auto open/close shopping list when checked
This commit is contained in:
parent
66ce1a88f6
commit
4b7896f7d1
@ -412,6 +412,7 @@
|
|||||||
amount: undefined,
|
amount: undefined,
|
||||||
food: undefined,
|
food: undefined,
|
||||||
},
|
},
|
||||||
|
unchecked_entries: 0,
|
||||||
foods: [],
|
foods: [],
|
||||||
foods_loading: false,
|
foods_loading: false,
|
||||||
units: [],
|
units: [],
|
||||||
@ -449,6 +450,7 @@
|
|||||||
return cache
|
return cache
|
||||||
},
|
},
|
||||||
display_categories() {
|
display_categories() {
|
||||||
|
this.unchecked_entries = 0
|
||||||
let categories = {
|
let categories = {
|
||||||
no_category: {
|
no_category: {
|
||||||
name: gettext('Uncategorized'),
|
name: gettext('Uncategorized'),
|
||||||
@ -514,6 +516,9 @@
|
|||||||
categories['no_category'].entries.push(item)
|
categories['no_category'].entries.push(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!item.checked) {
|
||||||
|
this.unchecked_entries += 1
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let ordered_categories = []
|
let ordered_categories = []
|
||||||
@ -772,6 +777,27 @@
|
|||||||
|
|
||||||
Promise.allSettled(updates).then(() => {
|
Promise.allSettled(updates).then(() => {
|
||||||
this.auto_sync_blocked = false
|
this.auto_sync_blocked = false
|
||||||
|
if (this.unchecked_entries < 1) {
|
||||||
|
this.shopping_list.finished = true
|
||||||
|
|
||||||
|
this.$http.put("{% url 'api:shoppinglist-detail' 123456 %}".replace('123456', this.shopping_list.id), this.shopping_list, {}).then((response) => {
|
||||||
|
this.makeToast(gettext('Finished'), gettext('Shopping list finished!'), 'success')
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
this.makeToast(gettext('Error'), gettext("There was an error updating a resource!") + err.bodyText, 'danger')
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if (this.unchecked_entries > 0 && this.shopping_list.finished) {
|
||||||
|
this.shopping_list.finished = false
|
||||||
|
|
||||||
|
this.$http.put("{% url 'api:shoppinglist-detail' 123456 %}".replace('123456', this.shopping_list.id), this.shopping_list, {}).then((response) => {
|
||||||
|
this.makeToast(gettext('Open'), gettext('Shopping list reopened!'), 'success')
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
this.makeToast(gettext('Error'), gettext("There was an error updating a resource!") + err.bodyText, 'danger')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addEntry: function () {
|
addEntry: function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user