mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 21:58:54 -05:00
supermarket editor done
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
<delete-confirm-dialog :object-name="objectName" :model-name="$t(modelClass.model.localizationKey)" @delete="emit('delete')"></delete-confirm-dialog>
|
<delete-confirm-dialog :object-name="objectName" :model-name="$t(modelClass.model.localizationKey)" @delete="emit('delete')"></delete-confirm-dialog>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn color="save" prepend-icon="$create" @click="emit('save')" v-if="!isUpdate && !modelClass.model.disableCreate">{{ $t('Create') }}</v-btn>
|
<v-btn color="save" prepend-icon="$create" @click="emit('save')" v-if="!isUpdate && !modelClass.model.disableCreate">{{ $t('Create') }}</v-btn>
|
||||||
<v-btn color="save" prepend-icon="$save" @click="emit('save')" v-if="isUpdate && !modelClass.model.disableUpdate">{{ $t('Update') }}</v-btn>
|
<v-btn color="save" prepend-icon="$save" @click="emit('save')" v-if="isUpdate && !modelClass.model.disableUpdate">{{ $t('Save') }}</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ const emit = defineEmits(['create', 'save', 'delete', 'close'])
|
|||||||
const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading, editingObj, modelClass} = useModelEditorFunctions<Supermarket>('Supermarket', emit)
|
const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading, editingObj, modelClass} = useModelEditorFunctions<Supermarket>('Supermarket', emit)
|
||||||
|
|
||||||
// object specific data (for selects/display)
|
// object specific data (for selects/display)
|
||||||
const tab = ref("categories")
|
const tab = ref("supermarket")
|
||||||
|
|
||||||
// all available supermarket categories
|
// all available supermarket categories
|
||||||
const supermarketCategories = ref([] as SupermarketCategory[])
|
const supermarketCategories = ref([] as SupermarketCategory[])
|
||||||
@@ -172,7 +172,6 @@ function sortCategoryRelations(startIndex: number = 0) {
|
|||||||
|
|
||||||
if (!preventSort.value) {
|
if (!preventSort.value) {
|
||||||
editingObjectSupermarketCategoriesRelations.value.forEach((sc, index) => {
|
editingObjectSupermarketCategoriesRelations.value.forEach((sc, index) => {
|
||||||
console.log('sorting ', index, startIndex)
|
|
||||||
if (index >= startIndex) {
|
if (index >= startIndex) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
sc.order = 0
|
sc.order = 0
|
||||||
@@ -204,7 +203,7 @@ function addCategoryRelation(sCR: SupermarketCategoryRelation) {
|
|||||||
} else {
|
} else {
|
||||||
sCR.order = 0
|
sCR.order = 0
|
||||||
}
|
}
|
||||||
} else {
|
} else if (editingObjectSupermarketCategoriesRelations.value.length > 0) {
|
||||||
// item will be added last to list so give it the highest order
|
// item will be added last to list so give it the highest order
|
||||||
sCR.order = editingObjectSupermarketCategoriesRelations.value[editingObjectSupermarketCategoriesRelations.value.length - 1].order! + 1
|
sCR.order = editingObjectSupermarketCategoriesRelations.value[editingObjectSupermarketCategoriesRelations.value.length - 1].order! + 1
|
||||||
}
|
}
|
||||||
@@ -221,8 +220,7 @@ function addCategoryRelation(sCR: SupermarketCategoryRelation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preventSort.value = false
|
preventSort.value = false
|
||||||
// TODO reorder existing items after index
|
sortCategoryRelations(relationIndex)
|
||||||
|
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
useMessageStore().addError(ErrorMessageType.CREATE_ERROR, err)
|
useMessageStore().addError(ErrorMessageType.CREATE_ERROR, err)
|
||||||
preventSort.value = false
|
preventSort.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user