mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
basics of an open data plugin (tmp in this repo)
temporarily in the main repo while testing and playing around
This commit is contained in:
26
vue3/src/plugins/open_data_plugin/OpenDataPage.vue
Normal file
26
vue3/src/plugins/open_data_plugin/OpenDataPage.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<v-container>
|
||||
Welcome to the OpenData Plugin in Tandoor 2
|
||||
<model-select model="OpenDataFood" allow-create></model-select>
|
||||
|
||||
</v-container>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {onMounted, ref} from "vue";
|
||||
import ModelSelect from "@/components/inputs/ModelSelect.vue";
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<model-editor-base
|
||||
:loading="loading"
|
||||
:dialog="dialog"
|
||||
@save="saveObject"
|
||||
@delete="deleteObject"
|
||||
@close="emit('close'); editingObjChanged = false"
|
||||
:is-update="isUpdate()"
|
||||
:is-changed="editingObjChanged"
|
||||
:model-class="modelClass"
|
||||
:object-name="editingObjName()">
|
||||
<v-card-text>
|
||||
<v-form :disabled="loading">
|
||||
|
||||
<v-text-field :label="$t('Name')" v-model="editingObj.name"></v-text-field>
|
||||
|
||||
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
</model-editor-base>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import {onMounted, PropType} from "vue";
|
||||
import {Keyword, OpenDataFood} from "@/openapi";
|
||||
import ModelEditorBase from "@/components/model_editors/ModelEditorBase.vue";
|
||||
import {useModelEditorFunctions} from "@/composables/useModelEditorFunctions";
|
||||
|
||||
const props = defineProps({
|
||||
item: {type: {} as PropType<OpenDataFood>, required: false, default: null},
|
||||
itemId: {type: [Number, String], required: false, default: undefined},
|
||||
itemDefaults: {type: {} as PropType<OpenDataFood>, required: false, default: {} as OpenDataFood},
|
||||
dialog: {type: Boolean, default: false}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['create', 'save', 'delete', 'close', 'changedState'])
|
||||
const {setupState, deleteObject, saveObject, isUpdate, editingObjName, loading, editingObj, editingObjChanged, modelClass} = useModelEditorFunctions<OpenDataFood>('OpenDataFood', emit)
|
||||
|
||||
// object specific data (for selects/display)
|
||||
|
||||
onMounted(() => {
|
||||
setupState(props.item, props.itemId, {itemDefaults: props.itemDefaults})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
32
vue3/src/plugins/open_data_plugin/plugin.ts
Normal file
32
vue3/src/plugins/open_data_plugin/plugin.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {TandoorPlugin} from '@/types/Plugins.ts'
|
||||
import {Model, registerModel} from "@/types/Models.ts";
|
||||
import {defineAsyncComponent} from "vue";
|
||||
|
||||
export const plugin: TandoorPlugin = {
|
||||
name: 'Open Data Plugin',
|
||||
routes: [
|
||||
{path: '/open-data/', component: () => import("@/plugins/open_data_plugin/OpenDataPage.vue"), name: 'OpenDataPage'},
|
||||
]
|
||||
} as TandoorPlugin
|
||||
|
||||
|
||||
// define models below
|
||||
|
||||
const TOpenDataFood = {
|
||||
name: 'OpenDataFood',
|
||||
localizationKey: 'Food',
|
||||
localizationKeyDescription: 'FoodHelp',
|
||||
icon: 'fa-solid fa-carrot',
|
||||
|
||||
editorComponent: defineAsyncComponent(() => import(`@/plugins/open_data_plugin/components/model_editors/OpenDataFoodEditor.vue`)),
|
||||
|
||||
isPaginated: false,
|
||||
isMerge: false,
|
||||
toStringKeys: ['name'],
|
||||
|
||||
tableHeaders: [
|
||||
{title: 'Name', key: 'name'},
|
||||
{title: 'Actions', key: 'action', align: 'end'},
|
||||
]
|
||||
} as Model
|
||||
registerModel(TOpenDataFood)
|
||||
Reference in New Issue
Block a user