diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue index 5afe9f31..1e31282d 100644 --- a/vue/src/apps/ShoppingListView/ShoppingListView.vue +++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue @@ -21,7 +21,7 @@ + /> @@ -29,10 +29,9 @@ @@ -368,7 +367,7 @@
- {{ $t(go.translatable_label)}} + {{ $t(go.translatable_label) }} @@ -384,93 +383,32 @@ + content-cols="1" class="mb-1"> - {{ $t('Information')}} + {{ $t('Information') }} + content-cols="1" class="mb-1"> + content-cols="1" class="mb-1"> + content-cols="1" class="mb-1">
- {{ - $t("Reset") - }} - {{ $t("Close") }}
- - - + @@ -517,14 +455,12 @@ import "bootstrap-vue/dist/bootstrap-vue.css" import VueCookies from "vue-cookies" import draggable from "vuedraggable" -import ContextMenu from "@/components/ContextMenu/ContextMenu" -import ContextMenuItem from "@/components/ContextMenu/ContextMenuItem" + import ShoppingLineItem from "@/components/ShoppingLineItem" import DownloadPDF from "@/components/Buttons/DownloadPDF" import DownloadCSV from "@/components/Buttons/DownloadCSV" import CopyToClipboard from "@/components/Buttons/CopyToClipboard" import GenericMultiselect from "@/components/GenericMultiselect" -import LookupInput from "@/components/Modals/LookupInput" import ShoppingModal from "@/components/Modals/ShoppingModal" import {ApiMixin, getUserPreference, StandardToasts, makeToast, ResolveUrlMixin} from "@/utils/utils" @@ -533,7 +469,7 @@ import ShoppingSettingsComponent from "@/components/Settings/ShoppingSettingsCom Vue.use(BootstrapVue) Vue.use(VueCookies) -let SETTINGS_COOKIE_NAME = "shopping_settings" + import {Workbox} from 'workbox-window'; import BottomNavigationBar from "@/components/BottomNavigationBar.vue"; import {useShoppingListStore} from "@/stores/ShoppingListStore"; @@ -543,8 +479,7 @@ export default { name: "ShoppingListView", mixins: [ApiMixin, ResolveUrlMixin], components: { - ContextMenu, - ContextMenuItem, + ShoppingLineItem, GenericMultiselect, DownloadPDF, @@ -561,8 +496,7 @@ export default { // this.Models and this.Actions inherited from ApiMixin items: [], current_tab: 0, - group_by: "category", - group_by_choices: ["created_by", "category", "recipe"], + supermarkets: [], shopping_categories: [], show_undefined_categories: true, @@ -696,9 +630,6 @@ export default { // }) return [] }, - defaultDelay() { - return Number(getUserPreference("default_delay")) || 2 - }, editingSupermarket() { return this.supermarkets.filter((el) => { return el.editing @@ -711,22 +642,6 @@ export default { return [] } }, - formUnit() { - let unit = this.Models.SHOPPING_LIST.create.form.unit - unit.value = this.new_item.unit - return unit - }, - formFood() { - let food = this.Models.SHOPPING_LIST.create.form.food - food.value = this.new_item.food - return food - }, - itemsDelayed() { - return this.items.filter((x) => !x.delay_until || !Date.parse(x?.delay_until) > new Date(Date.now())).length < this.items.length - }, - filterApplied() { - return (this.itemsDelayed && !this.show_delay) || !this.show_undefined_categories || (this.supermarket_categories_only && this.ui.selected_supermarket) - }, Recipes() { // hiding recipes associated with shopping list items that are complete return [...new Map(this.items.filter((x) => x.list_recipe && !x.checked).map((item) => [item["list_recipe"], item])).values()] @@ -734,7 +649,6 @@ export default { supermarket_categories() { return this.shopping_categories }, - }, watch: { @@ -809,9 +723,11 @@ export default { setFocus() { this.$refs['amount_input_simple'].focus() }, - // this.genericAPI inherited from ApiMixin + /** + * get ingredient from input string and create new shopping list entry using it + */ addItem: function () { - + // this.genericAPI inherited from ApiMixin if (this.new_item.ingredient !== "" && this.new_item.ingredient !== undefined) { this.genericPostAPI("api_ingredient_from_string", {text: this.new_item.ingredient}).then((result) => { let unit = null @@ -828,38 +744,6 @@ export default { }) } }, - resetFilters: function () { - this.ui.selected_supermarket = undefined - this.supermarket_categories_only = this.settings.filter_to_supermarket - this.show_undefined_categories = true - this.group_by = "category" - this.show_delay = false - }, - delayThis: function (item) { - let entries = [] - let promises = [] - let delay_date = new Date(Date.now() + this.delay * (60 * 60 * 1000)) - - if (Array.isArray(item)) { - item = item.map((x) => { - return {...x, delay_until: delay_date} - }) - entries = item.map((x) => x.id) - } else { - item.delay_until = delay_date - entries = [item.id] - } - - entries.forEach((entry) => { - promises.push(this.saveThis({id: entry, delay_until: delay_date}, false)) - }) - Promise.all(promises).then(() => { - this.items = this.items.filter((x) => !entries.includes(x.id)) - this.delay = this.defaultDelay - }).catch(err => { - StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err) - }) - }, deleteRecipe: function (e, recipe) { let api = new ApiApiFactory() api.destroyShoppingListRecipe(recipe) diff --git a/vue/src/stores/ShoppingListStore.js b/vue/src/stores/ShoppingListStore.js index 5d4fa6ba..13750f90 100644 --- a/vue/src/stores/ShoppingListStore.js +++ b/vue/src/stores/ShoppingListStore.js @@ -188,7 +188,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, { * @param {{}} entries set of entries */ delayEntries(entries) { - let delay = 4 //TODO get delay from settings + let delay = 4 //TODO get delay from settings in an offline friendly way let delay_date = new Date(Date.now() + delay * (60 * 60 * 1000)) for (let i in entries) {