Skip to content

Commit

Permalink
merge & automate
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Jan 2, 2025
1 parent cab1641 commit 05e5072
Show file tree
Hide file tree
Showing 33 changed files with 61 additions and 5 deletions.
29 changes: 25 additions & 4 deletions vue3/src/components/dialogs/ModelMergeDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
</v-col>
</v-row>

<v-checkbox :label="$t('Automate')" v-model="automate" :hint="$t('MergeAutomateHelp')" persistent-hint v-if="genericModel.model.mergeAutomation"></v-checkbox>

</v-card-text>
<v-card-actions>
<v-btn :disabled="loading">{{ $t('Cancel') }}</v-btn>
<v-btn color="warning" @click="mergeModel()" :loading="loading">{{ $t('Merge') }}</v-btn>
<v-btn color="warning" @click="mergeModel()" :loading="loading" :disabled="!target">{{ $t('Merge') }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
Expand All @@ -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<EditorSupportedModels>, required: true},
Expand All @@ -56,6 +57,7 @@ const {t} = useI18n()
const dialog = defineModel<boolean>({default: false})
const loading = ref(false)
const automate = ref(false)
const genericModel = getGenericModelFromString(props.model, t)
const target = ref<null | EditorSupportedTypes>(null)
Expand All @@ -64,16 +66,35 @@ const target = ref<null | EditorSupportedTypes>(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
}
})
}
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"Meal_Type_Required": "",
"Meal_Types": "",
"Merge": "",
"MergeAutomateHelp": "",
"Merge_Keyword": "",
"Message": "",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"Meal_Type_Required": "Изисква се вид хранене",
"Meal_Types": "Видове хранене",
"Merge": "Обединяване",
"MergeAutomateHelp": "",
"Merge_Keyword": "Обединяване на ключова дума",
"Messages": "",
"Miscellaneous": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
"Meal_Type_Required": "",
"Meal_Types": "",
"Merge": "",
"MergeAutomateHelp": "",
"Merge_Keyword": "Fusioneu paraula clau",
"Message": "",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"Meal_Type_Required": "Το είδος του γεύματος είναι απαραίτητο",
"Meal_Types": "Είδη γευμάτων",
"Merge": "Συγχώνευση",
"MergeAutomateHelp": "",
"Merge_Keyword": "Συγχώνευση λέξης-κλειδί",
"Message": "Μήνυμα",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"Meal_Type_Required": "Ateriatyyppi pakollinen",
"Meal_Types": "Ateriatyypit",
"Merge": "Yhdistä",
"MergeAutomateHelp": "",
"Merge_Keyword": "Yhdistä Avainsana",
"Messages": "",
"Miscellaneous": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"Meal_Type_Required": "סוג אוכל נדרש",
"Meal_Types": "סוגי אוכל",
"Merge": "איחוד",
"MergeAutomateHelp": "",
"Merge_Keyword": "איחוד מילת מפתח",
"Message": "הודעה",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/hy.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"MealPlanShoppingHelp": "",
"Meal_Plan": "Ճաշացուցակ",
"Merge": "Միացնել",
"MergeAutomateHelp": "",
"Merge_Keyword": "Միացնել բանալի բառը",
"Messages": "",
"Miscellaneous": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"Meal_Type_Required": "",
"Meal_Types": "",
"Merge": "Menggabungkan",
"MergeAutomateHelp": "",
"Merge_Keyword": "Gabungkan Kata Kunci",
"Message": "",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/is.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
"Meal_Type_Required": "",
"Meal_Types": "",
"Merge": "",
"MergeAutomateHelp": "",
"Merge_Keyword": "",
"Message": "",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"Meal_Type_Required": "",
"Meal_Types": "",
"Merge": "",
"MergeAutomateHelp": "",
"Merge_Keyword": "Sujungti raktažodį",
"Message": "",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/nb_NO.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
"Meal_Type_Required": "Maaltype is verplicht",
"Meal_Types": "Maaltypes",
"Merge": "Samenvoegen",
"MergeAutomateHelp": "",
"Merge_Keyword": "Voeg Etiket samen",
"Message": "Bericht",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"Meal_Type_Required": "Тип питания обязателен",
"Meal_Types": "Типы питания",
"Merge": "Объединить",
"MergeAutomateHelp": "",
"Merge_Keyword": "Объеденить ключевые слова",
"Messages": "",
"Miscellaneous": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"Meal_Type_Required": "Тип страви є обов'язковим",
"Meal_Types": "Типи страви",
"Merge": "Об'єднати",
"MergeAutomateHelp": "",
"Merge_Keyword": "Об'єднати Ключове слово",
"Messages": "",
"Miscellaneous": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/zh_Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"Meal_Type_Required": "用餐类型是必需的",
"Meal_Types": "用餐类型",
"Merge": "合并",
"MergeAutomateHelp": "",
"Merge_Keyword": "合并关键词",
"Message": "信息",
"Messages": "",
Expand Down
1 change: 1 addition & 0 deletions vue3/src/locales/zh_Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"Manage_Books": "管理書籍",
"MealPlanShoppingHelp": "",
"Meal_Plan": "膳食計劃",
"MergeAutomateHelp": "",
"Messages": "",
"Miscellaneous": "",
"Monday": "",
Expand Down
6 changes: 5 additions & 1 deletion vue3/src/types/Models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
AccessToken,
ApiApi, Automation,
ApiApi, Automation, type AutomationTypeEnum,
Food,
Ingredient,
InviteLink, Keyword,
Expand Down Expand Up @@ -102,6 +102,7 @@ export type Model = {

isPaginated: boolean | undefined,
isMerge?: boolean | undefined,
mergeAutomation?: string | AutomationTypeEnum,
isTree?: boolean | undefined,

tableHeaders: ModelTableHeaders[],
Expand Down Expand Up @@ -161,6 +162,7 @@ export const TFood = {

isPaginated: true,
isMerge: true,
mergeAutomation: 'FOOD_ALIAS',
toStringKeys: ['name'],

tableHeaders: [
Expand All @@ -179,6 +181,7 @@ export const TUnit = {

isPaginated: true,
isMerge: true,
mergeAutomation: 'UNIT_ALIAS',
toStringKeys: ['name'],

tableHeaders: [
Expand All @@ -196,6 +199,7 @@ export const TKeyword = {

isPaginated: true,
isMerge: true,
mergeAutomation: 'KEYWORD_ALIAS',
toStringKeys: ['name'],

tableHeaders: [
Expand Down

0 comments on commit 05e5072

Please sign in to comment.