fixed deleting objects
This commit is contained in:
parent
d3376b33d8
commit
20bc1c5c2a
@ -48,7 +48,7 @@
|
||||
|
||||
<h6 class="mt-2">{{ $t('Entries') }}</h6>
|
||||
|
||||
<b-button variant="danger" block @click="detail_modal_visible = false;useShoppingListStore().deleteFood(food)">{{ $t('Delete_All') }}</b-button>
|
||||
<b-button variant="danger" block @click="detail_modal_visible = false;useShoppingListStore().deleteEntries(entries)">{{ $t('Delete_All') }}</b-button>
|
||||
|
||||
<b-row v-for="e in entries" v-bind:key="e.id">
|
||||
<b-col cold="12">
|
||||
|
@ -96,11 +96,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||
deleteObject(object) {
|
||||
let apiClient = new ApiApiFactory()
|
||||
return apiClient.destroyShoppingListEntry(object.id).then((r) => {
|
||||
|
||||
Vue.delete(this.category_food_entries[this.getFoodCategory(object.food)]['foods'][object.food.id]['entries'], object.id)
|
||||
if (Object.keys(this.category_food_entries[this.getFoodCategory(object.food)]['foods'][object.food.id]['entries']).length === 0) {
|
||||
Vue.delete(this.category_food_entries[this.getFoodCategory(object.food)]['foods'], object.food.id)
|
||||
}
|
||||
Vue.delete(this.entries, object.id)
|
||||
}).catch((err) => {
|
||||
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
|
||||
})
|
||||
@ -167,11 +163,11 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||
this.updateObject(this.entries[i])
|
||||
}
|
||||
},
|
||||
/**
|
||||
* function to handle user "delaying" shopping entries
|
||||
* @param {{}} entries set of entries
|
||||
*/
|
||||
delayEntries(entries) {
|
||||
/**
|
||||
* function to handle user "delaying" shopping entry
|
||||
* takes a food object as an argument and delays all entries associated with the food
|
||||
*/
|
||||
let delay = 4 //TODO get delay from settings
|
||||
let delay_date = new Date(Date.now() + delay * (60 * 60 * 1000))
|
||||
|
||||
@ -181,13 +177,13 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||
this.updateObject(this.entries[i])
|
||||
}
|
||||
},
|
||||
deleteFood(food) {
|
||||
/**
|
||||
* function to handle user deleting all entries of a certain food
|
||||
*/
|
||||
let entries = this.category_food_entries[this.getFoodCategory(food)]['foods'][food.id]['entries']
|
||||
/**
|
||||
* delete list of entries
|
||||
* @param {{}} entries set of entries
|
||||
*/
|
||||
deleteEntries(entries) {
|
||||
for (let i in entries) {
|
||||
this.deleteObject(entries[i])
|
||||
this.deleteObject(this.entries[i])
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user