mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 12:18:45 -05:00
changed model list navigation
This commit is contained in:
32
vue3/src/components/display/DatabaseLinkCol.vue
Normal file
32
vue3/src/components/display/DatabaseLinkCol.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<v-col cols="12" md="6" lg="4">
|
||||
<v-card :prepend-icon="props.prependIcon" :title="props.title" :subtitle="props.subtitle" variant="outlined" elevation="1"
|
||||
:to="props.to"
|
||||
append-icon="fa-solid fa-arrow-right">
|
||||
</v-card>
|
||||
</v-col>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {EditorSupportedModels, GenericModel, getGenericModelFromString} from "@/types/Models.ts";
|
||||
import {onBeforeMount, PropType, ref, watch} from "vue";
|
||||
import {useI18n} from "vue-i18n";
|
||||
import type { RouteLocationRaw } from 'vue-router';
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
const props = defineProps({
|
||||
prependIcon: {type: String, default: ''},
|
||||
title: {type: String, default: ''},
|
||||
subtitle: {type: String, default: ''},
|
||||
to: {type: {} as PropType<RouteLocationRaw> }
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
50
vue3/src/components/display/DatabaseModelCol.vue
Normal file
50
vue3/src/components/display/DatabaseModelCol.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<v-col cols="12" md="6" lg="4">
|
||||
<v-card :prepend-icon="genericModel.model.icon" :title="$t(genericModel.model.localizationKey)" :subtitle="$t(genericModel.model.localizationKeyDescription)" variant="outlined" elevation="1"
|
||||
:to="{name: 'ModelListPage', params: {model: genericModel.model.name}}"
|
||||
append-icon="fa-solid fa-arrow-right">
|
||||
</v-card>
|
||||
</v-col>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {EditorSupportedModels, GenericModel, getGenericModelFromString} from "@/types/Models.ts";
|
||||
import {onBeforeMount, PropType, ref, watch} from "vue";
|
||||
import {useI18n} from "vue-i18n";
|
||||
|
||||
const {t} = useI18n()
|
||||
|
||||
const props = defineProps({
|
||||
model: {
|
||||
type: String as PropType<EditorSupportedModels>,
|
||||
default: 'food'
|
||||
},
|
||||
})
|
||||
|
||||
const genericModel = ref({} as GenericModel)
|
||||
|
||||
watch(() => props.model, (newValue, oldValue) => {
|
||||
if (newValue != oldValue) {
|
||||
genericModel.value = getGenericModelFromString(props.model, t)
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* select model class before mount because template renders before onMounted is called
|
||||
*/
|
||||
onBeforeMount(() => {
|
||||
try {
|
||||
genericModel.value = getGenericModelFromString(props.model, t)
|
||||
} catch (Error) {
|
||||
console.error('Invalid model passed to ModelListPage, loading Food instead')
|
||||
genericModel.value = getGenericModelFromString('Food', t)
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,15 +1,15 @@
|
||||
<template>
|
||||
|
||||
<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.toLowerCase()} }">
|
||||
<template #prepend>
|
||||
<v-icon :icon="m.icon"></v-icon>
|
||||
</template>
|
||||
{{ $t(m.localizationKey) }}
|
||||
</v-list-item>
|
||||
</template>
|
||||
<!-- <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.toLowerCase()} }">-->
|
||||
<!-- <template #prepend>-->
|
||||
<!-- <v-icon :icon="m.icon"></v-icon>-->
|
||||
<!-- </template>-->
|
||||
<!-- {{ $t(m.localizationKey) }}-->
|
||||
<!-- </v-list-item>-->
|
||||
<!-- </template>-->
|
||||
|
||||
<template v-if="route.name == 'MealPlanPage'">
|
||||
<v-divider></v-divider>
|
||||
|
||||
Reference in New Issue
Block a user