working on dedicated food view
This commit is contained in:
parent
f0f12ca83f
commit
b7f202d645
@ -1,51 +1,102 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<hr/>
|
<div class="row" v-if="food">
|
||||||
|
<div class="col-12">
|
||||||
|
<h2>{{ food.name }}</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12">
|
<div class="col-12">
|
||||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); column-gap: 0.5rem;row-gap: 1rem; grid-auto-rows: max-content; ">
|
<b-form v-if="food">
|
||||||
<b-list-group v-for="x in Array(5).keys()" v-bind:key="x">
|
<b-form-group :label="$t('Name')" description="">
|
||||||
<b-list-group-item >
|
<b-form-input v-model="food.name"></b-form-input>
|
||||||
<h4>Monday </h4>
|
</b-form-group>
|
||||||
</b-list-group-item>
|
<b-form-group :label="$t('Plural')" description="">
|
||||||
<b-list-group-item v-for="y in Array(Math.round(Math.random()*4) ).keys()" v-bind:key="y">
|
<b-form-input v-model="food.plural_name"></b-form-input>
|
||||||
<div class="d-flex flex-row align-items-center">
|
</b-form-group>
|
||||||
<div>
|
|
||||||
<b-img style="height: 50px; width: 50px; object-fit: cover" src="http://127.0.0.1:8000/media/recipes/6a2fd228-c589-4a14-b21f-365bca3fbd94_119.png" rounded="circle"></b-img>
|
|
||||||
</div>
|
|
||||||
<div class="flex-grow-1 ml-2">
|
|
||||||
<span class="two-row-text">{{ recipe.name }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</b-list-group-item>
|
|
||||||
<b-list-group-item class="justify-content-center text-center">
|
|
||||||
<b-button><i class="fa fa-plus"></i></b-button>
|
|
||||||
</b-list-group-item>
|
|
||||||
</b-list-group>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
<b-form-group :label="$t('Recipe')" :description="$t('food_recipe_help')">
|
||||||
</div>
|
<generic-multiselect
|
||||||
|
@change="food.recipe = $event.val;"
|
||||||
|
:model="Models.RECIPE"
|
||||||
|
:initial_selection="food.recipe"
|
||||||
|
label="name"
|
||||||
|
:multiple="false"
|
||||||
|
:placeholder="$t('Recipe')"
|
||||||
|
></generic-multiselect>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
|
<b-form-group :description="$t('OnHand_help')">
|
||||||
|
<b-form-checkbox v-model="food.food_onhand">{{ $t('OnHand') }}</b-form-checkbox>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
|
<b-form-group :description="$t('ignore_shopping_help')">
|
||||||
|
<b-form-checkbox v-model="food.ignore_shopping">{{ $t('Ignore_Shopping') }}</b-form-checkbox>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
|
<b-form-group :label="$t('Shopping_Category')" :description="$t('shopping_category_help')">
|
||||||
|
<generic-multiselect
|
||||||
|
@change="food.supermarket_category = $event.val;"
|
||||||
|
:model="Models.SHOPPING_CATEGORY"
|
||||||
|
:initial_selection="food.supermarket_category"
|
||||||
|
label="name"
|
||||||
|
:multiple="false"
|
||||||
|
:placeholder="$t('Shopping_Category')"
|
||||||
|
></generic-multiselect>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
<!-- todo add conditions if false disable dont hide -->
|
||||||
|
<b-form-group :label="$t('Substitutes')" :description="$t('substitute_help')">
|
||||||
|
<generic-multiselect
|
||||||
|
@change="food.substitute = $event.val;"
|
||||||
|
:model="Models.FOOD"
|
||||||
|
:initial_selection="food.substitute"
|
||||||
|
label="name"
|
||||||
|
:multiple="false"
|
||||||
|
:placeholder="$t('Substitutes')"
|
||||||
|
></generic-multiselect>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
<div class="row">
|
<b-form-group :description="$t('substitute_siblings_help')">
|
||||||
<div class="col col-md-12">
|
<b-form-checkbox v-model="food.substitute_siblings">{{ $t('substitute_siblings') }}</b-form-checkbox>
|
||||||
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 0.5rem;row-gap: 1rem; grid-auto-rows: max-content; ">
|
</b-form-group>
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
<b-form-group :label="$t('InheritFields')" :description="$t('InheritFields_help')">
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
<generic-multiselect
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
@change="food.inherit_fields = $event.val;"
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
:model="Models.FOOD_INHERIT_FIELDS"
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
:initial_selection="food.inherit_fields"
|
||||||
<recipe-card :recipe="recipe" :detailed="false"></recipe-card>
|
label="name"
|
||||||
|
:multiple="false"
|
||||||
|
:placeholder="$t('InheritFields')"
|
||||||
|
></generic-multiselect>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
|
<b-form-group :label="$t('ChildInheritFields')" :description="$t('ChildInheritFields_help')">
|
||||||
|
<generic-multiselect
|
||||||
|
@change="food.child_inherit_fields = $event.val;"
|
||||||
|
:model="Models.FOOD_INHERIT_FIELDS"
|
||||||
|
:initial_selection="food.child_inherit_fields"
|
||||||
|
label="name"
|
||||||
|
:multiple="false"
|
||||||
|
:placeholder="$t('ChildInheritFields')"
|
||||||
|
></generic-multiselect>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
|
<!-- TODO change to a button -->
|
||||||
|
<b-form-group :description="$t('reset_children_help')">
|
||||||
|
<b-form-checkbox v-model="food.reset_inherit">{{ $t('reset_children') }}</b-form-checkbox>
|
||||||
|
</b-form-group>
|
||||||
|
|
||||||
|
<b-button variant="primary" @click="updateFood">{{ $t('Save') }}</b-button>
|
||||||
|
</b-form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -58,6 +109,8 @@ import {BootstrapVue} from "bootstrap-vue"
|
|||||||
import "bootstrap-vue/dist/bootstrap-vue.css"
|
import "bootstrap-vue/dist/bootstrap-vue.css"
|
||||||
import {ApiApiFactory} from "@/utils/openapi/api";
|
import {ApiApiFactory} from "@/utils/openapi/api";
|
||||||
import RecipeCard from "@/components/RecipeCard.vue";
|
import RecipeCard from "@/components/RecipeCard.vue";
|
||||||
|
import GenericMultiselect from "@/components/GenericMultiselect.vue";
|
||||||
|
import {ApiMixin, StandardToasts} from "@/utils/utils";
|
||||||
|
|
||||||
|
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
@ -65,45 +118,38 @@ Vue.use(BootstrapVue)
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TestView",
|
name: "TestView",
|
||||||
mixins: [],
|
mixins: [ApiMixin],
|
||||||
components: {RecipeCard},
|
components: {
|
||||||
|
GenericMultiselect
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
recipe: undefined,
|
food: undefined,
|
||||||
recipe_detailed: false,
|
|
||||||
meal_plan: undefined
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||||
let apiClient = new ApiApiFactory()
|
let apiClient = new ApiApiFactory()
|
||||||
apiClient.retrieveRecipe('119').then((r) => {
|
apiClient.retrieveFood('1').then((r) => {
|
||||||
this.recipe = r.data
|
this.food = r.data
|
||||||
})
|
|
||||||
apiClient.retrieveMealPlan('1').then((r) => {
|
|
||||||
this.meal_plan = r.data
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateFood: function () {
|
||||||
|
let apiClient = new ApiApiFactory()
|
||||||
|
apiClient.updateFood(this.food.id, this.food).then((r) => {
|
||||||
|
this.food = r.data
|
||||||
|
StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE)
|
||||||
|
}).catch(err => {
|
||||||
|
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.dot {
|
|
||||||
height: 40px;
|
|
||||||
width: 40px;
|
|
||||||
background-color: #bbb;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.two-row-text {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-line-clamp: 2; /* number of lines to show */
|
|
||||||
line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user