@antcde/component-library 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1660 -1658
- package/dist/types/components/TasksFlow/useTaskFlow.d.ts +0 -1
- package/lib/DocumentManager/DocumentManager.vue +10 -5
- package/lib/TableViewer/TableViewer.vue +51 -177
- package/lib/TableViewer/composables/columns.ts +51 -0
- package/lib/TableViewer/composables/records.ts +18 -1
- package/lib/TableViewer/composables/relations.ts +8 -0
- package/lib/TableViewer/core/Columns/ColumnForm.vue +403 -190
- package/lib/TableViewer/core/Columns/ColumnItem.vue +225 -0
- package/lib/TableViewer/core/Columns/ColumnsList.vue +142 -0
- package/lib/TableViewer/core/Columns/ForeignKeyColumnItem.vue +165 -0
- package/lib/TableViewer/core/Columns/ForeignKeyColumnsList.vue +55 -0
- package/lib/TableViewer/core/Dialog/DeleteConfirmationDialog.vue +63 -0
- package/lib/TableViewer/core/Filters/ConditionItem.vue +133 -0
- package/lib/TableViewer/core/Filters/ConditionsList.vue +53 -0
- package/lib/TableViewer/core/Filters/FiltersEditor.vue +48 -0
- package/lib/TableViewer/core/Filters/QueriesList.vue +63 -0
- package/lib/TableViewer/core/{Queries → Filters}/QueryItem.vue +3 -3
- package/lib/TableViewer/core/Records/RecordCell.vue +32 -42
- package/lib/TableViewer/core/Records/RecordForm.vue +146 -0
- package/lib/TableViewer/core/Records/RecordHeader.vue +60 -153
- package/lib/TableViewer/core/Records/RecordInput.vue +65 -14
- package/lib/TableViewer/core/Records/RecordValue.vue +67 -20
- package/lib/TableViewer/core/Records/RecordsTable.vue +97 -56
- package/lib/TableViewer/core/Records/RecordsTableToolbar.vue +42 -142
- package/lib/TableViewer/core/Revisions/RevisionHistory.vue +25 -7
- package/lib/TableViewer/core/Tables/TableEditor.vue +136 -0
- package/lib/TableViewer/core/Tables/TableItem.vue +162 -0
- package/lib/TableViewer/core/Tables/TableViewer.vue +28 -0
- package/lib/TableViewer/core/Tables/TablesList.vue +116 -0
- package/lib/TableViewer/stores/columnRelation.ts +106 -0
- package/lib/TableViewer/stores/columns.ts +56 -37
- package/lib/TableViewer/stores/conditions.ts +44 -46
- package/lib/TableViewer/stores/records.ts +73 -4
- package/lib/TableViewer/stores/table.ts +48 -52
- package/lib/TableViewer/stores/tables.ts +1 -1
- package/lib/TableViewer/types/column.d.ts +2 -2
- package/lib/TableViewer/types/relations.d.ts +7 -0
- package/package.json +2 -2
- package/lib/DocumentManager/hooks/useDarkMode.ts +0 -17
- package/lib/TableViewer/TableView.vue +0 -39
- package/lib/TableViewer/core/Columns/ColumnsConfiguration.vue +0 -99
- package/lib/TableViewer/core/Columns/ColumnsConfigurationTable.vue +0 -186
- package/lib/TableViewer/core/Columns/ColumnsTable.vue +0 -165
- package/lib/TableViewer/core/Permissions/PermissionDialog.vue +0 -149
- package/lib/TableViewer/core/Permissions/PermissionForm.vue +0 -117
- package/lib/TableViewer/core/Permissions/PermissionsConfiguration.vue +0 -55
- package/lib/TableViewer/core/Permissions/PermissionsConfigurationTable.vue +0 -185
- package/lib/TableViewer/core/Permissions/PermissionsTable.vue +0 -207
- package/lib/TableViewer/core/Queries/QueriesMenu.vue +0 -75
- package/lib/TableViewer/core/Records/RecordDialog.vue +0 -128
- package/lib/TableViewer/core/Relations/RelationForm.vue +0 -154
- package/lib/TableViewer/core/Relations/RelationsConfiguration.vue +0 -32
- package/lib/TableViewer/core/Relations/RelationsConfigurationTable.vue +0 -146
- package/lib/TableViewer/core/Relations/RelationsTable.vue +0 -129
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { Permission } from '@antcde/connect-ts/services/PermissionService'
|
|
3
|
-
import BaseClickableIcon from '@/components/BaseClickableIcon.vue'
|
|
4
|
-
import { onMounted, ref } from 'vue'
|
|
5
|
-
import { useI18n } from 'vue-i18n'
|
|
6
|
-
import PermissionDialog from '../Permissions/PermissionDialog.vue'
|
|
7
|
-
|
|
8
|
-
const { t } = useI18n()
|
|
9
|
-
|
|
10
|
-
interface ColumnHeader {
|
|
11
|
-
title: string
|
|
12
|
-
key: string
|
|
13
|
-
align?: 'start' | 'center' | 'end'
|
|
14
|
-
sortable?: boolean
|
|
15
|
-
hasSlot?: boolean
|
|
16
|
-
checkbox?: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type PermissionHeader = ColumnHeader & {
|
|
20
|
-
title: 'role' | 'read' | 'create' | 'update' | 'delete' | 'configure' | 'Actions'
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const roleStore = useRoleStore()
|
|
24
|
-
const permissionStore = usePermissionStore()
|
|
25
|
-
const projectStore = useProjectStore()
|
|
26
|
-
|
|
27
|
-
onMounted(() => {
|
|
28
|
-
permissionStore.fetchPermissions()
|
|
29
|
-
roleStore.fetchRoles(projectStore.project?.id as string)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const permissionHeaders: PermissionHeader[] = [
|
|
33
|
-
{
|
|
34
|
-
title: 'role',
|
|
35
|
-
key: 'role',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
title: 'read',
|
|
39
|
-
key: 'read',
|
|
40
|
-
sortable: false,
|
|
41
|
-
checkbox: true,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
title: 'create',
|
|
45
|
-
key: 'create',
|
|
46
|
-
sortable: false,
|
|
47
|
-
checkbox: true,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: 'update',
|
|
51
|
-
key: 'update',
|
|
52
|
-
sortable: false,
|
|
53
|
-
checkbox: true,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
title: 'delete',
|
|
57
|
-
key: 'delete',
|
|
58
|
-
sortable: false,
|
|
59
|
-
checkbox: true,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
title: 'configure',
|
|
63
|
-
key: 'configure',
|
|
64
|
-
sortable: false,
|
|
65
|
-
checkbox: true,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
title: 'Actions',
|
|
69
|
-
key: 'actions',
|
|
70
|
-
align: 'end',
|
|
71
|
-
sortable: false,
|
|
72
|
-
},
|
|
73
|
-
]
|
|
74
|
-
|
|
75
|
-
const permissionToDelete = ref<Permission | null>(null)
|
|
76
|
-
const permissionDeleteDialog = ref(false)
|
|
77
|
-
|
|
78
|
-
function setupPermissionDelete(item: Permission) {
|
|
79
|
-
permissionToDelete.value = item
|
|
80
|
-
permissionDeleteDialog.value = true
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function closePermissionDeleteDialog() {
|
|
84
|
-
permissionDeleteDialog.value = false
|
|
85
|
-
permissionToDelete.value = null
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function deletePermission() {
|
|
89
|
-
if (permissionToDelete.value) {
|
|
90
|
-
await permissionStore.deletePermission(permissionToDelete.value)
|
|
91
|
-
closePermissionDeleteDialog()
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const permissionToUpdate = ref<Permission | null>(null)
|
|
96
|
-
|
|
97
|
-
async function updatePermission() {
|
|
98
|
-
if (permissionToUpdate.value) {
|
|
99
|
-
await permissionStore.updatePermission({
|
|
100
|
-
...permissionToUpdate.value,
|
|
101
|
-
role_id: permissionToUpdate.value.role.id,
|
|
102
|
-
table_id: permissionToUpdate.value.table,
|
|
103
|
-
})
|
|
104
|
-
permissionToUpdate.value = null
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const permissionDialog = ref(false)
|
|
109
|
-
</script>
|
|
110
|
-
|
|
111
|
-
<template>
|
|
112
|
-
<v-data-table
|
|
113
|
-
:headers="permissionHeaders"
|
|
114
|
-
:items="permissionStore.permissions"
|
|
115
|
-
:loading="permissionStore.isFetching"
|
|
116
|
-
color="primary"
|
|
117
|
-
density="compact"
|
|
118
|
-
>
|
|
119
|
-
<template #[`item.role`]="{ item }">
|
|
120
|
-
{{ item.role.name }}
|
|
121
|
-
</template>
|
|
122
|
-
<template
|
|
123
|
-
v-for="header in permissionHeaders.filter(h => h.checkbox)"
|
|
124
|
-
:key="header.key"
|
|
125
|
-
#[`item.${header.key}`]="{ item }"
|
|
126
|
-
>
|
|
127
|
-
<v-checkbox-btn
|
|
128
|
-
v-model="item[header.key as keyof Permission]"
|
|
129
|
-
:disabled="item.id !== permissionToUpdate?.id"
|
|
130
|
-
/>
|
|
131
|
-
</template>
|
|
132
|
-
<template #[`item.actions`]="{ item }">
|
|
133
|
-
<BaseClickableIcon
|
|
134
|
-
v-if="item.id === permissionToUpdate?.id"
|
|
135
|
-
:loading="permissionStore.isUpdating"
|
|
136
|
-
:tooltip-text="t('system.buttons.save')"
|
|
137
|
-
icon="mdi-content-save"
|
|
138
|
-
size="x-small"
|
|
139
|
-
tooltip-location="start"
|
|
140
|
-
@click="updatePermission"
|
|
141
|
-
/>
|
|
142
|
-
<BaseClickableIcon
|
|
143
|
-
v-else
|
|
144
|
-
:tooltip-text="t('system.buttons.edit')"
|
|
145
|
-
icon="mdi-pencil"
|
|
146
|
-
size="x-small"
|
|
147
|
-
tooltip-location="start"
|
|
148
|
-
@click="permissionToUpdate = item"
|
|
149
|
-
/>
|
|
150
|
-
|
|
151
|
-
<BaseClickableIcon
|
|
152
|
-
:tooltip-text="t('system.buttons.delete')"
|
|
153
|
-
icon="mdi-delete"
|
|
154
|
-
size="x-small"
|
|
155
|
-
tooltip-location="start"
|
|
156
|
-
@click="setupPermissionDelete(item)"
|
|
157
|
-
/>
|
|
158
|
-
</template>
|
|
159
|
-
<template #top>
|
|
160
|
-
<v-toolbar density="compact">
|
|
161
|
-
<v-toolbar-title>{{ t('project.tableConfig.permissions.title') }}</v-toolbar-title>
|
|
162
|
-
<v-spacer />
|
|
163
|
-
<base-delete-dialog
|
|
164
|
-
:delete-action="deletePermission"
|
|
165
|
-
:displayed="permissionDeleteDialog"
|
|
166
|
-
:is-loading="permissionStore.isDeleting"
|
|
167
|
-
:title="
|
|
168
|
-
t('project.tableConfig.permissions.deleteTitle', {
|
|
169
|
-
role: permissionToDelete?.role?.name,
|
|
170
|
-
})
|
|
171
|
-
"
|
|
172
|
-
@close="closePermissionDeleteDialog"
|
|
173
|
-
/>
|
|
174
|
-
<BaseClickableIcon
|
|
175
|
-
id="ant-tour-create-permission"
|
|
176
|
-
:tooltip-text="t('project.tableConfig.permissions.newPermission')"
|
|
177
|
-
icon="mdi-plus"
|
|
178
|
-
tooltip-location="start"
|
|
179
|
-
@click="permissionDialog = true"
|
|
180
|
-
/>
|
|
181
|
-
<PermissionDialog :display-dialog="permissionDialog" @close="permissionDialog = false" />
|
|
182
|
-
</v-toolbar>
|
|
183
|
-
</template>
|
|
184
|
-
</v-data-table>
|
|
185
|
-
</template>
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Permission } from '@antcde/connect-ts/services/PermissionService'
|
|
3
|
-
import { storeToRefs } from 'pinia'
|
|
4
|
-
import { ref } from 'vue'
|
|
5
|
-
import { useI18n } from 'vue-i18n'
|
|
6
|
-
import { usePermissionStore } from '../../stores/permissions'
|
|
7
|
-
|
|
8
|
-
const { t } = useI18n()
|
|
9
|
-
|
|
10
|
-
defineProps<{
|
|
11
|
-
roles: any[]
|
|
12
|
-
}>()
|
|
13
|
-
const emit = defineEmits(['openPermissionCreate', 'close'])
|
|
14
|
-
|
|
15
|
-
const permissionStore = usePermissionStore()
|
|
16
|
-
|
|
17
|
-
const { isDeleting, isFetching, isUpdating, permissions } = storeToRefs(permissionStore)
|
|
18
|
-
|
|
19
|
-
interface PermissionHeader {
|
|
20
|
-
title: string
|
|
21
|
-
key: string
|
|
22
|
-
align?: 'start' | 'center' | 'end'
|
|
23
|
-
sortable?: boolean
|
|
24
|
-
hasSlot?: boolean
|
|
25
|
-
checkbox?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const permissionHeaders: PermissionHeader[] = [
|
|
29
|
-
{
|
|
30
|
-
title: t('project.tableConfig.permissions.role'),
|
|
31
|
-
key: 'role',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
title: t('project.tableConfig.permissions.read'),
|
|
35
|
-
key: 'read',
|
|
36
|
-
sortable: false,
|
|
37
|
-
checkbox: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
title: t('project.tableConfig.permissions.create'),
|
|
41
|
-
key: 'create',
|
|
42
|
-
sortable: false,
|
|
43
|
-
checkbox: true,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
title: t('project.tableConfig.permissions.update'),
|
|
47
|
-
key: 'update',
|
|
48
|
-
sortable: false,
|
|
49
|
-
checkbox: true,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
title: t('project.tableConfig.permissions.delete'),
|
|
53
|
-
key: 'delete',
|
|
54
|
-
sortable: false,
|
|
55
|
-
checkbox: true,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
title: t('project.tableConfig.permissions.configure'),
|
|
59
|
-
key: 'configure',
|
|
60
|
-
sortable: false,
|
|
61
|
-
checkbox: true,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
title: t('system.actions'),
|
|
65
|
-
key: 'actions',
|
|
66
|
-
align: 'end',
|
|
67
|
-
sortable: false,
|
|
68
|
-
},
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
const selectedPermission = ref<Permission | null>(null)
|
|
72
|
-
const isDeleteConfirmationShown = ref(false)
|
|
73
|
-
|
|
74
|
-
function setupPermissionUpdate(item: Permission) {
|
|
75
|
-
selectedPermission.value = item
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function setupPermissionDelete(item: Permission) {
|
|
79
|
-
selectedPermission.value = item
|
|
80
|
-
isDeleteConfirmationShown.value = true
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function deletePermission() {
|
|
84
|
-
if (selectedPermission.value) {
|
|
85
|
-
await permissionStore.deletePermission(selectedPermission.value)
|
|
86
|
-
closePermissionDeleteDialog()
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function closePermissionDeleteDialog() {
|
|
91
|
-
isDeleteConfirmationShown.value = false
|
|
92
|
-
selectedPermission.value = null
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function updatePermission() {
|
|
96
|
-
if (selectedPermission.value) {
|
|
97
|
-
await permissionStore.updatePermission({
|
|
98
|
-
...selectedPermission.value,
|
|
99
|
-
role_id: selectedPermission.value.role.id,
|
|
100
|
-
table_id: selectedPermission.value.table,
|
|
101
|
-
})
|
|
102
|
-
selectedPermission.value = null
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
</script>
|
|
106
|
-
|
|
107
|
-
<template>
|
|
108
|
-
<base-delete-dialog
|
|
109
|
-
:delete-action="deletePermission"
|
|
110
|
-
:displayed="isDeleteConfirmationShown"
|
|
111
|
-
:is-loading="isDeleting"
|
|
112
|
-
:title="
|
|
113
|
-
t('project.tableConfig.permissions.deleteTitle', {
|
|
114
|
-
role: selectedPermission?.role?.name,
|
|
115
|
-
})
|
|
116
|
-
"
|
|
117
|
-
@close="closePermissionDeleteDialog"
|
|
118
|
-
/>
|
|
119
|
-
|
|
120
|
-
<v-toolbar color="primary" class="px-0" density="compact">
|
|
121
|
-
<v-toolbar-title>{{ t('project.tableConfig.permissions.title') }}</v-toolbar-title>
|
|
122
|
-
<v-spacer />
|
|
123
|
-
|
|
124
|
-
<v-toolbar-items>
|
|
125
|
-
<v-btn
|
|
126
|
-
v-if="roles.length > 0"
|
|
127
|
-
v-tooltip="t('project.tableConfig.permissions.newPermission')"
|
|
128
|
-
icon="mdi-plus"
|
|
129
|
-
@click="emit('openPermissionCreate')"
|
|
130
|
-
/>
|
|
131
|
-
<v-btn
|
|
132
|
-
v-tooltip="t('system.buttons.close')"
|
|
133
|
-
icon="mdi-close"
|
|
134
|
-
@click="emit('close')"
|
|
135
|
-
/>
|
|
136
|
-
</v-toolbar-items>
|
|
137
|
-
</v-toolbar>
|
|
138
|
-
|
|
139
|
-
<v-data-table
|
|
140
|
-
class="h-full overflow-auto"
|
|
141
|
-
fixed-header
|
|
142
|
-
hide-default-footer
|
|
143
|
-
:headers="permissionHeaders"
|
|
144
|
-
:items="permissions"
|
|
145
|
-
:loading="isFetching"
|
|
146
|
-
:items-per-page="permissions.length"
|
|
147
|
-
density="compact"
|
|
148
|
-
>
|
|
149
|
-
<template #[`item.role`]="{ item }">
|
|
150
|
-
{{ item.role.name }}
|
|
151
|
-
</template>
|
|
152
|
-
|
|
153
|
-
<template
|
|
154
|
-
v-for="header in permissionHeaders.filter((h) => h.checkbox)"
|
|
155
|
-
:key="header.key"
|
|
156
|
-
#[`item.${header.key}`]="{ item }"
|
|
157
|
-
>
|
|
158
|
-
<v-checkbox-btn
|
|
159
|
-
v-if="item.id === selectedPermission?.id && !isDeleteConfirmationShown"
|
|
160
|
-
v-model="item[header.key as keyof Permission]"
|
|
161
|
-
density="compact"
|
|
162
|
-
/>
|
|
163
|
-
<v-icon
|
|
164
|
-
v-else
|
|
165
|
-
class="ml-1"
|
|
166
|
-
:icon="item[header.key as keyof Permission] ? 'mdi-check-bold' : 'mdi-close-thick'"
|
|
167
|
-
color="grey-darken-1"
|
|
168
|
-
/>
|
|
169
|
-
</template>
|
|
170
|
-
|
|
171
|
-
<!-- ACTIONS CELL -->
|
|
172
|
-
<template #[`item.actions`]="{ item }">
|
|
173
|
-
<v-btn
|
|
174
|
-
v-if="item.id === selectedPermission?.id && !isDeleteConfirmationShown"
|
|
175
|
-
v-tooltip="t('system.buttons.save')"
|
|
176
|
-
:disabled="isUpdating"
|
|
177
|
-
icon="mdi-content-save"
|
|
178
|
-
size="small"
|
|
179
|
-
variant="text"
|
|
180
|
-
color="grey-darken-1"
|
|
181
|
-
tooltip-location="start"
|
|
182
|
-
@click="updatePermission"
|
|
183
|
-
/>
|
|
184
|
-
|
|
185
|
-
<v-btn
|
|
186
|
-
v-else
|
|
187
|
-
v-tooltip="t('system.buttons.edit')"
|
|
188
|
-
icon="mdi-pencil"
|
|
189
|
-
size="small"
|
|
190
|
-
variant="text"
|
|
191
|
-
color="grey-darken-1"
|
|
192
|
-
tooltip-location="start"
|
|
193
|
-
@click="setupPermissionUpdate(item)"
|
|
194
|
-
/>
|
|
195
|
-
|
|
196
|
-
<v-btn
|
|
197
|
-
v-tooltip="t('system.buttons.delete')"
|
|
198
|
-
icon="mdi-delete"
|
|
199
|
-
size="small"
|
|
200
|
-
variant="text"
|
|
201
|
-
color="grey-darken-1"
|
|
202
|
-
tooltip-location="start"
|
|
203
|
-
@click="setupPermissionDelete(item)"
|
|
204
|
-
/>
|
|
205
|
-
</template>
|
|
206
|
-
</v-data-table>
|
|
207
|
-
</template>
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { TableQueryColumn } from '@antcde/connect-ts/services/TableQueryService'
|
|
3
|
-
import { storeToRefs } from 'pinia'
|
|
4
|
-
import { ref } from 'vue'
|
|
5
|
-
import { useI18n } from 'vue-i18n'
|
|
6
|
-
import { useQueryStore } from '../../stores/queries'
|
|
7
|
-
import { useRecordStore } from '../../stores/records'
|
|
8
|
-
import QueryItem from './QueryItem.vue'
|
|
9
|
-
|
|
10
|
-
const { t } = useI18n()
|
|
11
|
-
|
|
12
|
-
const queryStore = useQueryStore()
|
|
13
|
-
const recordStore = useRecordStore()
|
|
14
|
-
|
|
15
|
-
const { queries, isCreating } = storeToRefs(queryStore)
|
|
16
|
-
const { queryPayload } = storeToRefs(recordStore)
|
|
17
|
-
|
|
18
|
-
const queryName = ref('')
|
|
19
|
-
|
|
20
|
-
function createQuery() {
|
|
21
|
-
console.log('createQuery---->')
|
|
22
|
-
if (!queryName.value) {
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
queryStore.createQuery(
|
|
26
|
-
queryName.value,
|
|
27
|
-
(queryPayload.value?.tables[0]?.columns as TableQueryColumn[]) ?? [],
|
|
28
|
-
)
|
|
29
|
-
queryName.value = ''
|
|
30
|
-
}
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<template>
|
|
34
|
-
<v-menu :close-on-content-click="false">
|
|
35
|
-
<template #activator="{ props: activatorProps }">
|
|
36
|
-
<v-btn size="small" v-bind="activatorProps" icon="mdi-database-search" />
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<v-card class="min-w-[150px]">
|
|
40
|
-
<v-text-field
|
|
41
|
-
v-model="queryName"
|
|
42
|
-
:label="t('project.tableConfig.queries.name')"
|
|
43
|
-
:placeholder="t('project.tableConfig.queries.newQuery')"
|
|
44
|
-
color="primary"
|
|
45
|
-
hide-details
|
|
46
|
-
@keydown.enter="createQuery"
|
|
47
|
-
>
|
|
48
|
-
<template #append-inner>
|
|
49
|
-
<v-progress-circular
|
|
50
|
-
v-if="isCreating"
|
|
51
|
-
size="small"
|
|
52
|
-
color="grey-darken-2"
|
|
53
|
-
indeterminate
|
|
54
|
-
/>
|
|
55
|
-
<v-btn
|
|
56
|
-
v-else
|
|
57
|
-
variant="text"
|
|
58
|
-
size="small"
|
|
59
|
-
icon="mdi-content-save-check-outline"
|
|
60
|
-
color="grey-darken-2"
|
|
61
|
-
@click="createQuery"
|
|
62
|
-
/>
|
|
63
|
-
</template>
|
|
64
|
-
</v-text-field>
|
|
65
|
-
<v-divider />
|
|
66
|
-
<v-card-text>
|
|
67
|
-
<v-expansion-panels class="w-[400px]">
|
|
68
|
-
<query-item v-for="query in queries" :key="query.id" :query="query" />
|
|
69
|
-
</v-expansion-panels>
|
|
70
|
-
</v-card-text>
|
|
71
|
-
</v-card>
|
|
72
|
-
</v-menu>
|
|
73
|
-
</template>
|
|
74
|
-
|
|
75
|
-
<style scoped></style>
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { Column } from '@antcde/connect-ts/services/ColumnService'
|
|
3
|
-
import type { TableRecord } from '@antcde/connect-ts/services/TableService'
|
|
4
|
-
import { storeToRefs } from 'pinia'
|
|
5
|
-
import { computed, ref, watchEffect } from 'vue'
|
|
6
|
-
import { useI18n } from 'vue-i18n'
|
|
7
|
-
import { parseRecordBody, validateEmail } from '../../composables/records'
|
|
8
|
-
|
|
9
|
-
import { useColumnStore } from '../../stores/columns'
|
|
10
|
-
import { useRecordStore } from '../../stores/records'
|
|
11
|
-
import RecordInput from '../Records/RecordInput.vue'
|
|
12
|
-
|
|
13
|
-
const props = defineProps<{
|
|
14
|
-
displayDialog: boolean
|
|
15
|
-
record?: TableRecord | null
|
|
16
|
-
}>()
|
|
17
|
-
|
|
18
|
-
const emit = defineEmits(['close'])
|
|
19
|
-
|
|
20
|
-
const { t } = useI18n()
|
|
21
|
-
|
|
22
|
-
const recordStore = useRecordStore()
|
|
23
|
-
const columnStore = useColumnStore()
|
|
24
|
-
|
|
25
|
-
const { isUpdating, isCreating } = storeToRefs(recordStore)
|
|
26
|
-
|
|
27
|
-
const { columns } = storeToRefs(columnStore)
|
|
28
|
-
|
|
29
|
-
const recordItem = ref<TableRecord>({
|
|
30
|
-
id: '-1',
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const isLoading = computed(() => isUpdating.value || isCreating.value)
|
|
34
|
-
const isValid = computed(() => columns.value.every(column => validateColumnValue(column, recordItem.value[column.name])))
|
|
35
|
-
|
|
36
|
-
function validateColumnValue(column: Column, value: any) {
|
|
37
|
-
if (column.required && !value) {
|
|
38
|
-
return false
|
|
39
|
-
}
|
|
40
|
-
if (column.type === 'email') {
|
|
41
|
-
return value ? validateEmail(value) : true
|
|
42
|
-
}
|
|
43
|
-
return true
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function saveRecord() {
|
|
47
|
-
const body = await parseRecordBody(columns.value, recordItem.value)
|
|
48
|
-
try {
|
|
49
|
-
if (recordItem.value.id !== '-1') {
|
|
50
|
-
await recordStore.updateRecord(recordItem.value.id, body)
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
await recordStore.createRecord(body)
|
|
54
|
-
}
|
|
55
|
-
closeDialog()
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
console.error(e)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
watchEffect(async () => recordItem.value = props.record ? { ...props.record } : { id: '-1' })
|
|
63
|
-
|
|
64
|
-
function closeDialog() {
|
|
65
|
-
recordItem.value = {
|
|
66
|
-
id: '-1',
|
|
67
|
-
}
|
|
68
|
-
emit('close')
|
|
69
|
-
}
|
|
70
|
-
</script>
|
|
71
|
-
|
|
72
|
-
<template>
|
|
73
|
-
<v-dialog
|
|
74
|
-
:model-value="displayDialog"
|
|
75
|
-
width="800"
|
|
76
|
-
height="600"
|
|
77
|
-
@update:model-value="closeDialog"
|
|
78
|
-
>
|
|
79
|
-
<v-card class="d-flex">
|
|
80
|
-
<v-toolbar color="primary" density="compact">
|
|
81
|
-
<v-toolbar-title>{{ t(recordItem.id !== '-1' ? 'project.records.dialog.updateTitle' : 'project.records.dialog.createTitle') }}</v-toolbar-title>
|
|
82
|
-
|
|
83
|
-
<v-spacer />
|
|
84
|
-
|
|
85
|
-
<v-toolbar-items>
|
|
86
|
-
<v-btn
|
|
87
|
-
icon="mdi-close"
|
|
88
|
-
@click="emit('close')"
|
|
89
|
-
/>
|
|
90
|
-
</v-toolbar-items>
|
|
91
|
-
</v-toolbar>
|
|
92
|
-
<v-card-text class="flex-1 d-flex flex-col gap-1 overflow-auto">
|
|
93
|
-
<record-input
|
|
94
|
-
v-for="column in columns"
|
|
95
|
-
:key="column.id"
|
|
96
|
-
v-model="recordItem[column.name]"
|
|
97
|
-
:column="column"
|
|
98
|
-
:hide-label="false"
|
|
99
|
-
/>
|
|
100
|
-
</v-card-text>
|
|
101
|
-
<v-divider />
|
|
102
|
-
<v-card-actions>
|
|
103
|
-
<v-spacer />
|
|
104
|
-
<v-btn
|
|
105
|
-
:disabled="isLoading"
|
|
106
|
-
size="small"
|
|
107
|
-
variant="text"
|
|
108
|
-
color="primary"
|
|
109
|
-
@click="emit('close')"
|
|
110
|
-
>
|
|
111
|
-
{{ t('system.buttons.cancel') }}
|
|
112
|
-
</v-btn>
|
|
113
|
-
<v-btn
|
|
114
|
-
:disabled="isLoading || !isValid"
|
|
115
|
-
:loading="isLoading"
|
|
116
|
-
color="primary"
|
|
117
|
-
size="small"
|
|
118
|
-
variant="flat"
|
|
119
|
-
@click="saveRecord"
|
|
120
|
-
>
|
|
121
|
-
{{ t('system.buttons.save') }}
|
|
122
|
-
</v-btn>
|
|
123
|
-
</v-card-actions>
|
|
124
|
-
</v-card>
|
|
125
|
-
</v-dialog>
|
|
126
|
-
</template>
|
|
127
|
-
|
|
128
|
-
<style lang="scss" scoped></style>
|