From c36eaf934f9efcd29242c0c575e227b3b8971979 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Thu, 20 Mar 2025 21:33:51 +0100 Subject: [PATCH] enable food property deletion --- vue3/src/pages/PropertyEditorPage.vue | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/vue3/src/pages/PropertyEditorPage.vue b/vue3/src/pages/PropertyEditorPage.vue index 744a0fc62..ddecb7654 100644 --- a/vue3/src/pages/PropertyEditorPage.vue +++ b/vue3/src/pages/PropertyEditorPage.vue @@ -64,7 +64,7 @@ + :loading="food.loading" @click:clear="deleteFoodProperty(p, food)" clearable> @@ -263,6 +263,28 @@ function buildFoodProperties(food: Food) { return food } +/** + * deletes the given property either on client or also on server if it has an id + * @param p + * @param food + */ +function deleteFoodProperty(p: Property, food: Food & { loading?: boolean } ){ + let api = new ApiApi() + + if(p.id){ + food.loading = true + api.apiPropertyDestroy({id: p.id}).then(r => { + p.propertyAmount = null + }).catch(err => { + useMessageStore().addError(ErrorMessageType.DELETE_ERROR, err) + }).finally(() => { + food.loading = false + }) + } else { + p.propertyAmount = null + } +} + /** * update food * @param food