1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-25 08:09:41 +02:00

Refactor Shopping List API (#2021)

* tidied up shopping list item models
redefined recipe refs and updated models
added calculated display attribute to unify shopping list item rendering
added validation to use a food's label if an item's label is null

* fixed schema reference

* refactored shopping list item service
route all operations through one central method to account for edgecases
return item collections for all operations to account for merging
consolidate recipe items before sending them to the shopping list

* made fractions prettier

* replaced redundant display text util

* fixed edgecase for zero quantity items on a recipe

* fix for pre-merging recipe ingredients

* fixed edgecase for merging create_items together

* fixed bug with merged updated items creating dupes

* added test for self-removing recipe ref

* update items are now merged w/ existing items

* refactored service to make it easier to read

* added a lot of tests

* made it so checked items are never merged

* fixed bug with dragging + re-ordering

* fix for postgres cascade issue

* added prevalidator to recipe ref to avoid db error
This commit is contained in:
Michael Genson 2023-01-28 18:45:02 -06:00 committed by GitHub
parent 3415a9c310
commit 617cc1fdfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1398 additions and 576 deletions

View file

@ -10,7 +10,7 @@
>
<template #label>
<div :class="listItem.checked ? 'strike-through' : ''">
{{ displayText }}
{{ listItem.display }}
</div>
</template>
</v-checkbox>
@ -55,10 +55,9 @@
import { defineComponent, computed, ref, useContext } from "@nuxtjs/composition-api";
import ShoppingListItemEditor from "./ShoppingListItemEditor.vue";
import MultiPurposeLabel from "./MultiPurposeLabel.vue";
import { ShoppingListItemCreate } from "~/lib/api/types/group";
import { ShoppingListItemOut } from "~/lib/api/types/group";
import { MultiPurposeLabelOut } from "~/lib/api/types/labels";
import { IngredientFood, IngredientUnit } from "~/lib/api/types/recipe";
import { getDisplayText } from "~/composables/use-display-text";
import { MultiPurposeLabelSummary } from "~/lib/api/types/user";
interface actions {
@ -70,7 +69,7 @@ export default defineComponent({
components: { ShoppingListItemEditor, MultiPurposeLabel },
props: {
value: {
type: Object as () => ShoppingListItemCreate,
type: Object as () => ShoppingListItemOut,
required: true,
},
labels: {
@ -147,10 +146,6 @@ export default defineComponent({
});
});
const displayText = computed(() =>
getDisplayText(listItem.value.note, listItem.value.quantity, listItem.value.food, listItem.value.unit)
);
/**
* Gets the label for the shopping list item. Either the label assign to the item
* or the label of the food applied.
@ -170,7 +165,6 @@ export default defineComponent({
});
return {
displayText,
updatedLabels,
save,
contextHandler,