fixed deleting objects
This commit is contained in:
parent
d3376b33d8
commit
20bc1c5c2a
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
<h6 class="mt-2">{{ $t('Entries') }}</h6>
|
<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-row v-for="e in entries" v-bind:key="e.id">
|
||||||
<b-col cold="12">
|
<b-col cold="12">
|
||||||
|
@ -96,11 +96,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
|||||||
deleteObject(object) {
|
deleteObject(object) {
|
||||||
let apiClient = new ApiApiFactory()
|
let apiClient = new ApiApiFactory()
|
||||||
return apiClient.destroyShoppingListEntry(object.id).then((r) => {
|
return apiClient.destroyShoppingListEntry(object.id).then((r) => {
|
||||||
|
Vue.delete(this.entries, object.id)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
|
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
|
||||||
})
|
})
|
||||||
@ -167,11 +163,11 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
|||||||
this.updateObject(this.entries[i])
|
this.updateObject(this.entries[i])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* function to handle user "delaying" shopping entries
|
||||||
|
* @param {{}} entries set of entries
|
||||||
|
*/
|
||||||
delayEntries(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 = 4 //TODO get delay from settings
|
||||||
let delay_date = new Date(Date.now() + delay * (60 * 60 * 1000))
|
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])
|
this.updateObject(this.entries[i])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteFood(food) {
|
/**
|
||||||
/**
|
* delete list of entries
|
||||||
* function to handle user deleting all entries of a certain food
|
* @param {{}} entries set of entries
|
||||||
*/
|
*/
|
||||||
let entries = this.category_food_entries[this.getFoodCategory(food)]['foods'][food.id]['entries']
|
deleteEntries(entries) {
|
||||||
for (let i in entries) {
|
for (let i in entries) {
|
||||||
this.deleteObject(entries[i])
|
this.deleteObject(this.entries[i])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user