improvements to recipe tab

This commit is contained in:
vabene1111
2023-12-28 00:19:12 +01:00
parent 2c3e0b547b
commit 063c64d078
2 changed files with 82 additions and 198 deletions

View File

@@ -67,11 +67,13 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
return ordered_structure
},
/**
* list of options available for grouping entry display
* @return {[{id: *, translatable_label: string},{id: *, translatable_label: string},{id: *, translatable_label: string}]}
*/
grouping_options: function () {
return [{'id': this.GROUP_CATEGORY, 'translatable_label': 'Category'}, {'id': this.GROUP_CREATED_BY, 'translatable_label': 'created_by'}, {'id': this.GROUP_RECIPE, 'translatable_label': 'Recipe'}]
}
},
},
actions: {
// TODO implement shopping list recipes
@@ -148,6 +150,21 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
})
},
/**
* returns a distinct list of recipes associated with unchecked shopping list entries
*/
getAssociatedRecipes: function () {
let recipes = {}
for (let i in this.entries) {
let e = this.entries[i]
if (e.recipe_mealplan !== null) {
Vue.set(recipes, e.recipe_mealplan.recipe, {'shopping_list_recipe_id': e.list_recipe, 'recipe_id': e.recipe_mealplan.recipe, 'recipe_name': e.recipe_mealplan.recipe_name, 'servings': e.recipe_mealplan.servings})
}
}
return recipes
},
// convenience methods
/**
* function to set entry to its proper place in the data structure to perform grouping