From 54a5c145ccbad5e3a49f6dfac03cce6aafba4d45 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Fri, 5 May 2023 17:04:20 +0200 Subject: [PATCH] comonent in generic form trial --- vue/src/components/FoodEditor.vue | 149 +++++++++--------- .../components/Modals/GenericModalForm.vue | 74 +++++---- vue/src/utils/models.js | 1 + 3 files changed, 125 insertions(+), 99 deletions(-) diff --git a/vue/src/components/FoodEditor.vue b/vue/src/components/FoodEditor.vue index e0017d564..f506c58b8 100644 --- a/vue/src/components/FoodEditor.vue +++ b/vue/src/components/FoodEditor.vue @@ -20,7 +20,9 @@ -
{{ $t('Properties') }} {{ food.name }}
+
{{ $t('Properties') }} {{ + food.name + }}
@@ -42,86 +44,91 @@ - + {{$t('Advanced')}} + + + + - - - + + {{ $t('OnHand') }} + - - {{ $t('OnHand') }} - + + {{ + $t('Ignore_Shopping') + }} + + - - {{ $t('Ignore_Shopping') }} - + + + - - - +
+ + + + -
- - - - + + {{ + $t('substitute_siblings') + }} + + - - {{ - $t('substitute_siblings') - }} - - + + + - - - + + + - - - + + + {{ $t('reset_children') }} + +
- - - {{ $t('reset_children') }} - {{ $t('Save') }} diff --git a/vue/src/components/Modals/GenericModalForm.vue b/vue/src/components/Modals/GenericModalForm.vue index 1fe68b507..4bf4b42ed 100644 --- a/vue/src/components/Modals/GenericModalForm.vue +++ b/vue/src/components/Modals/GenericModalForm.vue @@ -1,34 +1,43 @@ @@ -111,6 +120,15 @@ export default { return undefined } }, + form_component() { + // TODO this leads webpack to create one .js file for each component in this folder because at runtime any one of them could be requested + // TODO this is not necessarily bad but maybe there are better options to do this + if (this.form.component !== undefined){ + return () => import(/* webpackChunkName: "header-component" */ `@/components/${this.form.component}`) + }else{ + return undefined + } + }, }, watch: { show: function () { diff --git a/vue/src/utils/models.js b/vue/src/utils/models.js index 213a37874..fa494ad4e 100644 --- a/vue/src/utils/models.js +++ b/vue/src/utils/models.js @@ -97,6 +97,7 @@ export class Models { form: { show_help: true, + component: "FoodEditor", name: { form_field: true, type: "text",
{{ fp.property_type.unit }}