mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-08-07 11:24:52 +00:00
feat: add re-roll button to meal planner entries (#7348)
Co-authored-by: Michael Genson <genson.michael@gmail.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -155,7 +155,18 @@
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
<v-btn class="ml-auto" size="small" variant="text" icon @click="actions.deleteOne(mealplan.id)">
|
||||
<v-btn
|
||||
v-if="mealplan.recipe && mealplan.entryType"
|
||||
class="ml-auto"
|
||||
size="small"
|
||||
variant="text"
|
||||
icon
|
||||
:title="$t('meal-plan.randomize-recipe')"
|
||||
@click="randomizeMeal(mealplan)"
|
||||
>
|
||||
<v-icon>{{ $globals.icons.diceMultiple }}</v-icon>
|
||||
</v-btn>
|
||||
<v-btn :class="{ 'ml-auto': !mealplan.recipe || !mealplan.entryType }" size="small" variant="text" icon @click="actions.deleteOne(mealplan.id)">
|
||||
<v-icon>{{ $globals.icons.delete }}</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user