mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-20 13:33:39 -07:00
fix merge conflicts from my own PR lol
This commit is contained in:
parent
6095e9d816
commit
ef362603ba
2 changed files with 3 additions and 24 deletions
|
@ -20,13 +20,12 @@ export function useShoppingListCrud(
|
||||||
const createListItemData = ref<ShoppingListItemOut>(listItemFactory());
|
const createListItemData = ref<ShoppingListItemOut>(listItemFactory());
|
||||||
const localLabels = ref<ShoppingListMultiPurposeLabelOut[]>();
|
const localLabels = ref<ShoppingListMultiPurposeLabelOut[]>();
|
||||||
|
|
||||||
function listItemFactory(isFood = false): ShoppingListItemOut {
|
function listItemFactory(): ShoppingListItemOut {
|
||||||
return {
|
return {
|
||||||
id: uuid4(),
|
id: uuid4(),
|
||||||
shoppingListId: shoppingList.value?.id || "",
|
shoppingListId: shoppingList.value?.id || "",
|
||||||
checked: false,
|
checked: false,
|
||||||
position: shoppingList.value?.listItems?.length || 1,
|
position: shoppingList.value?.listItems?.length || 1,
|
||||||
isFood,
|
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
note: "",
|
note: "",
|
||||||
labelId: undefined,
|
labelId: undefined,
|
||||||
|
@ -169,7 +168,7 @@ export function useShoppingListCrud(
|
||||||
shoppingList.value.listItems.push(createListItemData.value);
|
shoppingList.value.listItems.push(createListItemData.value);
|
||||||
updateListItemOrder();
|
updateListItemOrder();
|
||||||
}
|
}
|
||||||
createListItemData.value = listItemFactory(createListItemData.value.isFood || false);
|
createListItemData.value = listItemFactory();
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,31 +235,12 @@ export function useShoppingListCrud(
|
||||||
// Context menu actions
|
// Context menu actions
|
||||||
const contextActions = {
|
const contextActions = {
|
||||||
delete: "delete",
|
delete: "delete",
|
||||||
setIngredient: "setIngredient",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const contextMenu = [
|
const contextMenu = [
|
||||||
{ title: t("general.delete"), action: contextActions.delete },
|
{ title: t("general.delete"), action: contextActions.delete },
|
||||||
{ title: t("recipe.ingredient"), action: contextActions.setIngredient },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function contextMenuAction(action: string, item: ShoppingListItemOut, idx: number) {
|
|
||||||
if (!shoppingList.value?.listItems) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case contextActions.delete:
|
|
||||||
shoppingList.value.listItems = shoppingList.value?.listItems.filter(itm => itm.id !== item.id);
|
|
||||||
break;
|
|
||||||
case contextActions.setIngredient:
|
|
||||||
shoppingList.value.listItems[idx].isFood = !shoppingList.value.listItems[idx].isFood;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
createListItemData,
|
createListItemData,
|
||||||
localLabels,
|
localLabels,
|
||||||
|
@ -279,6 +259,5 @@ export function useShoppingListCrud(
|
||||||
toggleReorderLabelsDialog,
|
toggleReorderLabelsDialog,
|
||||||
contextActions,
|
contextActions,
|
||||||
contextMenu,
|
contextMenu,
|
||||||
contextMenuAction,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ export function useShoppingListSorting() {
|
||||||
shoppingList.listItems.forEach((item) => {
|
shoppingList.listItems.forEach((item) => {
|
||||||
const key = item.checked
|
const key = item.checked
|
||||||
? checkedItemKey
|
? checkedItemKey
|
||||||
: item.isFood && item.food?.name
|
: item.food?.name
|
||||||
? item.food.name
|
? item.food.name
|
||||||
: item.note || "";
|
: item.note || "";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue