From 247dd30b209471ad8665e3f8ecfedbdcef10619d Mon Sep 17 00:00:00 2001 From: smilerz Date: Mon, 25 Oct 2021 11:55:36 -0500 Subject: [PATCH] fade-enter-active --- vue/src/apps/ChecklistView/ChecklistView.vue | 181 +++++++++---------- vue/src/components/Ingredient.vue | 39 +--- vue/src/components/ShoppingLineItem.vue | 164 +++++++++++++---- 3 files changed, 221 insertions(+), 163 deletions(-) diff --git a/vue/src/apps/ChecklistView/ChecklistView.vue b/vue/src/apps/ChecklistView/ChecklistView.vue index fd86f5b15..0db80ec28 100644 --- a/vue/src/apps/ChecklistView/ChecklistView.vue +++ b/vue/src/apps/ChecklistView/ChecklistView.vue @@ -20,7 +20,7 @@
-
+
@@ -52,80 +52,6 @@ @open-context-menu="openContextMenu" @toggle-checkbox="toggleChecked" > - -
@@ -134,7 +60,15 @@
- These are the settings + + These are the settings
-sort supermarket categories
+ -add supermarket categories
+ - add supermarkets autosync time
+ autosync on/off
+ always restrict supermarket to categories?
+ when restricted or filterd - give visual indication
+ how long to defer shopping - default tomorrow +
@@ -159,25 +93,54 @@ @@ -71,6 +101,10 @@ import Vue from "vue" import { BootstrapVue } from "bootstrap-vue" import "bootstrap-vue/dist/bootstrap-vue.css" +import ContextMenu from "@/components/ContextMenu/ContextMenu" +import ContextMenuItem from "@/components/ContextMenu/ContextMenuItem" +import { ApiMixin } from "@/utils/utils" +import RecipeCard from "./RecipeCard.vue" Vue.use(BootstrapVue) @@ -78,8 +112,8 @@ export default { // TODO ApiGenerator doesn't capture and share error information - would be nice to share error details when available // or i'm capturing it incorrectly name: "ShoppingLineItem", - mixins: [], - components: {}, + mixins: [ApiMixin], + components: { RecipeCard, ContextMenu, ContextMenuItem }, props: { entries: { type: Array, @@ -89,14 +123,15 @@ export default { data() { return { showDetails: false, + recipe: undefined, } }, computed: { formatAmount: function() { - return this.entries[0].amount + return this.formatOneAmount(this.entries[0]) }, formatCategory: function() { - return this.entries[0]?.food?.supermarket_category?.name ?? this.$t("Undefined") + return this.formatOneCategory(this.entries[0]) || this.$t("Undefined") }, formatChecked: function() { return false @@ -109,20 +144,24 @@ export default { } }, formatFood: function() { - return this.entries[0]?.food?.name ?? this.$t("Undefined") + return this.formatOneFood(this.entries[0]) }, formatUnit: function() { - return this.entries[0]?.unit?.name ?? this.$t("Undefined") + return this.formatOneUnit(this.entries[0]) }, formatRecipe: function() { - if (this.entries.length == 1) { - return this.entries[0]?.recipe_mealplan?.name ?? this.$t("Undefined") + if (this.entries?.length == 1) { + return this.formatOneMealPlan(this.entries[0]) || "" } else { - return [this.entries[0]?.recipe_mealplan?.name ?? this.$t("Undefined"), this.$t("CountMore", { count: this.entries.length - 1 })].join(" ") + let mealplan_name = this.entries.filter((x) => x?.recipe_mealplan?.name) + return [this.formatOneMealPlan(mealplan_name?.[0]), this.$t("CountMore", { count: this.entries?.length - 1 })].join(" ") } }, formatNotes: function() { - return [this.entries[0]?.recipe_mealplan?.mealplan_note, this.entries?.ingredient_note].filter(String).join("\n") + if (this.entries?.length == 1) { + return this.formatOneNote(this.entries[0]) || "" + } + return "" }, }, watch: {}, @@ -146,10 +185,57 @@ export default { // this.saveThis(item, false) // this.$refs.table.refresh() }, + formatOneAmount: function(item) { + return item?.amount ?? 1 + }, + formatOneUnit: function(item) { + return item?.unit?.name ?? "" + }, + formatOneCategory: function(item) { + return item?.food?.supermarket_category?.name + }, + formatOneFood: function(item) { + return item.food.name + }, + formatOneChecked: function(item) { + return item.checked + }, + formatOneMealPlan: function(item) { + return item?.recipe_mealplan?.name + }, + formatOneRecipe: function(item) { + return item?.recipe_mealplan?.recipe_name + }, + formatOneNote: function(item) { + if (!item) { + item = this.entries[0] + } + return [item?.recipe_mealplan?.mealplan_note, item?.ingredient_note].filter(String) + }, + formatOneCreatedBy: function(item) { + return [item?.created_by.username, "@", this.formatDate(item.created_at)].join(" ") + }, + openRecipeCard: function(e, item) { + this.genericAPI(this.Models.RECIPE, this.Actions.FETCH, { id: item.recipe_mealplan.recipe }).then((result) => { + let recipe = result.data + recipe.steps = undefined + this.recipe = true + this.$refs.recipe_card.open(e, recipe) + }) + }, }, } - +