From 4f425fb99af499d8b540b3e76b5a2ad58481e7cd Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 8 Oct 2024 19:23:20 +0200 Subject: [PATCH] MealPlan editor in new editor system --- .../components/dialogs/ModelEditDialog.vue | 9 +- vue3/src/components/display/MealPlanView.vue | 7 + .../model_editors/MealPlanEditor.vue | 131 ++++++++++++++++++ .../model_editors/MealTypeEditor.vue | 2 + .../composables/useModelEditorFunctions.ts | 6 +- vue3/src/locales/ar.json | 1 + vue3/src/locales/bg.json | 1 + vue3/src/locales/ca.json | 1 + vue3/src/locales/cs.json | 1 + vue3/src/locales/da.json | 1 + vue3/src/locales/de.json | 1 + vue3/src/locales/el.json | 1 + vue3/src/locales/en.json | 1 + vue3/src/locales/es.json | 1 + vue3/src/locales/fi.json | 1 + vue3/src/locales/fr.json | 1 + vue3/src/locales/he.json | 1 + vue3/src/locales/hu.json | 1 + vue3/src/locales/hy.json | 1 + vue3/src/locales/id.json | 1 + vue3/src/locales/is.json | 1 + vue3/src/locales/it.json | 1 + vue3/src/locales/lt.json | 1 + vue3/src/locales/nb_NO.json | 1 + vue3/src/locales/nl.json | 1 + vue3/src/locales/pl.json | 1 + vue3/src/locales/pt.json | 1 + vue3/src/locales/pt_BR.json | 1 + vue3/src/locales/ro.json | 1 + vue3/src/locales/ru.json | 1 + vue3/src/locales/sl.json | 1 + vue3/src/locales/sv.json | 1 + vue3/src/locales/tr.json | 1 + vue3/src/locales/uk.json | 1 + vue3/src/locales/zh_Hans.json | 1 + vue3/src/locales/zh_Hant.json | 1 + vue3/src/pages/ModelEditPage.vue | 7 +- vue3/src/types/Models.ts | 20 ++- 38 files changed, 203 insertions(+), 10 deletions(-) create mode 100644 vue3/src/components/model_editors/MealPlanEditor.vue diff --git a/vue3/src/components/dialogs/ModelEditDialog.vue b/vue3/src/components/dialogs/ModelEditDialog.vue index 26b133671..4ef3ced6d 100644 --- a/vue3/src/components/dialogs/ModelEditDialog.vue +++ b/vue3/src/components/dialogs/ModelEditDialog.vue @@ -1,5 +1,5 @@ @@ -8,7 +8,10 @@ import {defineAsyncComponent, PropType, ref, shallowRef} from "vue"; -import {EditorSupportedModels} from "@/types/Models"; +import {EditorSupportedModels, getGenericModelFromString} from "@/types/Models"; +import {useI18n} from "vue-i18n"; + +const {t} = useI18n() const emit = defineEmits(['create', 'save', 'delete']) @@ -21,7 +24,7 @@ const props = defineProps({ closeAfterDelete: {default: true}, }) -const editorComponent = shallowRef(defineAsyncComponent(() => import(`@/components/model_editors/${props.model}Editor.vue`))) +const editorComponent = shallowRef(defineAsyncComponent(() => import(`@/components/model_editors/${getGenericModelFromString(props.model, t).model.name}Editor.vue`))) const dialog = ref(false) diff --git a/vue3/src/components/display/MealPlanView.vue b/vue3/src/components/display/MealPlanView.vue index c0674e959..dfd4aa133 100644 --- a/vue3/src/components/display/MealPlanView.vue +++ b/vue3/src/components/display/MealPlanView.vue @@ -2,6 +2,11 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vue3/src/components/model_editors/MealTypeEditor.vue b/vue3/src/components/model_editors/MealTypeEditor.vue index adc7ab72b..9ed23450e 100644 --- a/vue3/src/components/model_editors/MealTypeEditor.vue +++ b/vue3/src/components/model_editors/MealTypeEditor.vue @@ -29,6 +29,8 @@ + + diff --git a/vue3/src/composables/useModelEditorFunctions.ts b/vue3/src/composables/useModelEditorFunctions.ts index cafab4563..62bb5e212 100644 --- a/vue3/src/composables/useModelEditorFunctions.ts +++ b/vue3/src/composables/useModelEditorFunctions.ts @@ -1,13 +1,13 @@ import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore"; -import {onBeforeMount, PropType, ref} from "vue"; -import {GenericModel, getGenericModelFromString} from "@/types/Models"; +import {onBeforeMount, ref} from "vue"; +import {EditorSupportedModels, GenericModel, getGenericModelFromString} from "@/types/Models"; import {useI18n} from "vue-i18n"; import {ResponseError} from "@/openapi"; // TODO type emit parameter (https://mokkapps.de/vue-tips/emit-event-from-composable) // TODO alternatively there seems to be a getContext method to get the calling context (good practice?) -export function useModelEditorFunctions(modelName: string, emit: any) { +export function useModelEditorFunctions(modelName: EditorSupportedModels, emit: any) { const loading = ref(true) const editingObj = ref({} as T) diff --git a/vue3/src/locales/ar.json b/vue3/src/locales/ar.json index 7d35a53ef..94bf8ab6a 100644 --- a/vue3/src/locales/ar.json +++ b/vue3/src/locales/ar.json @@ -61,6 +61,7 @@ "Custom Filter": "", "Database": "", "Date": "", + "Default": "", "DelayFor": "", "DelayUntil": "", "Delete": "", diff --git a/vue3/src/locales/bg.json b/vue3/src/locales/bg.json index 9f49fe477..fcaf28ff2 100644 --- a/vue3/src/locales/bg.json +++ b/vue3/src/locales/bg.json @@ -58,6 +58,7 @@ "Custom Filter": "Персонализиран филтър", "Database": "", "Date": "Дата", + "Default": "", "DelayFor": "Закъснение за {hours} часа", "DelayUntil": "Забавяне до", "Delete": "Изтрий", diff --git a/vue3/src/locales/ca.json b/vue3/src/locales/ca.json index c111aa375..26c2e877f 100644 --- a/vue3/src/locales/ca.json +++ b/vue3/src/locales/ca.json @@ -88,6 +88,7 @@ "Day": "", "Days": "", "Decimals": "", + "Default": "", "Default_Unit": "", "DelayFor": "", "DelayUntil": "", diff --git a/vue3/src/locales/cs.json b/vue3/src/locales/cs.json index d9aca0591..c64c32bc8 100644 --- a/vue3/src/locales/cs.json +++ b/vue3/src/locales/cs.json @@ -87,6 +87,7 @@ "Day": "Den", "Days": "Dny", "Decimals": "Desetinná místa", + "Default": "", "DefaultPage": "Výchozí stránka", "Default_Unit": "Výchozí jednotka", "DelayFor": "Odložit na {hours} hodin", diff --git a/vue3/src/locales/da.json b/vue3/src/locales/da.json index 17053f566..a7da8b107 100644 --- a/vue3/src/locales/da.json +++ b/vue3/src/locales/da.json @@ -80,6 +80,7 @@ "Day": "Dag", "Days": "Dage", "Decimals": "Decimaler", + "Default": "", "Default_Unit": "Standardenhed", "DelayFor": "Udskyd i {hours} hours", "DelayUntil": "Udskyd indtil", diff --git a/vue3/src/locales/de.json b/vue3/src/locales/de.json index adc2840d2..55b9eee0f 100644 --- a/vue3/src/locales/de.json +++ b/vue3/src/locales/de.json @@ -89,6 +89,7 @@ "Day": "Tag", "Days": "Tage", "Decimals": "Nachkommastellen", + "Default": "Standard", "DefaultPage": "Standardseite", "Default_Unit": "Standardeinheit", "DelayFor": "Um {hours} Stunden verschieben", diff --git a/vue3/src/locales/el.json b/vue3/src/locales/el.json index dc8cb193b..d7260013f 100644 --- a/vue3/src/locales/el.json +++ b/vue3/src/locales/el.json @@ -79,6 +79,7 @@ "Day": "Ημέρα", "Days": "Ημέρες", "Decimals": "Δεκαδικά", + "Default": "", "Default_Unit": "Προεπιλεγμένη μονάδα μέτρησης", "DelayFor": "Καθυστέρηση για {hours} ώρες", "DelayUntil": "Καθυστέρηση μέχρι", diff --git a/vue3/src/locales/en.json b/vue3/src/locales/en.json index 22d4678c2..f2dcd5006 100644 --- a/vue3/src/locales/en.json +++ b/vue3/src/locales/en.json @@ -88,6 +88,7 @@ "Day": "Day", "Days": "Days", "Decimals": "Decimals", + "Default": "Default", "DefaultPage": "Default Page", "Default_Unit": "Default Unit", "DelayFor": "Delay for {hours} hours", diff --git a/vue3/src/locales/es.json b/vue3/src/locales/es.json index 3c01d5942..17d32605e 100644 --- a/vue3/src/locales/es.json +++ b/vue3/src/locales/es.json @@ -88,6 +88,7 @@ "Day": "Día", "Days": "Días", "Decimals": "Decimales", + "Default": "", "DefaultPage": "Página por Defecto", "Default_Unit": "Unidad Predeterminada", "DelayFor": "Retrasar por {hours} horas", diff --git a/vue3/src/locales/fi.json b/vue3/src/locales/fi.json index 8550f0c42..83be1f797 100644 --- a/vue3/src/locales/fi.json +++ b/vue3/src/locales/fi.json @@ -41,6 +41,7 @@ "Current_Period": "Nykyinen Jakso", "Database": "", "Date": "Päivämäärä", + "Default": "", "Delete": "Poista", "DeleteConfirmQuestion": "", "Delete_Food": "Poista ruoka", diff --git a/vue3/src/locales/fr.json b/vue3/src/locales/fr.json index b5b0c5cf7..03299593f 100644 --- a/vue3/src/locales/fr.json +++ b/vue3/src/locales/fr.json @@ -87,6 +87,7 @@ "Day": "Jour", "Days": "Jours", "Decimals": "Décimales", + "Default": "", "DefaultPage": "Page par défaut", "Default_Unit": "Unité par défaut", "DelayFor": "Retard de {hours} heures", diff --git a/vue3/src/locales/he.json b/vue3/src/locales/he.json index f3dd66346..bce845b03 100644 --- a/vue3/src/locales/he.json +++ b/vue3/src/locales/he.json @@ -88,6 +88,7 @@ "Day": "יום", "Days": "ימים", "Decimals": "דצימל", + "Default": "", "DefaultPage": "עמוד ברירת מחדל", "Default_Unit": "ערך ברירת מחדל", "DelayFor": "השהה ל {hours} שעות", diff --git a/vue3/src/locales/hu.json b/vue3/src/locales/hu.json index fa971f364..8015dedb9 100644 --- a/vue3/src/locales/hu.json +++ b/vue3/src/locales/hu.json @@ -79,6 +79,7 @@ "Day": "Nap", "Days": "Nap", "Decimals": "Tizedesek", + "Default": "", "DelayFor": "Késleltetés {hours} óráig", "DelayUntil": "", "Delete": "Törlés", diff --git a/vue3/src/locales/hy.json b/vue3/src/locales/hy.json index c020a9b9b..6c558191b 100644 --- a/vue3/src/locales/hy.json +++ b/vue3/src/locales/hy.json @@ -28,6 +28,7 @@ "Create_New_Shopping Category": "Ստեղծել գնումների նոր կատեգորիա", "Database": "", "Date": "", + "Default": "", "Delete": "", "DeleteConfirmQuestion": "", "Delete_Food": "Ջնջել սննդամթերքը", diff --git a/vue3/src/locales/id.json b/vue3/src/locales/id.json index 645adab81..5c1eb0946 100644 --- a/vue3/src/locales/id.json +++ b/vue3/src/locales/id.json @@ -69,6 +69,7 @@ "Day": "", "Days": "", "Decimals": "", + "Default": "", "Default_Unit": "", "DelayFor": "", "DelayUntil": "", diff --git a/vue3/src/locales/is.json b/vue3/src/locales/is.json index 15230ae80..68bcc15cc 100644 --- a/vue3/src/locales/is.json +++ b/vue3/src/locales/is.json @@ -88,6 +88,7 @@ "Day": "", "Days": "", "Decimals": "", + "Default": "", "Default_Unit": "", "DelayFor": "", "DelayUntil": "", diff --git a/vue3/src/locales/it.json b/vue3/src/locales/it.json index 63b26466a..e68db7ae6 100644 --- a/vue3/src/locales/it.json +++ b/vue3/src/locales/it.json @@ -73,6 +73,7 @@ "Day": "Giorno", "Days": "Giorni", "Decimals": "Decimali", + "Default": "", "Default_Unit": "Unità predefinita", "DelayFor": "Ritarda per {hours} ore", "DelayUntil": "Ritarda fino a", diff --git a/vue3/src/locales/lt.json b/vue3/src/locales/lt.json index 5bd8d5032..7fac2f8df 100644 --- a/vue3/src/locales/lt.json +++ b/vue3/src/locales/lt.json @@ -80,6 +80,7 @@ "Day": "", "Days": "", "Decimals": "", + "Default": "", "Default_Unit": "", "DelayFor": "", "DelayUntil": "", diff --git a/vue3/src/locales/nb_NO.json b/vue3/src/locales/nb_NO.json index 425c849a8..cfc5c018e 100644 --- a/vue3/src/locales/nb_NO.json +++ b/vue3/src/locales/nb_NO.json @@ -77,6 +77,7 @@ "Day": "Dag", "Days": "Dager", "Decimals": "Desimaler", + "Default": "", "Default_Unit": "Standard Enhet", "DelayFor": "Utsett i {hours} timer", "DelayUntil": "Forsink til", diff --git a/vue3/src/locales/nl.json b/vue3/src/locales/nl.json index 99d275bd7..36a9dd75a 100644 --- a/vue3/src/locales/nl.json +++ b/vue3/src/locales/nl.json @@ -81,6 +81,7 @@ "Day": "Dag", "Days": "Dagen", "Decimals": "Decimalen", + "Default": "", "Default_Unit": "Standaardeenheid", "DelayFor": "Stel {hours} uur uit", "DelayUntil": "Vertraag tot", diff --git a/vue3/src/locales/pl.json b/vue3/src/locales/pl.json index 8c2cfc6e6..c79ef19d5 100644 --- a/vue3/src/locales/pl.json +++ b/vue3/src/locales/pl.json @@ -89,6 +89,7 @@ "Day": "Dzień", "Days": "Dni", "Decimals": "Ułamki dziesiętne", + "Default": "", "DefaultPage": "Strona domyślna", "Default_Unit": "Jednostka domyślna", "DelayFor": "Opóźnij o {hours} godzin", diff --git a/vue3/src/locales/pt.json b/vue3/src/locales/pt.json index d7db1a8df..6c4123cb5 100644 --- a/vue3/src/locales/pt.json +++ b/vue3/src/locales/pt.json @@ -61,6 +61,7 @@ "Database": "", "Date": "Data", "Decimals": "Casas decimais", + "Default": "", "Default_Unit": "Unidade padrão", "DelayFor": "Atrasar por {hours} horas", "DelayUntil": "", diff --git a/vue3/src/locales/pt_BR.json b/vue3/src/locales/pt_BR.json index e7af53146..296161637 100644 --- a/vue3/src/locales/pt_BR.json +++ b/vue3/src/locales/pt_BR.json @@ -86,6 +86,7 @@ "Day": "Dia", "Days": "Dias", "Decimals": "Decimais", + "Default": "", "Default_Unit": "Unidade Padrão", "DelayFor": "Demorar por {hours} horas", "DelayUntil": "Atrasar Até", diff --git a/vue3/src/locales/ro.json b/vue3/src/locales/ro.json index 7e8f6b64b..d75d458ce 100644 --- a/vue3/src/locales/ro.json +++ b/vue3/src/locales/ro.json @@ -75,6 +75,7 @@ "Day": "Zi", "Days": "Zile", "Decimals": "Zecimale", + "Default": "", "Default_Unit": "Unitate standard", "DelayFor": "Întârziere pentru {hours} ore", "DelayUntil": "Amână până la", diff --git a/vue3/src/locales/ru.json b/vue3/src/locales/ru.json index 2f4bf07e3..4bd8cc57e 100644 --- a/vue3/src/locales/ru.json +++ b/vue3/src/locales/ru.json @@ -52,6 +52,7 @@ "Custom Filter": "Пользовательский фильтр", "Database": "", "Date": "Дата", + "Default": "", "DelayFor": "Отложить на {hours} часов", "Delete": "Удалить", "DeleteConfirmQuestion": "", diff --git a/vue3/src/locales/sl.json b/vue3/src/locales/sl.json index 20128a298..75797e87d 100644 --- a/vue3/src/locales/sl.json +++ b/vue3/src/locales/sl.json @@ -52,6 +52,7 @@ "Data_Import_Info": "Izboljšajte svoj prostor z uvozom seznama živil, enot in drugega, ker je pripravila skupnost, ter s tem izboljšajte svojo zbirko receptov.", "Database": "", "Date": "Datum", + "Default": "", "DelayFor": "Zamakni za {hours} ur", "DelayUntil": "Zamakni do", "Delete": "Izbriši", diff --git a/vue3/src/locales/sv.json b/vue3/src/locales/sv.json index 88c7a49e0..55892c624 100644 --- a/vue3/src/locales/sv.json +++ b/vue3/src/locales/sv.json @@ -89,6 +89,7 @@ "Day": "Dag", "Days": "Dagar", "Decimals": "Decimaler", + "Default": "", "DefaultPage": "Standardsida", "Default_Unit": "Standardenhet", "DelayFor": "Fördröjning på {hours} timmar", diff --git a/vue3/src/locales/tr.json b/vue3/src/locales/tr.json index 9a29519be..b58c0510c 100644 --- a/vue3/src/locales/tr.json +++ b/vue3/src/locales/tr.json @@ -88,6 +88,7 @@ "Day": "Gün", "Days": "Günler", "Decimals": "Ondalık Sayılar", + "Default": "", "DefaultPage": "Varsayılan Sayfa", "Default_Unit": "Varsayılan Birim", "DelayFor": "{hours} saat geciktir", diff --git a/vue3/src/locales/uk.json b/vue3/src/locales/uk.json index 8949e1840..156d30029 100644 --- a/vue3/src/locales/uk.json +++ b/vue3/src/locales/uk.json @@ -65,6 +65,7 @@ "Database": "", "Date": "Дата", "Decimals": "Десятки", + "Default": "", "Default_Unit": "Одиниця замовчуванням", "DelayFor": "Затримка на {hours} годин", "DelayUntil": "", diff --git a/vue3/src/locales/zh_Hans.json b/vue3/src/locales/zh_Hans.json index be31f0350..2ad697946 100644 --- a/vue3/src/locales/zh_Hans.json +++ b/vue3/src/locales/zh_Hans.json @@ -86,6 +86,7 @@ "Day": "天", "Days": "天", "Decimals": "小数", + "Default": "", "Default_Unit": "默认单位", "DelayFor": "延迟 {hours} 小时", "DelayUntil": "推迟到", diff --git a/vue3/src/locales/zh_Hant.json b/vue3/src/locales/zh_Hant.json index 639314f88..2a9f3b034 100644 --- a/vue3/src/locales/zh_Hant.json +++ b/vue3/src/locales/zh_Hant.json @@ -23,6 +23,7 @@ "Create": "", "Database": "", "Date": "", + "Default": "", "Delete": "", "DeleteConfirmQuestion": "", "Deleted": "", diff --git a/vue3/src/pages/ModelEditPage.vue b/vue3/src/pages/ModelEditPage.vue index f6cbd8529..5a4a7b418 100644 --- a/vue3/src/pages/ModelEditPage.vue +++ b/vue3/src/pages/ModelEditPage.vue @@ -20,15 +20,18 @@