diff --git a/vue/src/apps/TestView/TestView.vue b/vue/src/apps/TestView/TestView.vue index 789a167714..9c7235ada5 100644 --- a/vue/src/apps/TestView/TestView.vue +++ b/vue/src/apps/TestView/TestView.vue @@ -8,30 +8,61 @@ {{ $t('Name') }} - {{ pt.name }} - - + FDC + {{ $t('Properties_Food_Amount') }} + {{ $t('Properties_Food_Unit') }} + + + + + {{ pt.unit }} + + + + - {{ f.food.name }} #{{ f.food.id }} - {{ $t('Property') }} / + {{ f.food.name }} + + + + + + + + + + + + + + - - - {{ p.property_type.unit }} ({{ p.property_type.name }}) + + + + + + + @@ -47,6 +78,7 @@ import axios from "axios"; import BetaWarning from "@/components/BetaWarning.vue"; import {ApiApiFactory} from "@/utils/openapi/api"; import GenericMultiselect from "@/components/GenericMultiselect.vue"; +import GenericModalForm from "@/components/Modals/GenericModalForm.vue"; Vue.use(BootstrapVue) @@ -55,10 +87,10 @@ Vue.use(BootstrapVue) export default { name: "TestView", mixins: [ApiMixin], - components: {GenericMultiselect}, + components: {GenericModalForm, GenericMultiselect}, computed: { foods: function () { - let foods = [] + let foods = {} if (this.recipe !== null && this.property_types !== []) { this.recipe.steps.forEach(s => { s.ingredients.forEach(i => { @@ -70,49 +102,53 @@ export default { i.food.properties.forEach(fp => { food.properties[fp.property_type.id] = {changed: false, property_amount: fp.property_amount, property_type: fp.property_type} }) - foods.push(food) + foods[food.food.id] = food }) }) } return foods + }, + properties: function () { + let properties = {} + this.property_types.forEach(pt => { + properties[pt.id] = pt + }) + return properties } }, data() { return { recipe: null, - property_types: [] + property_types: [], + editing_property_type: null, } }, mounted() { this.$i18n.locale = window.CUSTOM_LOCALE - this.loadData(); + this.loadRecipe(); + this.loadPropertyTypes(); }, methods: { - loadData: function () { + loadRecipe: function () { let apiClient = new ApiApiFactory() apiClient.retrieveRecipe("112").then(result => { this.recipe = result.data }) - - apiClient.listPropertyTypes().then(result => { - this.property_types = result.data - }) }, updateFood: function (food) { let apiClient = new ApiApiFactory() apiClient.partialUpdateFood(food.id, food).then(result => { - //TODO handle properly StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE) }).catch((err) => { StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err) }) }, - updatePropertyType: function (pt) { + loadPropertyTypes: function () { let apiClient = new ApiApiFactory() - apiClient.partialUpdatePropertyType(pt.id, pt).then(result => { - //TODO handle properly + apiClient.listPropertyTypes().then(result => { + this.property_types = result.data StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE) }).catch((err) => { StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err) @@ -122,7 +158,7 @@ export default { let apiClient = new ApiApiFactory() apiClient.fdcFood(food.id).then(result => { - this.loadData() + this.loadRecipe() StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE) }).catch((err) => { StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err) diff --git a/vue/src/components/FoodEditor.vue b/vue/src/components/FoodEditor.vue index 232ae4bc52..9b707c400e 100644 --- a/vue/src/components/FoodEditor.vue +++ b/vue/src/components/FoodEditor.vue @@ -33,11 +33,11 @@
{{ $t('Properties') }}
- + - +