From 1a595d4d0f441a040fa385ee62287ad3a62f2772 Mon Sep 17 00:00:00 2001 From: smashngrabb <41264963+smashngrabb@users.noreply.github.com> Date: Fri, 31 Jul 2026 04:02:44 +0800 Subject: [PATCH] feat: add re-roll button to meal planner entries (#7348) Co-authored-by: Michael Genson --- frontend/app/lang/messages/en-US.json | 3 +- .../pages/household/mealplan/planner/edit.vue | 31 ++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/frontend/app/lang/messages/en-US.json b/frontend/app/lang/messages/en-US.json index 1201b9ebc..1a07fccde 100644 --- a/frontend/app/lang/messages/en-US.json +++ b/frontend/app/lang/messages/en-US.json @@ -410,7 +410,8 @@ "applies-on-days": "Applies on {0}s", "meal-plan-settings": "Meal Plan Settings", "add-all-to-list": "Add All to List", - "add-day-to-list": "Add Day to List" + "add-day-to-list": "Add Day to List", + "randomize-recipe": "Randomize Recipe" }, "migration": { "migration-data-removed": "Migration data removed", diff --git a/frontend/app/pages/household/mealplan/planner/edit.vue b/frontend/app/pages/household/mealplan/planner/edit.vue index b8fbe19b1..a1337e140 100644 --- a/frontend/app/pages/household/mealplan/planner/edit.vue +++ b/frontend/app/pages/household/mealplan/planner/edit.vue @@ -155,7 +155,18 @@ - + + {{ $globals.icons.diceMultiple }} + + {{ $globals.icons.delete }} @@ -391,6 +402,24 @@ async function randomMeal(date: Date, type: PlanEntryType) { } } +async function randomizeMeal(mealplan: UpdatePlanEntry) { + if (!mealplan.entryType) { + return; + } + + // Delete the current entry, then create a new random one with the same date and type + const { data: deleted } = await api.mealplans.deleteOne(mealplan.id); + if (deleted) { + await api.mealplans.setRandom({ + date: mealplan.date, + entryType: mealplan.entryType, + }); + + // Refresh either way: if setRandom failed we still need to reflect the deletion + props.actions.refreshAll(); + } +} + // ===================================================== // Search