feat(property): assign new property to global option property
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
789502c1b2
commit
12ec914603
1 changed files with 31 additions and 2 deletions
|
|
@ -14,19 +14,22 @@ import { FloatingActionButton, PaginationComponent } from 'src/components';
|
|||
import PaginationPageSize from 'src/components/PaginationPageSize.vue';
|
||||
import PropertyDialog from './PropertyDialog.vue';
|
||||
import { Property } from 'src/stores/property/types';
|
||||
import { dialog } from 'src/stores/utils';
|
||||
import { dialog, toCamelCase } from 'src/stores/utils';
|
||||
import CreateButton from 'src/components/AddButton.vue';
|
||||
import useOptionStore from 'stores/options';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, locale } = useI18n();
|
||||
const $q = useQuasar();
|
||||
const navigatorStore = useNavigator();
|
||||
const propertyStore = useProperty();
|
||||
const optionStore = useOptionStore();
|
||||
const {
|
||||
data: propertyData,
|
||||
page: propertyPage,
|
||||
pageSize: propertyPageSize,
|
||||
pageMax: propertyPageMax,
|
||||
} = storeToRefs(propertyStore);
|
||||
const { globalOption } = storeToRefs(optionStore);
|
||||
|
||||
const currPropertyData = ref<Property>();
|
||||
const formProperty = ref<Property>({
|
||||
|
|
@ -146,6 +149,7 @@ async function fetchPropertyList(mobileFetch?: boolean) {
|
|||
|
||||
function triggerDialog(type: 'add' | 'edit' | 'view') {
|
||||
if (type === 'add') {
|
||||
resetForm();
|
||||
pageState.addModal = true;
|
||||
pageState.isDrawerEdit = true;
|
||||
}
|
||||
|
|
@ -271,6 +275,31 @@ async function submit() {
|
|||
});
|
||||
}
|
||||
await fetchPropertyList($q.screen.xs);
|
||||
|
||||
// assign new property to global option
|
||||
const propList = propertyData.value.map((v) => {
|
||||
return {
|
||||
label: locale.value === 'eng' ? v.nameEN : v.name,
|
||||
value: toCamelCase(v.nameEN),
|
||||
type: v.type.type,
|
||||
};
|
||||
});
|
||||
|
||||
const existingValues = new Set(
|
||||
globalOption.value.propertiesField.map(
|
||||
(item: { value: string }) => item.value,
|
||||
),
|
||||
);
|
||||
const newProps = propList.filter((prop) => !existingValues.has(prop.value));
|
||||
if (newProps) {
|
||||
globalOption.value.propertiesField.splice(
|
||||
globalOption.value.propertiesField.length - 4,
|
||||
0,
|
||||
...newProps,
|
||||
);
|
||||
}
|
||||
|
||||
currPropertyData.value;
|
||||
resetForm();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue