mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-11 17:16:59 -05:00
model related stuff
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-card >
|
||||
<v-card-text class="pt-2 pb-2">
|
||||
<v-btn variant="flat" @click="router.go(-1)" prepend-icon="fa-solid fa-arrow-left">{{ $t('Back')}}</v-btn>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<food-editor :item-id="id"></food-editor>
|
||||
@@ -13,12 +22,14 @@
|
||||
import FoodEditor from "@/components/model_editors/FoodEditor.vue";
|
||||
import {onMounted, ref} from "vue";
|
||||
import {ApiApi, Food} from "@/openapi";
|
||||
import {useRouter} from "vue-router";
|
||||
|
||||
const props = defineProps({
|
||||
model: {type: String, default: 'Food'},
|
||||
id: {type: String, required: true},
|
||||
})
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
:items-length="itemCount"
|
||||
:loading="loading"
|
||||
:search="searchQuery"
|
||||
|
||||
:headers="tableHeaders"
|
||||
:headers="genericModel.getTableHeaders()"
|
||||
:items-per-page-options="itemsPerPageOptions"
|
||||
:show-select="tableShowSelect"
|
||||
>
|
||||
@@ -44,10 +43,7 @@
|
||||
</v-data-table-server>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
</v-container>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -69,10 +65,9 @@ import {
|
||||
TAutomation,
|
||||
TUserFile, TCookLog, TViewLog
|
||||
} from "@/types/Models";
|
||||
import {ca} from "vuetify/locale";
|
||||
import {ApiApi} from "@/openapi";
|
||||
import ModelSelect from "@/components/inputs/ModelSelect.vue";
|
||||
import ModelEditorDialog from "@/components/dialogs/ModelEditorDialog.vue";
|
||||
import {VDataTable} from "vuetify/components";
|
||||
type VDataTableProps = InstanceType<typeof VDataTable>['$props']
|
||||
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
@@ -87,10 +82,10 @@ const itemsPerPageOptions = [
|
||||
{value: 50, title: '50'},
|
||||
]
|
||||
|
||||
const tableHeaders = [
|
||||
const tableHeaders : VDataTableProps['headers'] = [
|
||||
{title: t('Name'), key: 'name'},
|
||||
{title: t('Category'), key: 'supermarketCategory.name'},
|
||||
{title: t('Edit'), key: 'action', align: 'end'},
|
||||
{title: t('Actions'), key: 'action', align: 'end'},
|
||||
]
|
||||
|
||||
const tableShowSelect = ref(true)
|
||||
@@ -107,7 +102,7 @@ const genericModel = ref({} as GenericModel)
|
||||
// watch for changes to the prop in case its changed
|
||||
watch(() => props.model, () => {
|
||||
console.log('loading model ', props.model)
|
||||
genericModel.value = getGenericModelFromString(props.model)
|
||||
genericModel.value = getGenericModelFromString(props.model, t)
|
||||
loadItems({page: 1, itemsPerPage: 10})
|
||||
})
|
||||
|
||||
@@ -117,10 +112,10 @@ watch(() => props.model, () => {
|
||||
onBeforeMount(() => {
|
||||
|
||||
try {
|
||||
genericModel.value = getGenericModelFromString(props.model)
|
||||
genericModel.value = getGenericModelFromString(props.model, t)
|
||||
} catch (Error) {
|
||||
console.error('Invalid model passed to ModelListPage, loading Food instead')
|
||||
genericModel.value = getGenericModelFromString('Food')
|
||||
genericModel.value = getGenericModelFromString('Food', t)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user