diff --git a/vue3/src/components/dialogs/ModelMergeDialog.vue b/vue3/src/components/dialogs/ModelMergeDialog.vue index 572b217758..3cdbd01e39 100644 --- a/vue3/src/components/dialogs/ModelMergeDialog.vue +++ b/vue3/src/components/dialogs/ModelMergeDialog.vue @@ -26,11 +26,12 @@ + {{ $t('Cancel') }} - {{ $t('Merge') }} + {{ $t('Merge') }} @@ -41,10 +42,10 @@ import ModelSelect from "@/components/inputs/ModelSelect.vue"; import {PropType, ref} from "vue"; import {EditorSupportedModels, EditorSupportedTypes, getGenericModelFromString} from "@/types/Models"; -import {ApiApi, Food} from "@/openapi"; import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore"; import {useI18n} from "vue-i18n"; import VClosableCardTitle from "@/components/dialogs/VClosableCardTitle.vue"; +import {ApiApi, Automation} from "@/openapi"; const props = defineProps({ model: {type: String as PropType, required: true}, @@ -56,6 +57,7 @@ const {t} = useI18n() const dialog = defineModel({default: false}) const loading = ref(false) +const automate = ref(false) const genericModel = getGenericModelFromString(props.model, t) const target = ref(null) @@ -64,16 +66,35 @@ const target = ref(null) * merge source into selected target */ function mergeModel() { + let api = new ApiApi() + if (target.value != null) { loading.value = true genericModel.merge(props.source, target.value).then(r => { useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS) + + if (automate.value && target.value != null && Object.hasOwn(props.source, 'name') && Object.hasOwn(target.value, 'name')) { + let automation = { + name: `${t('Merge') } ${props.source.name} -> ${target.value.name}`.substring(0,128), + param1: props.source.name, + param2: target.value.name, + type: genericModel.model.mergeAutomation + } as Automation + api.apiAutomationCreate({automation: automation}).catch(err => { + useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err) + }).finally(() => { + loading.value = false + dialog.value = false + }) + } }).catch(err => { useMessageStore().addError(ErrorMessageType.UPDATE_ERROR, err) }).finally(() => { - loading.value = false - dialog.value = false + if (!automate.value) { + loading.value = false + dialog.value = false + } }) } diff --git a/vue3/src/locales/ar.json b/vue3/src/locales/ar.json index 7dbcf3f6b9..25b9c85e2b 100644 --- a/vue3/src/locales/ar.json +++ b/vue3/src/locales/ar.json @@ -174,6 +174,7 @@ "Meal_Type_Required": "", "Meal_Types": "", "Merge": "", + "MergeAutomateHelp": "", "Merge_Keyword": "", "Message": "", "Messages": "", diff --git a/vue3/src/locales/bg.json b/vue3/src/locales/bg.json index c75a129357..70b291097b 100644 --- a/vue3/src/locales/bg.json +++ b/vue3/src/locales/bg.json @@ -169,6 +169,7 @@ "Meal_Type_Required": "Изисква се вид хранене", "Meal_Types": "Видове хранене", "Merge": "Обединяване", + "MergeAutomateHelp": "", "Merge_Keyword": "Обединяване на ключова дума", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/ca.json b/vue3/src/locales/ca.json index b85d0c58e3..d1a0ed1faf 100644 --- a/vue3/src/locales/ca.json +++ b/vue3/src/locales/ca.json @@ -224,6 +224,7 @@ "Meal_Type_Required": "", "Meal_Types": "", "Merge": "", + "MergeAutomateHelp": "", "Merge_Keyword": "Fusioneu paraula clau", "Message": "", "Messages": "", diff --git a/vue3/src/locales/cs.json b/vue3/src/locales/cs.json index ea7d840888..a97f08356d 100644 --- a/vue3/src/locales/cs.json +++ b/vue3/src/locales/cs.json @@ -223,6 +223,7 @@ "Meal_Type_Required": "Druh jídla je povinný", "Meal_Types": "Druhy jídel", "Merge": "Spojit", + "MergeAutomateHelp": "", "Merge_Keyword": "Sloučit štítek", "Message": "Zpráva", "Messages": "", diff --git a/vue3/src/locales/da.json b/vue3/src/locales/da.json index ae2e810f8b..860782ff51 100644 --- a/vue3/src/locales/da.json +++ b/vue3/src/locales/da.json @@ -210,6 +210,7 @@ "Meal_Type_Required": "Måltidstype påkrævet", "Meal_Types": "Måltidstyper", "Merge": "Sammenflet", + "MergeAutomateHelp": "", "Merge_Keyword": "Sammenflet nøgleord", "Message": "Besked", "Messages": "", diff --git a/vue3/src/locales/de.json b/vue3/src/locales/de.json index 13977867bb..dcef196c1b 100644 --- a/vue3/src/locales/de.json +++ b/vue3/src/locales/de.json @@ -226,6 +226,7 @@ "Meal_Type_Required": "Mahlzeitentyp ist erforderlich", "Meal_Types": "Mahlzeiten", "Merge": "Zusammenführen", + "MergeAutomateHelp": "Erstelle eine Automatisierung die auch zukünftig erstellte Objekte mit diesem Namen durch das gewählte Objekt ersetzt. ", "Merge_Keyword": "Schlagworte zusammenführen", "Message": "Nachricht", "Messages": "Nachrichten", diff --git a/vue3/src/locales/el.json b/vue3/src/locales/el.json index 2e8c15d5c5..e5ab8de17f 100644 --- a/vue3/src/locales/el.json +++ b/vue3/src/locales/el.json @@ -205,6 +205,7 @@ "Meal_Type_Required": "Το είδος του γεύματος είναι απαραίτητο", "Meal_Types": "Είδη γευμάτων", "Merge": "Συγχώνευση", + "MergeAutomateHelp": "", "Merge_Keyword": "Συγχώνευση λέξης-κλειδί", "Message": "Μήνυμα", "Messages": "", diff --git a/vue3/src/locales/en.json b/vue3/src/locales/en.json index c29b519bde..bc5da6dcf9 100644 --- a/vue3/src/locales/en.json +++ b/vue3/src/locales/en.json @@ -225,6 +225,7 @@ "Meal_Type_Required": "Meal type is required", "Meal_Types": "Meal types", "Merge": "Merge", + "MergeAutomateHelp": "Create an automation that replaces future objects of this type with the selected object.", "Merge_Keyword": "Merge Keyword", "Message": "Message", "Messages": "Messages", diff --git a/vue3/src/locales/es.json b/vue3/src/locales/es.json index 2112c0307f..4115b12604 100644 --- a/vue3/src/locales/es.json +++ b/vue3/src/locales/es.json @@ -225,6 +225,7 @@ "Meal_Type_Required": "El Tipo es obligatorio", "Meal_Types": "Tipos de comida", "Merge": "Unificar", + "MergeAutomateHelp": "", "Merge_Keyword": "Fusionar palabra clave", "Message": "Mensaje", "Messages": "", diff --git a/vue3/src/locales/fi.json b/vue3/src/locales/fi.json index 415347206a..7ad8f7729b 100644 --- a/vue3/src/locales/fi.json +++ b/vue3/src/locales/fi.json @@ -124,6 +124,7 @@ "Meal_Type_Required": "Ateriatyyppi pakollinen", "Meal_Types": "Ateriatyypit", "Merge": "Yhdistä", + "MergeAutomateHelp": "", "Merge_Keyword": "Yhdistä Avainsana", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/fr.json b/vue3/src/locales/fr.json index 9649a34f5e..442da5f4d6 100644 --- a/vue3/src/locales/fr.json +++ b/vue3/src/locales/fr.json @@ -224,6 +224,7 @@ "Meal_Type_Required": "Type de repas obligatoire", "Meal_Types": "Types de repas", "Merge": "Fusionner", + "MergeAutomateHelp": "", "Merge_Keyword": "Fusionner le mot-clé", "Message": "Message", "Messages": "", diff --git a/vue3/src/locales/he.json b/vue3/src/locales/he.json index 6e4e1a1de8..1f7ac75aa7 100644 --- a/vue3/src/locales/he.json +++ b/vue3/src/locales/he.json @@ -225,6 +225,7 @@ "Meal_Type_Required": "סוג אוכל נדרש", "Meal_Types": "סוגי אוכל", "Merge": "איחוד", + "MergeAutomateHelp": "", "Merge_Keyword": "איחוד מילת מפתח", "Message": "הודעה", "Messages": "", diff --git a/vue3/src/locales/hu.json b/vue3/src/locales/hu.json index a11b2be8b1..71d957d021 100644 --- a/vue3/src/locales/hu.json +++ b/vue3/src/locales/hu.json @@ -206,6 +206,7 @@ "Meal_Type_Required": "Étkezés megadása kötelező", "Meal_Types": "Étkezések", "Merge": "Összefűzés", + "MergeAutomateHelp": "", "Merge_Keyword": "Kulcsszó összevonása", "Message": "Üzenet", "Messages": "", diff --git a/vue3/src/locales/hy.json b/vue3/src/locales/hy.json index 9d40d58adf..acc2f190d6 100644 --- a/vue3/src/locales/hy.json +++ b/vue3/src/locales/hy.json @@ -89,6 +89,7 @@ "MealPlanShoppingHelp": "", "Meal_Plan": "Ճաշացուցակ", "Merge": "Միացնել", + "MergeAutomateHelp": "", "Merge_Keyword": "Միացնել բանալի բառը", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/id.json b/vue3/src/locales/id.json index 5ef5954196..33090958e9 100644 --- a/vue3/src/locales/id.json +++ b/vue3/src/locales/id.json @@ -191,6 +191,7 @@ "Meal_Type_Required": "", "Meal_Types": "", "Merge": "Menggabungkan", + "MergeAutomateHelp": "", "Merge_Keyword": "Gabungkan Kata Kunci", "Message": "", "Messages": "", diff --git a/vue3/src/locales/is.json b/vue3/src/locales/is.json index 46b8342e5f..f3d57f5285 100644 --- a/vue3/src/locales/is.json +++ b/vue3/src/locales/is.json @@ -224,6 +224,7 @@ "Meal_Type_Required": "", "Meal_Types": "", "Merge": "", + "MergeAutomateHelp": "", "Merge_Keyword": "", "Message": "", "Messages": "", diff --git a/vue3/src/locales/it.json b/vue3/src/locales/it.json index 8b4184829d..696d2919de 100644 --- a/vue3/src/locales/it.json +++ b/vue3/src/locales/it.json @@ -196,6 +196,7 @@ "Meal_Type_Required": "Il tipo di pasto è richiesto", "Meal_Types": "Tipi di pasto", "Merge": "Unisci", + "MergeAutomateHelp": "", "Merge_Keyword": "Unisci parola chiave", "Message": "Messaggio", "Messages": "", diff --git a/vue3/src/locales/lt.json b/vue3/src/locales/lt.json index 782ffc5157..31f1d30db7 100644 --- a/vue3/src/locales/lt.json +++ b/vue3/src/locales/lt.json @@ -208,6 +208,7 @@ "Meal_Type_Required": "", "Meal_Types": "", "Merge": "", + "MergeAutomateHelp": "", "Merge_Keyword": "Sujungti raktažodį", "Message": "", "Messages": "", diff --git a/vue3/src/locales/nb_NO.json b/vue3/src/locales/nb_NO.json index 6d0b0534a9..269e108fea 100644 --- a/vue3/src/locales/nb_NO.json +++ b/vue3/src/locales/nb_NO.json @@ -203,6 +203,7 @@ "Meal_Type_Required": "Måltidstype er nødvendig", "Meal_Types": "Måltidstyper", "Merge": "Slå sammen", + "MergeAutomateHelp": "", "Merge_Keyword": "Slå sammen nøkkelord", "Message": "Melding", "Messages": "", diff --git a/vue3/src/locales/nl.json b/vue3/src/locales/nl.json index c824c6a829..6428f385a2 100644 --- a/vue3/src/locales/nl.json +++ b/vue3/src/locales/nl.json @@ -207,6 +207,7 @@ "Meal_Type_Required": "Maaltype is verplicht", "Meal_Types": "Maaltypes", "Merge": "Samenvoegen", + "MergeAutomateHelp": "", "Merge_Keyword": "Voeg Etiket samen", "Message": "Bericht", "Messages": "", diff --git a/vue3/src/locales/pl.json b/vue3/src/locales/pl.json index a3e576beec..1466799bb1 100644 --- a/vue3/src/locales/pl.json +++ b/vue3/src/locales/pl.json @@ -226,6 +226,7 @@ "Meal_Type_Required": "Rodzaj posiłku jest wymagany", "Meal_Types": "Rodzaje posiłków", "Merge": "Scal", + "MergeAutomateHelp": "", "Merge_Keyword": "Scal słowa kluczowe", "Message": "Wiadomość", "Messages": "", diff --git a/vue3/src/locales/pt.json b/vue3/src/locales/pt.json index b162c73f76..c5b52b05ce 100644 --- a/vue3/src/locales/pt.json +++ b/vue3/src/locales/pt.json @@ -166,6 +166,7 @@ "Meal_Type_Required": "Tipo de refeição é necessário", "Meal_Types": "Tipos de refeições", "Merge": "Juntar", + "MergeAutomateHelp": "", "Merge_Keyword": "Unir palavra-chave", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/pt_BR.json b/vue3/src/locales/pt_BR.json index 7b8583d9f8..995a51b01b 100644 --- a/vue3/src/locales/pt_BR.json +++ b/vue3/src/locales/pt_BR.json @@ -218,6 +218,7 @@ "Meal_Type_Required": "Tipo de comida é obrigatório", "Meal_Types": "Tipos de Comida", "Merge": "Mesclar", + "MergeAutomateHelp": "", "Merge_Keyword": "Mesclar palavra-chave", "Message": "Mensagem", "Messages": "", diff --git a/vue3/src/locales/ro.json b/vue3/src/locales/ro.json index 3fb23c642e..c81e500761 100644 --- a/vue3/src/locales/ro.json +++ b/vue3/src/locales/ro.json @@ -200,6 +200,7 @@ "Meal_Type_Required": "Tipul mesei este necesar", "Meal_Types": "Tipuri de mese", "Merge": "Unire", + "MergeAutomateHelp": "", "Merge_Keyword": "Unește cuvânt cheie", "Message": "Mesaj", "Messages": "", diff --git a/vue3/src/locales/ru.json b/vue3/src/locales/ru.json index 2729ea8409..9cfea349b7 100644 --- a/vue3/src/locales/ru.json +++ b/vue3/src/locales/ru.json @@ -155,6 +155,7 @@ "Meal_Type_Required": "Тип питания обязателен", "Meal_Types": "Типы питания", "Merge": "Объединить", + "MergeAutomateHelp": "", "Merge_Keyword": "Объеденить ключевые слова", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/sl.json b/vue3/src/locales/sl.json index 869bc4afd5..1f8664e41b 100644 --- a/vue3/src/locales/sl.json +++ b/vue3/src/locales/sl.json @@ -151,6 +151,7 @@ "Meal_Type_Required": "Tip obroka je obvezen", "Meal_Types": "Tipi obroka", "Merge": "Združi", + "MergeAutomateHelp": "", "Merge_Keyword": "Združi ključno besedo", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/sv.json b/vue3/src/locales/sv.json index 42a2a7b88e..a2e1f79f2e 100644 --- a/vue3/src/locales/sv.json +++ b/vue3/src/locales/sv.json @@ -226,6 +226,7 @@ "Meal_Type_Required": "Måltidstyp är obligatorisk", "Meal_Types": "Måltidstyper", "Merge": "Slå samman", + "MergeAutomateHelp": "", "Merge_Keyword": "Slå samman nyckelord", "Message": "Meddelande", "Messages": "", diff --git a/vue3/src/locales/tr.json b/vue3/src/locales/tr.json index 6f4017e9ae..ab689c95b8 100644 --- a/vue3/src/locales/tr.json +++ b/vue3/src/locales/tr.json @@ -225,6 +225,7 @@ "Meal_Type_Required": "Yemek türü gereklidir", "Meal_Types": "Yemek türleri", "Merge": "Birleştir", + "MergeAutomateHelp": "", "Merge_Keyword": "Anahtar Kelimeyi Birleştir", "Message": "Mesaj", "Messages": "", diff --git a/vue3/src/locales/uk.json b/vue3/src/locales/uk.json index a086e58ad1..6d70e261a2 100644 --- a/vue3/src/locales/uk.json +++ b/vue3/src/locales/uk.json @@ -180,6 +180,7 @@ "Meal_Type_Required": "Тип страви є обов'язковим", "Meal_Types": "Типи страви", "Merge": "Об'єднати", + "MergeAutomateHelp": "", "Merge_Keyword": "Об'єднати Ключове слово", "Messages": "", "Miscellaneous": "", diff --git a/vue3/src/locales/zh_Hans.json b/vue3/src/locales/zh_Hans.json index abb4b85079..043d531967 100644 --- a/vue3/src/locales/zh_Hans.json +++ b/vue3/src/locales/zh_Hans.json @@ -221,6 +221,7 @@ "Meal_Type_Required": "用餐类型是必需的", "Meal_Types": "用餐类型", "Merge": "合并", + "MergeAutomateHelp": "", "Merge_Keyword": "合并关键词", "Message": "信息", "Messages": "", diff --git a/vue3/src/locales/zh_Hant.json b/vue3/src/locales/zh_Hant.json index 3638a965ec..3352444de5 100644 --- a/vue3/src/locales/zh_Hant.json +++ b/vue3/src/locales/zh_Hant.json @@ -73,6 +73,7 @@ "Manage_Books": "管理書籍", "MealPlanShoppingHelp": "", "Meal_Plan": "膳食計劃", + "MergeAutomateHelp": "", "Messages": "", "Miscellaneous": "", "Monday": "", diff --git a/vue3/src/types/Models.ts b/vue3/src/types/Models.ts index dc36406a9a..ce72e38b93 100644 --- a/vue3/src/types/Models.ts +++ b/vue3/src/types/Models.ts @@ -1,6 +1,6 @@ import { AccessToken, - ApiApi, Automation, + ApiApi, Automation, type AutomationTypeEnum, Food, Ingredient, InviteLink, Keyword, @@ -102,6 +102,7 @@ export type Model = { isPaginated: boolean | undefined, isMerge?: boolean | undefined, + mergeAutomation?: string | AutomationTypeEnum, isTree?: boolean | undefined, tableHeaders: ModelTableHeaders[], @@ -161,6 +162,7 @@ export const TFood = { isPaginated: true, isMerge: true, + mergeAutomation: 'FOOD_ALIAS', toStringKeys: ['name'], tableHeaders: [ @@ -179,6 +181,7 @@ export const TUnit = { isPaginated: true, isMerge: true, + mergeAutomation: 'UNIT_ALIAS', toStringKeys: ['name'], tableHeaders: [ @@ -196,6 +199,7 @@ export const TKeyword = { isPaginated: true, isMerge: true, + mergeAutomation: 'KEYWORD_ALIAS', toStringKeys: ['name'], tableHeaders: [