diff --git a/cookbook/views/api.py b/cookbook/views/api.py index 70a0d7cdc..12ed69735 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -747,6 +747,10 @@ class FoodViewSet(LoggingMixin, TreeMixin): if properties with a fdc_id already exist they will be overridden, if existing properties don't have a fdc_id they won't be changed """ food = self.get_object() + + if request.data['fdc_id']: + food.fdc_id = request.data['fdc_id'] + if not food.fdc_id: return JsonResponse({'msg': 'Food has no FDC ID associated.'}, status=400, json_dumps_params={'indent': 4}) @@ -767,12 +771,17 @@ class FoodViewSet(LoggingMixin, TreeMixin): json_dumps_params={'indent': 4}) food.properties_food_amount = 100 - food.properties_food_unit = Unit.objects.get_or_create( - base_unit__iexact='g', - space=self.request.space, - defaults={'name': 'g', 'base_unit': 'g', 'space': self.request.space} - )[0] + standard_unit = Unit.objects.filter(base_unit__iexact='g', space=self.request.space).first() + if not standard_unit: + standard_unit = Unit.objects.filter(name__iexact='g', space=self.request.space).first() + if not standard_unit: + standard_unit = Unit.objects.create(name='g', base_unit='g', space=self.request.space) + else: + standard_unit.base_unit = 'g' + standard_unit.save() + + food.properties_food_unit = standard_unit food.save() try: diff --git a/vue3/src/apps/tandoor/main.ts b/vue3/src/apps/tandoor/main.ts index e6c671674..e8c0518a4 100644 --- a/vue3/src/apps/tandoor/main.ts +++ b/vue3/src/apps/tandoor/main.ts @@ -43,6 +43,7 @@ const routes = [ {path: '/edit/:model/:id?', component: () => import("@/pages/ModelListPage.vue"), props: true, name: 'ModelEditPage'}, {path: '/ingredient-editor', component: () => import("@/pages/IngredientEditorPage.vue"), name: 'IngredientEditorPage'}, + {path: '/property-editor', component: () => import("@/pages/PropertyEditorPage.vue"), name: 'PropertyEditorPage'}, ] const router = createRouter({ diff --git a/vue3/src/components/display/PropertyView.vue b/vue3/src/components/display/PropertyView.vue new file mode 100644 index 000000000..b3a6f27f6 --- /dev/null +++ b/vue3/src/components/display/PropertyView.vue @@ -0,0 +1,34 @@ + + + + + \ No newline at end of file diff --git a/vue3/src/components/display/RecipeView.vue b/vue3/src/components/display/RecipeView.vue index 8ee69fa0a..cf772d804 100644 --- a/vue3/src/components/display/RecipeView.vue +++ b/vue3/src/components/display/RecipeView.vue @@ -72,10 +72,16 @@ - + + {{ $t('Properties') }} + + + + + - {{ $t('Information') }} + {{ $t('Information') }} @@ -116,8 +122,11 @@ + + + @@ -137,6 +146,7 @@ import {useWakeLock} from "@vueuse/core"; import StepView from "@/components/display/StepView.vue"; import IngredientsTable from "@/components/display/IngredientsTable.vue"; import {DateTime} from "luxon"; +import PropertyView from "@/components/display/PropertyView.vue"; const {request, release} = useWakeLock() diff --git a/vue3/src/components/inputs/ModelSelect.vue b/vue3/src/components/inputs/ModelSelect.vue index a13f6d170..0115da0c9 100644 --- a/vue3/src/components/inputs/ModelSelect.vue +++ b/vue3/src/components/inputs/ModelSelect.vue @@ -1,6 +1,6 @@