Skip to content

Commit

Permalink
WIP merge button
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Dec 30, 2024
1 parent e219f7e commit fabf0c2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
41 changes: 41 additions & 0 deletions vue3/src/components/dialogs/ModelMergeDialog.vue
Original file line number Diff line number Diff line change
@@ -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>
18 changes: 15 additions & 3 deletions vue3/src/pages/ModelListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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']
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions vue3/src/types/Models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export type Model = {
disableListView?: boolean | undefined,

isPaginated: boolean | undefined,
isMerge?: boolean | undefined,
isTree?: boolean | undefined,

tableHeaders: ModelTableHeaders[],
}
Expand Down Expand Up @@ -116,6 +118,7 @@ export const TFood = {
icon: 'fa-solid fa-carrot',

isPaginated: true,
isMerge: true,
toStringKeys: ['name'],

tableHeaders: [
Expand Down
1 change: 1 addition & 0 deletions vue3/src/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fabf0c2

Please sign in to comment.