fixed model switcher

This commit is contained in:
vabene1111
2024-12-22 13:55:04 +01:00
parent 3f7c22cfe0
commit 8e0da93476
4 changed files with 15 additions and 3 deletions

View File

@@ -32,6 +32,14 @@ const editorComponent = shallowRef(defineAsyncComponent(() => import(`@/componen
const model = defineModel<Boolean|undefined>({default: undefined})
const dialogActivator = (model.value !== undefined) ? undefined : props.activator
/**
* for some reason editorComponent is not updated automatically when prop is changed
* because of this watch prop changes and update manually if prop is changed
*/
watch(() => props.model, () => {
editorComponent.value = defineAsyncComponent(() => import(`@/components/model_editors/${getGenericModelFromString(props.model, t).model.name}Editor.vue`))
})
/**
* Allow opening the model edit dialog trough v-model property of the dialog by watching for model changes
*/

View File

@@ -3,7 +3,7 @@
<template v-if="route.name == 'ModelListPage'">
<v-divider></v-divider>
<v-list-item v-for="m in getListModels()"
:to="{ name: 'ModelListPage', params: {model: m.name} }">
:to="{ name: 'ModelListPage', params: {model: m.name.toLowerCase()} }">
<template #prepend>
<v-icon :icon="m.icon"></v-icon>
</template>

View File

@@ -211,7 +211,7 @@
import {computed, onMounted, ref} from "vue";
import {useShoppingStore} from "@/stores/ShoppingStore";
import {ApiApi, Food, IngredientString, ShoppingListEntry, ShoppingListRecipe, Supermarket, Unit} from "@/openapi";
import {ApiApi, Food, IngredientString, ResponseError, ShoppingListEntry, ShoppingListRecipe, Supermarket, Unit} from "@/openapi";
import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore";
import ShoppingLineItem from "@/components/display/ShoppingLineItem.vue";
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
@@ -256,6 +256,10 @@ onMounted(() => {
if (useUserPreferenceStore().deviceSettings.shopping_selected_supermarket != null) {
new ApiApi().apiSupermarketRetrieve({id: useUserPreferenceStore().deviceSettings.shopping_selected_supermarket!.id!}).then(r => {
useUserPreferenceStore().deviceSettings.shopping_selected_supermarket = r
}).catch(err => {
if (err instanceof ResponseError && err.response.status == 404) {
useUserPreferenceStore().deviceSettings.shopping_selected_supermarket = null
}
})
}
})