mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
meal plan fixes
- added translations - form validation & tagging support for meal types
This commit is contained in:
@@ -31,11 +31,11 @@
|
||||
<b-tab :title="$t('Settings')">
|
||||
<div class="row mt-3">
|
||||
<div class="col-3 calender-options">
|
||||
<h5>{{ $t('CalenderSettings') }}</h5>
|
||||
<h5>{{ $t('Planner_Settings') }}</h5>
|
||||
<b-form>
|
||||
<b-form-group id="UomInput"
|
||||
:label="$t('Period')"
|
||||
:description="$t('PeriodToShow')"
|
||||
:description="$t('Plan_Period_To_Show')"
|
||||
label-for="UomInput">
|
||||
<b-form-select
|
||||
id="UomInput"
|
||||
@@ -44,8 +44,8 @@
|
||||
></b-form-select>
|
||||
</b-form-group>
|
||||
<b-form-group id="PeriodInput"
|
||||
:label="$t('PeriodCount')"
|
||||
:description="$t('ShowHowManyPeriods')"
|
||||
:label="$t('Periods')"
|
||||
:description="$t('Plan_Show_How_Many_Periods')"
|
||||
label-for="PeriodInput">
|
||||
<b-form-select
|
||||
id="PeriodInput"
|
||||
@@ -54,8 +54,8 @@
|
||||
></b-form-select>
|
||||
</b-form-group>
|
||||
<b-form-group id="DaysInput"
|
||||
:label="$t('StartingDay')"
|
||||
:description="$t('StartingDay')"
|
||||
:label="$t('Starting_Day')"
|
||||
:description="$t('Starting_Day')"
|
||||
label-for="DaysInput">
|
||||
<b-form-select
|
||||
id="DaysInput"
|
||||
@@ -66,7 +66,7 @@
|
||||
</b-form>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h5>{{ $t('MealTypes') }}</h5>
|
||||
<h5>{{ $t('Meal_Types') }}</h5>
|
||||
<b-form>
|
||||
|
||||
</b-form>
|
||||
@@ -82,10 +82,10 @@
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-pen"></i> {{ $t("Edit") }}</a>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @click="$refs.menu.close();moveEntryLeft(contextData)">
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-arrow-left"></i> {{ $t("DayBack") }}</a>
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-arrow-left"></i> {{ $t("Move") }}</a>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @click="$refs.menu.close();moveEntryRight(contextData)">
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-arrow-right"></i> {{ $t("DayForward") }}</a>
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-arrow-right"></i> {{ $t("Move") }}</a>
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @click="$refs.menu.close();createEntry(contextData.originalItem.entry)">
|
||||
<a class="dropdown-item p-2" href="#"><i class="fas fa-copy"></i> {{ $t("Clone") }}</a>
|
||||
@@ -98,7 +98,7 @@
|
||||
<meal-plan-edit-modal :entry="entryEditing" :entryEditing_initial_recipe="entryEditing_initial_recipe"
|
||||
:entry-editing_initial_meal_type="entryEditing_initial_meal_type" :modal_title="modal_title"
|
||||
:edit_modal_show="edit_modal_show" @save-entry="editEntry"
|
||||
@delete-entry="deleteEntry"></meal-plan-edit-modal>
|
||||
@delete-entry="deleteEntry" @reload-meal-types="refreshMealTypes"></meal-plan-edit-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -178,9 +178,9 @@ export default {
|
||||
computed: {
|
||||
modal_title: function () {
|
||||
if (this.entryEditing.id === -1) {
|
||||
return this.$t('CreateMealPlanEntry')
|
||||
return this.$t('Create_Meal_Plan_Entry')
|
||||
} else {
|
||||
return this.$t('EditMealPlanEntry')
|
||||
return this.$t('Edit_Meal_Plan_Entry')
|
||||
}
|
||||
},
|
||||
entryEditing_initial_recipe: function () {
|
||||
@@ -332,6 +332,11 @@ export default {
|
||||
}).then(result => {
|
||||
this.plan_entries = result.data
|
||||
})
|
||||
this.refreshMealTypes()
|
||||
},
|
||||
refreshMealTypes() {
|
||||
let apiClient = new ApiApiFactory()
|
||||
|
||||
apiClient.listMealTypes().then(result => {
|
||||
this.meal_types = result.data
|
||||
})
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<div class="actionArea d-none d-sm-flex">
|
||||
<span class="delete-area text-danger p-1 mr-2" @drop.prevent="onDeleteDrop($event)"
|
||||
@dragenter.prevent="onDeleteDragEnter($event)" @dragleave.prevent="onDeleteDragLeave($event)" @dragover.prevent="onDeleteDragEnter"><i
|
||||
class="fas fa-trash"></i> {{ $t('DragHereToDelete') }}</span>
|
||||
class="fas fa-trash"></i> {{ $t('Drag_Here_To_Delete') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
<div class="col-6 col-lg-9">
|
||||
<b-input-group>
|
||||
<b-form-input id="TitleInput" v-model="entryEditing.title"
|
||||
:placeholder="entryEditing.title_placeholder"></b-form-input>
|
||||
:placeholder="entryEditing.title_placeholder"
|
||||
@change="missing_recipe = false"></b-form-input>
|
||||
<b-input-group-append class="d-none d-lg-block">
|
||||
<b-button variant="primary" @click="entryEditing.title = ''"><i class="fa fa-eraser"></i></b-button>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
<small tabindex="-1" class="form-text text-muted">{{ $t("Title") }}</small>
|
||||
<span class="text-danger" v-if="missing_recipe">{{ $t('Title_or_Recipe_Required') }}</span>
|
||||
<small tabindex="-1" class="form-text text-muted" v-if="!missing_recipe">{{ $t("Title") }}</small>
|
||||
</div>
|
||||
<div class="col-6 col-lg-3">
|
||||
<input type="date" id="DateInput" class="form-control" v-model="entryEditing.date">
|
||||
@@ -37,10 +39,15 @@
|
||||
:label="'name'"
|
||||
:model="Models.MEAL_TYPE"
|
||||
style="flex-grow: 1; flex-shrink: 1; flex-basis: 0"
|
||||
v-bind:placeholder="$t('MealType')" :limit="10"
|
||||
v-bind:placeholder="$t('Meal_Type')" :limit="10"
|
||||
:multiple="false"
|
||||
:initial_selection="entryEditing_initial_meal_type"></generic-multiselect>
|
||||
<small tabindex="-1" class="form-text text-muted">{{ $t("MealType") }}</small>
|
||||
:initial_selection="entryEditing_initial_meal_type"
|
||||
:allow_create="true"
|
||||
:create_placeholder="$t('Create_New_Meal_Type')"
|
||||
@new="createMealType"
|
||||
></generic-multiselect>
|
||||
<span class="text-danger" v-if="missing_meal_type">{{ $t('Meal_Type_Required') }}</span>
|
||||
<small tabindex="-1" class="form-text text-muted" v-if="!missing_meal_type">{{ $t("Meal_Type") }}</small>
|
||||
</b-form-group>
|
||||
<b-form-group
|
||||
label-for="NoteInput"
|
||||
@@ -76,6 +83,10 @@ import {BootstrapVue} from "bootstrap-vue";
|
||||
import GenericMultiselect from "./GenericMultiselect";
|
||||
import {ApiMixin} from "../utils/utils";
|
||||
|
||||
const {ApiApiFactory} = require("@/utils/openapi/api");
|
||||
|
||||
const {StandardToasts} = require("@/utils/utils");
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
|
||||
export default {
|
||||
@@ -101,7 +112,9 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
entryEditing: {}
|
||||
entryEditing: {},
|
||||
missing_recipe: false,
|
||||
missing_meal_type: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -114,29 +127,47 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
editEntry() {
|
||||
this.missing_meal_type = false
|
||||
this.missing_recipe = false
|
||||
let cancel = false
|
||||
if (this.entryEditing.meal_type == null) {
|
||||
alert("Need Meal type")
|
||||
return
|
||||
this.missing_meal_type = true
|
||||
cancel = true
|
||||
}
|
||||
if (this.entryEditing.recipe == null && this.entryEditing.title === '') {
|
||||
alert("Need title or recipe")
|
||||
return
|
||||
this.missing_recipe = true
|
||||
cancel = true
|
||||
}
|
||||
if (!cancel) {
|
||||
this.$bvModal.hide(`edit-modal`);
|
||||
this.$emit('save-entry', this.entryEditing)
|
||||
}
|
||||
this.$bvModal.hide(`edit-modal`);
|
||||
this.$emit('save-entry', this.entryEditing)
|
||||
},
|
||||
deleteEntry() {
|
||||
this.$bvModal.hide(`edit-modal`);
|
||||
this.$emit('delete-entry', this.entryEditing)
|
||||
},
|
||||
selectMealType(event) {
|
||||
this.missing_meal_type = false
|
||||
if (event.val != null) {
|
||||
this.entryEditing.meal_type = event.val;
|
||||
} else {
|
||||
this.entryEditing.meal_type = null;
|
||||
}
|
||||
},
|
||||
createMealType(event) {
|
||||
if (event != "") {
|
||||
let apiClient = new ApiApiFactory()
|
||||
|
||||
apiClient.createMealType({name: event}).then(e => {
|
||||
this.$emit('reload-meal-types')
|
||||
}).catch(error => {
|
||||
StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE)
|
||||
})
|
||||
}
|
||||
},
|
||||
selectRecipe(event) {
|
||||
this.missing_recipe = false
|
||||
if (event.val != null) {
|
||||
this.entryEditing.recipe = event.val;
|
||||
this.entryEditing.title_placeholder = this.entryEditing.recipe.name
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
<meal-plan-edit-modal :entry="entryEditing" :entryEditing_initial_recipe="[recipe]"
|
||||
:entry-editing_initial_meal_type="[]" @save-entry="saveMealPlan"
|
||||
:modal_id="`modal-meal-plan_${modal_id}`" :allow_delete="false" :modal_title="$t('CreateMealPlanEntry')"></meal-plan-edit-modal>
|
||||
:modal_id="`modal-meal-plan_${modal_id}`" :allow_delete="false" :modal_title="$t('Create_Meal_Plan_Entry')"></meal-plan-edit-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@
|
||||
"Create_New_Food": "Add New Food",
|
||||
"Create_New_Keyword": "Add New Keyword",
|
||||
"Create_New_Unit": "Add New Unit",
|
||||
"Create_New_Meal_Type": "Add New Meal Type",
|
||||
"and_up": "& Up",
|
||||
"Instructions": "Instructions",
|
||||
"Unrated": "Unrated",
|
||||
@@ -161,5 +162,24 @@
|
||||
"Key_Shift": "Shift",
|
||||
"Time": "Time",
|
||||
"Text": "Text",
|
||||
"Shopping_list": "Shopping List"
|
||||
"Shopping_list": "Shopping List",
|
||||
"Create_Meal_Plan_Entry": "Create meal plan entry",
|
||||
"Edit_Meal_Plan_Entry": "Edit meal plan entry",
|
||||
"Title": "Title",
|
||||
"Week": "Week",
|
||||
"Month": "Month",
|
||||
"Year": "Year",
|
||||
"Planner": "Planner",
|
||||
"Planner_Settings": "Planner settings",
|
||||
"Period": "Period",
|
||||
"Plan_Period_To_Show": "Show weeks, months or years",
|
||||
"Periods": "Periods",
|
||||
"Plan_Show_How_Many_Periods": "How many periods to show",
|
||||
"Starting_Day": "Starting day of the week",
|
||||
"Meal_Types": "Meal types",
|
||||
"Meal_Type": "Meal type",
|
||||
"Clone": "Clone",
|
||||
"Drag_Here_To_Delete": "Drag here to delete",
|
||||
"Meal_Type_Required": "Meal type is required",
|
||||
"Title_or_Recipe_Required": "Title or recipe selection required"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user