meal plan context menu added, further progress

This commit is contained in:
Kaibu
2021-09-22 20:03:03 +02:00
parent 2012ef9e46
commit 5c85369120
23 changed files with 442 additions and 219 deletions

View File

@ -3,18 +3,18 @@
<div class="row">
<div class="col col-md-12">
<div class="row">
<div class="col-md-9">
<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>
<b-input-group-append>
<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>
</div>
<div class="col-md-3">
<div class="col-6 col-lg-3">
<input type="date" id="DateInput" class="form-control" v-model="entryEditing.date">
<small tabindex="-1" class="form-text text-muted">{{ $t("Date") }}</small>
</div>
@ -24,7 +24,7 @@
<b-form-group>
<generic-multiselect
@change="selectRecipe"
:initial_selection="entryEditing_initial"
:initial_selection="entryEditing_initial_recipe"
:label="'name'"
:model="Models.RECIPE"
style="flex-grow: 1; flex-shrink: 1; flex-basis: 0"
@ -32,35 +32,40 @@
:multiple="false"></generic-multiselect>
<small tabindex="-1" class="form-text text-muted">{{ $t("Recipe") }}</small>
</b-form-group>
<b-input-group>
<b-form-input id="ServingsInput" v-model="entryEditing.servings"
:placeholder="$t('Servings')"></b-form-input>
</b-input-group>
<small tabindex="-1" class="form-text text-muted">{{ $t("Servings") }}</small>
<b-form-group
label-for="NoteInput"
:description="$t('Note')" class="mt-3">
<textarea class="form-control" id="NoteInput" v-model="entryEditing.note"
:placeholder="$t('Note')"></textarea>
</b-form-group>
<b-form-group>
<b-form-group class="mt-3">
<generic-multiselect required
@change="selectMealType"
:label="'name'"
:model="Models.MEAL_TYPE"
style="flex-grow: 1; flex-shrink: 1; flex-basis: 0"
v-bind:placeholder="$t('MealType')" :limit="10"
:multiple="false"></generic-multiselect>
:multiple="false"
:initial_selection="entryEditing_initial_meal_type"></generic-multiselect>
<small tabindex="-1" class="form-text text-muted">{{ $t("MealType") }}</small>
</b-form-group>
<b-form-group
label-for="NoteInput"
:description="$t('Note')" class="mt-3">
<textarea class="form-control" id="NoteInput" v-model="entryEditing.note"
:placeholder="$t('Note')"></textarea>
</b-form-group>
<b-input-group>
<b-form-input id="ServingsInput" v-model="entryEditing.servings"
:placeholder="$t('Servings')"></b-form-input>
</b-input-group>
<small tabindex="-1" class="form-text text-muted">{{ $t("Servings") }}</small>
</div>
<div class="col-lg-6 d-none d-lg-block d-xl-block">
<recipe-card :recipe="entryEditing.recipe" v-if="entryEditing.recipe != null"></recipe-card>
</div>
</div>
<b-button class="mt-2 mb-3 ml-md-2" variant="danger">{{ $t('Delete') }}
</b-button>
<b-button class="mt-2 mb-3 ml-2 float-right" variant="primary" @click="editEntry">{{ $t('Save') }}</b-button>
<div class="row mt-3 mb-3">
<div class="col-12">
<b-button variant="danger" @click="deleteEntry">{{ $t('Delete') }}
</b-button>
<b-button class="float-right" variant="primary" @click="editEntry">{{ $t('Save') }}</b-button>
</div>
</div>
</div>
</div>
</b-modal>
@ -79,7 +84,8 @@ export default {
name: "MealPlanEditModal",
props: {
entry: Object,
entryEditing_initial: Array,
entryEditing_initial_recipe: Array,
entryEditing_initial_meal_type: Array,
modal_title: String
},
mixins: [ApiMixin],
@ -93,30 +99,35 @@ export default {
}
},
watch: {
entry: function () {
this.entryEditing = Object.assign({}, this.entry)
entry: {
handler() {
this.entryEditing = Object.assign({}, this.entry)
},
deep: true
}
},
methods: {
editEntry() {
if(this.entryEditing.meal_type == null) {
if (this.entryEditing.meal_type == null) {
alert("Need Meal type")
return
}
if(this.entryEditing.recipe == null && this.entryEditing.title === '') {
if (this.entryEditing.recipe == null && this.entryEditing.title === '') {
alert("Need title or recipe")
return
}
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) {
if (event.val != null) {
this.entryEditing.meal_type = event.val.id;
this.entryEditing.meal_type_name = event.val.id;
this.entryEditing.meal_type = event.val;
} else {
this.entryEditing.meal_type = null;
this.entryEditing.meal_type_name = ""
}
},
selectRecipe(event) {