diff --git a/vue/src/apps/TestView/TestView.vue b/vue/src/apps/TestView/TestView.vue
index 31ec9087..9ee2c928 100644
--- a/vue/src/apps/TestView/TestView.vue
+++ b/vue/src/apps/TestView/TestView.vue
@@ -2,61 +2,6 @@
-
{{ recipe.name }}
-
-
-
-
- {{ $t('Name') }} |
- FDC |
- {{ $t('Properties_Food_Amount') }} |
- {{ $t('Properties_Food_Unit') }} |
-
- {{ pt.name }} ({{ pt.unit }})
- |
-
-
-
-
-
- {{ f.name }}
- |
-
-
-
-
-
-
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
- |
-
-
-
-
-
-
@@ -82,107 +27,16 @@ Vue.use(BootstrapVue)
export default {
name: "TestView",
mixins: [ApiMixin],
- components: {GenericModalForm, GenericMultiselect},
- computed: {
-
- },
+ components: {},
+ computed: {},
data() {
- return {
- recipe: null,
- property_types: [],
- editing_property_type: null,
- loading: false,
- foods: [],
- }
+ return {}
},
mounted() {
this.$i18n.locale = window.CUSTOM_LOCALE
-
- this.loadData();
},
methods: {
- loadData: function () {
- let apiClient = new ApiApiFactory()
- apiClient.listPropertyTypes().then(result => {
- this.property_types = result.data
-
- apiClient.retrieveRecipe("112").then(result => { //TODO get recipe id
- this.recipe = result.data
-
- this.foods = []
-
- this.recipe.steps.forEach(s => {
- s.ingredients.forEach(i => {
- if (this.foods.filter(x => (x.id === i.food.id)).length === 0) {
- this.foods.push(this.buildFood(i.food))
- }
- })
- })
- this.loading = false;
- }).catch((err) => {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
- })
- }).catch((err) => {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
- })
- },
- buildFood: function (food) {
- /**
- * Prepare food for display in grid by making sure the food properties are in the same order as property_types and that no types are missing
- * */
-
- let existing_properties = {}
- food.properties.forEach(fp => {
- existing_properties[fp.property_type.id] = fp
- })
-
- let food_properties = []
- this.property_types.forEach(pt => {
- let new_food_property = {
- property_type: pt,
- property_amount: 0,
- }
- if (pt.id in existing_properties) {
- new_food_property = existing_properties[pt.id]
- }
- food_properties.push(new_food_property)
- })
-
- this.$set(food, 'loading', false)
-
- food.properties = food_properties
-
- return food
- },
- spliceInFood: function (food){
- /**
- * replace food in foods list, for example after updates from the server
- */
- this.foods = this.foods.map(f => (f.id === food.id) ? food : f)
-
- },
- updateFood: function (food) {
- let apiClient = new ApiApiFactory()
- apiClient.partialUpdateFood(food.id, food).then(result => {
- this.spliceInFood(this.buildFood(result.data))
- StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE)
- }).catch((err) => {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err)
- })
- },
- updateFoodFromFDC: function (food) {
- food.loading = true;
- let apiClient = new ApiApiFactory()
-
- apiClient.fdcFood(food.id).then(result => {
- StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE)
- this.spliceInFood(this.buildFood(result.data))
- }).catch((err) => {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err)
- food.loading = false;
- })
- }
},
}