WIP merge button

This commit is contained in:
vabene1111
2024-12-30 17:07:38 +01:00
parent e219f7e07c
commit fabf0c28e3
4 changed files with 60 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
<template>
<v-dialog max-width="600px" :activator="props.activator" v-model="dialog">
<v-card>
<v-card-title>{{ $t('merge_title', {type: getGenericModelFromString(props.model).model.name}) }}</v-card-title>
<!-- TODO localize model name -->
<v-card-text>
{{ $t('merge_selection', {source: '', type: getGenericModelFromString(props.model).model.name}) }}
<model-select append-to-body :model="props.model"></model-select>
</v-card-text>
<v-card-actions>
<v-btn>{{ $t('Cancel') }}</v-btn>
<v-btn color="warning">{{ $t('Merge') }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup lang="ts">
import ModelSelect from "@/components/inputs/ModelSelect.vue";
import {PropType} from "vue";
import {EditorSupportedModels, getGenericModelFromString} from "@/types/Models";
const props = defineProps({
model: {type: String as PropType<EditorSupportedModels>, required: true},
sourceObject: {},
activator: {type: String, default: 'parent'},
})
const dialog = defineModel<boolean>({default: false})
function mergeModel() {
}
</script>
<style scoped>
</style>

View File

@@ -44,8 +44,19 @@
:items-per-page="useUserPreferenceStore().deviceSettings.general_tableItemsPerPage"
>
<template v-slot:item.action="{ item }">
<v-btn color="edit" :to="{name: 'ModelEditPage', params: {model: model, id: item.id}}">
<v-icon icon="$edit"></v-icon>
<v-btn class="float-right" icon="$menu" variant="plain">
<v-icon icon="$menu"></v-icon>
<v-menu activator="parent">
<v-list>
<v-list-item prepend-icon="$edit" :to="{name: 'ModelEditPage', params: {model: model, id: item.id}}">
{{ $t('Edit') }}
</v-list-item>
<v-list-item prepend-icon="fa-solid fa-arrows-to-dot" link>
{{ $t('Merge') }}
<model-merge-dialog :model="model" activator="parent"></model-merge-dialog>
</v-list-item>
</v-list>
</v-menu>
</v-btn>
</template>
</v-data-table-server>
@@ -71,6 +82,7 @@ import {useUrlSearchParams} from "@vueuse/core";
import ModelEditDialog from "@/components/dialogs/ModelEditDialog.vue";
import {useRouter} from "vue-router";
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
import ModelMergeDialog from "@/components/dialogs/ModelMergeDialog.vue";
type VDataTableProps = InstanceType<typeof VDataTable>['$props']
@@ -156,7 +168,7 @@ function loadItems({page, itemsPerPage, search, sortBy, groupBy}) {
items.value = r.results
itemCount.value = r.count
}).catch((err: any) => {
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
}).finally(() => {
loading.value = false
tablePage.value = page // TODO remove once page bug is fixed

View File

@@ -83,6 +83,8 @@ export type Model = {
disableListView?: boolean | undefined,
isPaginated: boolean | undefined,
isMerge?: boolean | undefined,
isTree?: boolean | undefined,
tableHeaders: ModelTableHeaders[],
}
@@ -116,6 +118,7 @@ export const TFood = {
icon: 'fa-solid fa-carrot',
isPaginated: true,
isMerge: true,
toStringKeys: ['name'],
tableHeaders: [

View File

@@ -78,6 +78,7 @@ export default createVuetify({
mealplan: 'fa-solid fa-calendar-days',
recipes: 'fa-solid fa-book',
books: 'fa-solid fa-book-open',
menu: 'fa-solid fa-ellipsis-vertical'
},
sets: {
fa,