Add Setting to enable / disable feature

This commit is contained in:
Patrick Magauran 2024-02-06 22:52:59 -05:00
parent e8db2b6401
commit 768e9f8801
4 changed files with 22 additions and 4 deletions

View File

@ -126,7 +126,7 @@
<div class="flex-grow-1 ml-2"
style="text-overflow: ellipsis; overflow-wrap: anywhere;">
<span class="two-row-text">
<a :href="resolveDjangoUrl('view_recipe', `${plan.entry.recipe.id}-${plan.entry.servings}`)" v-if="plan.entry.recipe">{{ plan.entry.recipe.name }}</a>
<a :href="getRecipeURL(plan.entry.recipe, plan.entry.servings)" v-if="plan.entry.recipe">{{ plan.entry.recipe.name }}</a>
<span v-else>{{ plan.entry.title }}</span> <br/>
</span>
<span v-if="plan.entry.note" class="two-row-text">
@ -298,6 +298,7 @@ export default {
displayPeriodCount: 2,
startingDayOfWeek: 1,
displayWeekNumbers: true,
autoLoadServings: true,
},
dragged_item: null,
meal_types: [],
@ -392,10 +393,19 @@ export default {
},
},
methods: {
getRecipeURL: function (recipe, servings) {
let slug
if (this.settings.autoLoadServings) {
slug = `${recipe.id}-${servings}`
} else {
slug = recipe.id
}
return this.resolveDjangoUrl("view_recipe",slug)
},
openRecipe: function (recipe, servings) {
let ur = this.resolveDjangoUrl("view_recipe", `${recipe.id}-${servings}`)
console.log(ur)
window.open(ur)
window.open(this.getRecipeURL(recipe, servings))
},
setStartingDay(days) {
if (this.settings.startingDayOfWeek + days < 0) {

View File

@ -35,6 +35,11 @@
{{ $t("Show_Week_Numbers") }}
</b-form-checkbox>
</b-form-group>
<b-form-group id="AutoServingsInput" :label="$t('Auto_Servings')">
<b-form-checkbox v-model="settings.autoLoadServings" name="auto_servings">
{{ $t("Auto_Link_servings") }}
</b-form-checkbox>
</b-form-group>
</b-form>
<hr/>

View File

@ -264,6 +264,8 @@
"Add_Servings_to_Shopping": "Add {servings} Servings to Shopping",
"Week_Numbers": "Week numbers",
"Show_Week_Numbers": "Show week numbers ?",
"Auto_Servings": "Servings Link",
"Auto_Link_servings": "Open Recipes with number of servings specified in plan ?",
"Export_As_ICal": "Export current period to iCal format",
"Export_To_ICal": "Export .ics",
"Cannot_Add_Notes_To_Shopping": "Notes cannot be added to the shopping list",

View File

@ -108,6 +108,7 @@ export const useMealPlanStore = defineStore(_STORE_ID, {
displayPeriodCount: 3,
startingDayOfWeek: 1,
displayWeekNumbers: true,
autoLoadServings: true,
}
} else {
return JSON.parse(s)