diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue
index b13fbce3..8efc5a4e 100644
--- a/vue/src/apps/RecipeView/RecipeView.vue
+++ b/vue/src/apps/RecipeView/RecipeView.vue
@@ -137,7 +137,7 @@
@@ -184,7 +184,7 @@ import CustomInputSpinButton from "@/components/CustomInputSpinButton"
import {ApiApiFactory} from "@/utils/openapi/api";
import ImportTandoor from "@/components/Modals/ImportTandoor.vue";
import BottomNavigationBar from "@/components/BottomNavigationBar.vue";
-import FoodPropertyViewComponent from "@/components/FoodPropertyViewComponent.vue";
+import PropertyViewComponent from "@/components/PropertyViewComponent.vue";
Vue.prototype.moment = moment
@@ -209,7 +209,7 @@ export default {
RecipeSwitcher,
CustomInputSpinButton,
BottomNavigationBar,
- FoodPropertyViewComponent,
+ PropertyViewComponent,
},
computed: {
ingredient_factor: function () {
diff --git a/vue/src/components/FoodPropertyViewComponent.vue b/vue/src/components/PropertyViewComponent.vue
similarity index 58%
rename from vue/src/components/FoodPropertyViewComponent.vue
rename to vue/src/components/PropertyViewComponent.vue
index e51cd6a1..14d37e4d 100644
--- a/vue/src/components/FoodPropertyViewComponent.vue
+++ b/vue/src/components/PropertyViewComponent.vue
@@ -15,21 +15,32 @@
+
+
+
{{ $t('Food') }}
+
{{ $t('Recipe') }}
+
+
+
+
+
+
+
-
+
{{ p.icon }} {{ p.name }}
|
- {{ get_amount(p.total_value) }} |
+ {{ get_amount(p.property_amount) }} |
{{ p.unit }} |
-
+ |
@@ -74,7 +85,7 @@ import GenericModalForm from "@/components/Modals/GenericModalForm.vue";
import {ApiApiFactory} from "@/utils/openapi/api";
export default {
- name: "FoodPropertyViewComponent",
+ name: "PropertyViewComponent",
mixins: [ApiMixin],
components: {GenericModalForm},
props: {
@@ -87,15 +98,65 @@ export default {
selected_food: undefined,
show_food_edit_modal: false,
show_total: false,
+ show_recipe_properties: false,
}
},
computed: {
show_modal: function () {
return this.selected_property !== undefined
},
+ hasRecipeProperties: function () {
+ return this.recipe.properties.length !== 0
+ },
+ hasFoodProperties: function () {
+ let has_food_properties = false
+ for (const [key, fp] of Object.entries(this.recipe.food_properties)) {
+ if (fp.total_value !== 0) {
+ has_food_properties = true
+ }
+ }
+ return has_food_properties
+ },
+ property_list: function () {
+ let pt_list = []
+ if (this.show_recipe_properties) {
+ this.recipe.properties.forEach(rp => {
+ pt_list.push(
+ {
+ 'id': rp.property_type.id,
+ 'name': rp.property_type.name,
+ 'description': rp.property_type.description,
+ 'icon': rp.property_type.icon,
+ 'food_values': [],
+ 'property_amount': rp.property_amount,
+ 'missing_value': false,
+ 'unit': rp.property_type.unit,
+ }
+ )
+ })
+ } else {
+ for (const [key, fp] of Object.entries(this.recipe.food_properties)) {
+ pt_list.push(
+ {
+ 'id': fp.id,
+ 'name': fp.name,
+ 'description': fp.description,
+ 'icon': fp.icon,
+ 'food_values': fp.food_values,
+ 'property_amount': fp.total_value,
+ 'missing_value': fp.missing_value,
+ 'unit': fp.unit,
+ }
+ )
+ }
+ }
+ return pt_list
+ }
},
mounted() {
-
+ if (this.hasRecipeProperties && !this.hasFoodProperties) {
+ this.show_recipe_properties = true
+ }
},
methods: {
get_amount: function (amount) {
@@ -121,7 +182,7 @@ export default {
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
})
},
- foodEditorHidden: function (){
+ foodEditorHidden: function () {
this.show_food_edit_modal = false;
this.$emit("foodUpdated", "")
}
|