@antcde/component-library 0.1.1 → 0.1.2
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/README.md +6 -0
- package/dist/component-library.css +1 -1
- package/dist/index.js +17133 -18175
- package/dist/types/components/BaseAppCard.vue.d.ts +18 -4
- package/dist/types/components/BaseAppCardSkeleton.vue.d.ts +2 -0
- package/dist/types/components/BaseDeleteDialog.vue.d.ts +20 -7
- package/dist/types/components/RBAC/Permissions/PermissionCard.vue.d.ts +1 -1
- package/dist/types/components/TasksFlow/useTaskFlow.d.ts +7 -5
- package/dist/types/index.d.ts +3 -1
- package/lib/DocumentManager/DocumentDrop.vue +2 -6
- package/lib/DocumentManager/DocumentManager.vue +45 -43
- package/lib/DocumentManager/hooks/useDms.ts +1 -3
- package/lib/DocumentManager/index.ts +1 -1
- package/lib/DocumentManager/lang/translations/de.json +36 -0
- package/lib/DocumentManager/lang/translations/en.json +38 -0
- package/lib/DocumentManager/lang/translations/nl.json +36 -0
- package/lib/DocumentManager/utils.ts +1 -1
- package/lib/ForgeViewer/ForgeViewer.vue +6 -5
- package/lib/ForgeViewer/lang/translations/de.json +6 -0
- package/lib/ForgeViewer/lang/translations/en.json +6 -0
- package/lib/ForgeViewer/lang/translations/nl.json +6 -0
- package/lib/ForgeViewer/useForgeViewer.ts +0 -1
- package/lib/GisViewer/GisViewer.vue +14 -8
- package/lib/GisViewer/useGisViewer.ts +3 -3
- package/package.json +4 -3
- package/lib/TableViewer/TableViewer.vue +0 -79
- package/lib/TableViewer/composables/columns.ts +0 -51
- package/lib/TableViewer/composables/records.ts +0 -70
- package/lib/TableViewer/composables/relations.ts +0 -8
- package/lib/TableViewer/composables/useFile.ts +0 -20
- package/lib/TableViewer/core/Columns/ColumnForm.vue +0 -443
- package/lib/TableViewer/core/Columns/ColumnItem.vue +0 -225
- package/lib/TableViewer/core/Columns/ColumnsList.vue +0 -142
- package/lib/TableViewer/core/Columns/ForeignKeyColumnItem.vue +0 -165
- package/lib/TableViewer/core/Columns/ForeignKeyColumnsList.vue +0 -55
- package/lib/TableViewer/core/Dialog/DeleteConfirmationDialog.vue +0 -63
- package/lib/TableViewer/core/Filters/ConditionItem.vue +0 -133
- package/lib/TableViewer/core/Filters/ConditionsList.vue +0 -53
- package/lib/TableViewer/core/Filters/FiltersEditor.vue +0 -48
- package/lib/TableViewer/core/Filters/QueriesList.vue +0 -63
- package/lib/TableViewer/core/Filters/QueryItem.vue +0 -112
- package/lib/TableViewer/core/Records/RecordCell.vue +0 -108
- package/lib/TableViewer/core/Records/RecordForm.vue +0 -146
- package/lib/TableViewer/core/Records/RecordHeader.vue +0 -82
- package/lib/TableViewer/core/Records/RecordInput.vue +0 -234
- package/lib/TableViewer/core/Records/RecordValue.vue +0 -170
- package/lib/TableViewer/core/Records/RecordsTable.vue +0 -274
- package/lib/TableViewer/core/Records/RecordsTableToolbar.vue +0 -210
- package/lib/TableViewer/core/Revisions/RevisionComparisonCell.vue +0 -50
- package/lib/TableViewer/core/Revisions/RevisionComparisonTable.vue +0 -98
- package/lib/TableViewer/core/Revisions/RevisionHistory.vue +0 -156
- package/lib/TableViewer/core/Revisions/RevisionSelector.vue +0 -140
- package/lib/TableViewer/core/Tables/TableEditor.vue +0 -136
- package/lib/TableViewer/core/Tables/TableItem.vue +0 -162
- package/lib/TableViewer/core/Tables/TableViewer.vue +0 -28
- package/lib/TableViewer/core/Tables/TablesList.vue +0 -116
- package/lib/TableViewer/index.ts +0 -4
- package/lib/TableViewer/services/file-handler.ts +0 -84
- package/lib/TableViewer/stores/client.ts +0 -18
- package/lib/TableViewer/stores/columnRelation.ts +0 -106
- package/lib/TableViewer/stores/columns.ts +0 -171
- package/lib/TableViewer/stores/conditions.ts +0 -86
- package/lib/TableViewer/stores/permissions.ts +0 -102
- package/lib/TableViewer/stores/queries.ts +0 -80
- package/lib/TableViewer/stores/records.ts +0 -325
- package/lib/TableViewer/stores/relations.ts +0 -89
- package/lib/TableViewer/stores/revisions.ts +0 -194
- package/lib/TableViewer/stores/roles.ts +0 -109
- package/lib/TableViewer/stores/table.ts +0 -130
- package/lib/TableViewer/stores/tables.ts +0 -65
- package/lib/TableViewer/types/app.d.ts +0 -5
- package/lib/TableViewer/types/column.d.ts +0 -28
- package/lib/TableViewer/types/permission.d.ts +0 -12
- package/lib/TableViewer/types/project.d.ts +0 -37
- package/lib/TableViewer/types/relations.d.ts +0 -7
- package/lib/TableViewer/types/tables.d.ts +0 -69
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { Column, SbsRecord } from '@antcde/connect-ts'
|
|
3
|
-
import { useDebounceFn } from '@vueuse/core'
|
|
4
|
-
import { storeToRefs } from 'pinia'
|
|
5
|
-
import { computed, onMounted, ref } from 'vue'
|
|
6
|
-
import { useI18n } from 'vue-i18n'
|
|
7
|
-
import { useClientStore } from '../../stores/client'
|
|
8
|
-
import { useColumnRelationStore } from '../../stores/columnRelation'
|
|
9
|
-
import { useTableStore } from '../../stores/table'
|
|
10
|
-
import { useTablesStore } from '../../stores/tables'
|
|
11
|
-
|
|
12
|
-
const props = defineProps<{
|
|
13
|
-
column: Column
|
|
14
|
-
isLoading?: boolean
|
|
15
|
-
inputProps?: any
|
|
16
|
-
events?: any
|
|
17
|
-
hideLabel: boolean
|
|
18
|
-
}>()
|
|
19
|
-
|
|
20
|
-
const { t } = useI18n()
|
|
21
|
-
|
|
22
|
-
const model = defineModel()
|
|
23
|
-
|
|
24
|
-
const tableStore = useTableStore()
|
|
25
|
-
const tablesStore = useTablesStore()
|
|
26
|
-
const clientStore = useClientStore()
|
|
27
|
-
const columnRelationStore = useColumnRelationStore()
|
|
28
|
-
|
|
29
|
-
const sbsRecords = ref<SbsRecord[]>([])
|
|
30
|
-
const isLoadingSbs = ref(false)
|
|
31
|
-
const options = ref<any[]>([])
|
|
32
|
-
|
|
33
|
-
const { client } = storeToRefs(clientStore)
|
|
34
|
-
const { table } = storeToRefs(tableStore)
|
|
35
|
-
const { tables } = storeToRefs(tablesStore)
|
|
36
|
-
|
|
37
|
-
const hasRelation = computed(() => props.column.type === 'uuid' && props.column.column_relation)
|
|
38
|
-
|
|
39
|
-
const serverSideFilter = computed(() => !['user', 'table'].includes(props.column.column_relation?.related_entity ?? ''))
|
|
40
|
-
|
|
41
|
-
const inputComponent = computed(() => {
|
|
42
|
-
switch (props.column.type) {
|
|
43
|
-
case 'text':
|
|
44
|
-
case 'integer':
|
|
45
|
-
case 'link':
|
|
46
|
-
case 'float':
|
|
47
|
-
case 'email':
|
|
48
|
-
return 'v-text-field'
|
|
49
|
-
case 'text-field':
|
|
50
|
-
return 'v-textarea'
|
|
51
|
-
case 'boolean':
|
|
52
|
-
return 'v-checkbox'
|
|
53
|
-
case 'dropdown':
|
|
54
|
-
case 'table':
|
|
55
|
-
case 'sbscode':
|
|
56
|
-
return 'v-autocomplete'
|
|
57
|
-
case 'document':
|
|
58
|
-
return 'v-file-input'
|
|
59
|
-
case 'date':
|
|
60
|
-
return 'v-date-input'
|
|
61
|
-
case 'uuid':
|
|
62
|
-
return hasRelation.value ? 'v-autocomplete' : 'v-text-field'
|
|
63
|
-
default:
|
|
64
|
-
return 'v-text-field'
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
const inputProps = computed(() => {
|
|
69
|
-
let defaultProps: any = {
|
|
70
|
-
variant: 'outlined',
|
|
71
|
-
color: 'primary',
|
|
72
|
-
density: 'compact',
|
|
73
|
-
placeholder: convertToTitleCase(props.column.name),
|
|
74
|
-
autocomplete: 'none',
|
|
75
|
-
hideDetails: props.hideLabel,
|
|
76
|
-
}
|
|
77
|
-
switch (props.column.type) {
|
|
78
|
-
case 'email':
|
|
79
|
-
defaultProps = {
|
|
80
|
-
...defaultProps,
|
|
81
|
-
type: 'email',
|
|
82
|
-
}
|
|
83
|
-
break
|
|
84
|
-
case 'integer':
|
|
85
|
-
case 'float':
|
|
86
|
-
defaultProps = {
|
|
87
|
-
...defaultProps,
|
|
88
|
-
type: 'number',
|
|
89
|
-
}
|
|
90
|
-
break
|
|
91
|
-
case 'table':
|
|
92
|
-
defaultProps = {
|
|
93
|
-
...defaultProps,
|
|
94
|
-
items: tables.value,
|
|
95
|
-
itemTitle: 'name',
|
|
96
|
-
itemValue: 'id',
|
|
97
|
-
}
|
|
98
|
-
break
|
|
99
|
-
case 'dropdown':
|
|
100
|
-
defaultProps = {
|
|
101
|
-
...defaultProps,
|
|
102
|
-
items: props.column.options_value || [],
|
|
103
|
-
}
|
|
104
|
-
break
|
|
105
|
-
case 'sbscode':
|
|
106
|
-
defaultProps = {
|
|
107
|
-
...defaultProps,
|
|
108
|
-
noFilter: true,
|
|
109
|
-
items: sbsRecords.value,
|
|
110
|
-
loading: isLoadingSbs.value,
|
|
111
|
-
itemTitle: 'code',
|
|
112
|
-
itemValue: 'code',
|
|
113
|
-
}
|
|
114
|
-
break
|
|
115
|
-
case 'uuid':
|
|
116
|
-
defaultProps = {
|
|
117
|
-
...defaultProps,
|
|
118
|
-
noFilter: serverSideFilter.value,
|
|
119
|
-
items: options.value,
|
|
120
|
-
itemTitle: props.column.column_relation?.display_label ?? 'id',
|
|
121
|
-
itemValue: 'id',
|
|
122
|
-
}
|
|
123
|
-
break
|
|
124
|
-
case 'date':
|
|
125
|
-
defaultProps = {
|
|
126
|
-
...defaultProps,
|
|
127
|
-
prependIcon: '',
|
|
128
|
-
prependInnerIcon: '$calendar',
|
|
129
|
-
}
|
|
130
|
-
break
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
...defaultProps,
|
|
135
|
-
...(props.inputProps ?? {}),
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
const debouncedChange = useDebounceFn((value: any) => searchRelationRecords(value), 800)
|
|
140
|
-
|
|
141
|
-
const inputEvents = computed(() => {
|
|
142
|
-
switch (props.column.type) {
|
|
143
|
-
case 'sbscode':
|
|
144
|
-
return {
|
|
145
|
-
'update:search': searchSearchSbs,
|
|
146
|
-
}
|
|
147
|
-
case 'uuid':
|
|
148
|
-
return {
|
|
149
|
-
'update:search': serverSideFilter.value ? debouncedChange : () => {},
|
|
150
|
-
}
|
|
151
|
-
default:
|
|
152
|
-
return {}
|
|
153
|
-
}
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
function validateEmail(value: any) {
|
|
157
|
-
const pattern = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/
|
|
158
|
-
return pattern.test(value) || 'Invalid e-mail.'
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function validateValue() {
|
|
162
|
-
if (props.column.required && !model.value) {
|
|
163
|
-
return 'This field is required'
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (props.column.type === 'email' && !validateEmail(model.value)) {
|
|
167
|
-
return 'Invalid email'
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return true
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// This function should be debounced
|
|
174
|
-
async function searchSearchSbs(searchTerm: string) {
|
|
175
|
-
const connect = client?.value?.connect
|
|
176
|
-
if (connect) {
|
|
177
|
-
isLoadingSbs.value = true
|
|
178
|
-
sbsRecords.value = table.value?.project
|
|
179
|
-
? await connect.sbs.searchSbs(table.value.project, searchTerm)
|
|
180
|
-
: []
|
|
181
|
-
isLoadingSbs.value = false
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async function searchRelationRecords(searchTerm: string) {
|
|
186
|
-
if (!props.column.column_relation)
|
|
187
|
-
return
|
|
188
|
-
const response = await columnRelationStore.getRelationOptions(
|
|
189
|
-
props.column.column_relation,
|
|
190
|
-
searchTerm,
|
|
191
|
-
)
|
|
192
|
-
options.value = response as any[]
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
onMounted(() => {
|
|
196
|
-
if (props.column.type === 'uuid' && props.column.column_relation) {
|
|
197
|
-
// searchRelationRecords('')
|
|
198
|
-
}
|
|
199
|
-
if (props.column.type === 'sbscode') {
|
|
200
|
-
// searchSearchSbs('')
|
|
201
|
-
}
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
function convertToTitleCase(str: string) {
|
|
205
|
-
return str
|
|
206
|
-
.split('_')
|
|
207
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
208
|
-
.join(' ')
|
|
209
|
-
}
|
|
210
|
-
</script>
|
|
211
|
-
|
|
212
|
-
<template>
|
|
213
|
-
<div class="d-flex flex-row" v-if="column">
|
|
214
|
-
<v-label v-if="!hideLabel" class="mb-2 font-semibold w-[200px]">
|
|
215
|
-
{{ convertToTitleCase(column.name) }}
|
|
216
|
-
<!-- <v-icon
|
|
217
|
-
v-if="column.required"
|
|
218
|
-
v-tooltip="t('project.tableConfig.columns.is_required')"
|
|
219
|
-
size="8"
|
|
220
|
-
color="error"
|
|
221
|
-
icon="mdi-asterisk"
|
|
222
|
-
/> -->
|
|
223
|
-
</v-label>
|
|
224
|
-
|
|
225
|
-
<component
|
|
226
|
-
:is="inputComponent"
|
|
227
|
-
v-model="model"
|
|
228
|
-
class="flex-grow flex-1"
|
|
229
|
-
:rules="[validateValue]"
|
|
230
|
-
v-bind="inputProps"
|
|
231
|
-
v-on="inputEvents"
|
|
232
|
-
/>
|
|
233
|
-
</div>
|
|
234
|
-
</template>
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Column } from '@antcde/connect-ts/services/ColumnService'
|
|
3
|
-
import dayjs from 'dayjs'
|
|
4
|
-
import { storeToRefs } from 'pinia'
|
|
5
|
-
import { computed } from 'vue'
|
|
6
|
-
import { useDownloadDocument } from '../../composables/useFile'
|
|
7
|
-
import { useClientStore } from '../../stores/client'
|
|
8
|
-
import { useColumnStore } from '../../stores/columns'
|
|
9
|
-
import { useTableStore } from '../../stores/table'
|
|
10
|
-
import { useTablesStore } from '../../stores/tables'
|
|
11
|
-
|
|
12
|
-
const props = defineProps<{
|
|
13
|
-
value: any
|
|
14
|
-
column: Column
|
|
15
|
-
recordId: string
|
|
16
|
-
}>()
|
|
17
|
-
|
|
18
|
-
const tableStore = useTableStore()
|
|
19
|
-
const tablesStore = useTablesStore()
|
|
20
|
-
const clientStore = useClientStore()
|
|
21
|
-
const columnStore = useColumnStore()
|
|
22
|
-
|
|
23
|
-
const { columnsConfiguration } = storeToRefs(columnStore)
|
|
24
|
-
const { client } = storeToRefs(clientStore)
|
|
25
|
-
const { table } = storeToRefs(tableStore)
|
|
26
|
-
const { tables } = storeToRefs(tablesStore) // FIXME Get tables locally to unlink stores
|
|
27
|
-
|
|
28
|
-
const tableId = computed(() => table.value?.id ?? null)
|
|
29
|
-
|
|
30
|
-
const linkedTable = computed(() =>
|
|
31
|
-
!!props.value && props.column.type === 'table'
|
|
32
|
-
? tables.value.find((t: { id: any }) => t.id === props.value)
|
|
33
|
-
: null,
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
// check if value is object and has a name property
|
|
37
|
-
const isObject = (value: any) => typeof value === 'object' && value !== null
|
|
38
|
-
|
|
39
|
-
const hasRelation = computed(
|
|
40
|
-
() => isObject(props.value) && props.column.type === 'uuid' && !!props.column.column_relation,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
const columnConfiguration = computed(() => columnsConfiguration.value.find(c => c.name === props.column.name))
|
|
44
|
-
|
|
45
|
-
const displayedValue = computed(() => {
|
|
46
|
-
const { type } = props.column
|
|
47
|
-
|
|
48
|
-
if (type === 'boolean') {
|
|
49
|
-
return !!props.value
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (type === 'table') {
|
|
53
|
-
return linkedTable.value?.name ?? null
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (type === 'document') {
|
|
57
|
-
return props.value ? `${props.value.name}.${props.value.extension}` : '-'
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (type === 'date') {
|
|
61
|
-
return props.value ? dayjs(props.value).format('MMMM D, YYYY') : '-'
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (hasRelation.value) {
|
|
65
|
-
return props.value[props.column.column_relation?.display_label ?? ''] ?? null
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return props.value
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
async function downloadDocument() {
|
|
72
|
-
if (!tableId.value || !props.recordId || !props.value.id || !client?.value?.connect) {
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
const document = await client.value.connect.records.getRecordDocument(
|
|
76
|
-
tableId.value,
|
|
77
|
-
props.recordId,
|
|
78
|
-
props.value.id,
|
|
79
|
-
)
|
|
80
|
-
await useDownloadDocument(document)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function openLinkedTable() {
|
|
84
|
-
if (!linkedTable.value) {
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
await tableStore.fetchTable(linkedTable.value.id)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function isEmpty(val: any) {
|
|
91
|
-
return val == null || val === '' // Checks explicitly for undefined, null, or empty string
|
|
92
|
-
}
|
|
93
|
-
</script>
|
|
94
|
-
|
|
95
|
-
<template>
|
|
96
|
-
<v-icon
|
|
97
|
-
v-if="column.type === 'boolean'"
|
|
98
|
-
:icon="!!value ? 'mdi-check-bold' : 'mdi-close-thick'"
|
|
99
|
-
color="grey-darken-1"
|
|
100
|
-
/>
|
|
101
|
-
|
|
102
|
-
<span v-else-if="isEmpty(displayedValue)">
|
|
103
|
-
{{ '-' }}
|
|
104
|
-
</span>
|
|
105
|
-
|
|
106
|
-
<v-btn
|
|
107
|
-
v-else-if="column.type === 'table'"
|
|
108
|
-
v-tooltip="displayedValue"
|
|
109
|
-
size="small"
|
|
110
|
-
variant="text"
|
|
111
|
-
color="grey-darken-1"
|
|
112
|
-
icon
|
|
113
|
-
@click="openLinkedTable"
|
|
114
|
-
>
|
|
115
|
-
<v-icon>mdi-table-arrow-right</v-icon>
|
|
116
|
-
</v-btn>
|
|
117
|
-
|
|
118
|
-
<v-btn
|
|
119
|
-
v-else-if="column.type === 'link'"
|
|
120
|
-
v-tooltip="displayedValue"
|
|
121
|
-
size="small"
|
|
122
|
-
variant="text"
|
|
123
|
-
color="grey-darken-1"
|
|
124
|
-
:href="value"
|
|
125
|
-
icon
|
|
126
|
-
>
|
|
127
|
-
<v-icon>mdi-link</v-icon>
|
|
128
|
-
</v-btn>
|
|
129
|
-
|
|
130
|
-
<v-btn
|
|
131
|
-
v-else-if="column.type === 'document'"
|
|
132
|
-
v-tooltip="displayedValue"
|
|
133
|
-
size="small"
|
|
134
|
-
variant="text"
|
|
135
|
-
color="grey-darken-1"
|
|
136
|
-
@click="downloadDocument"
|
|
137
|
-
>
|
|
138
|
-
<span class="pr-2">{{ displayedValue }}</span>
|
|
139
|
-
<v-icon>mdi-download</v-icon>
|
|
140
|
-
</v-btn>
|
|
141
|
-
|
|
142
|
-
<v-menu v-else-if="hasRelation" :close-on-content-click="false" location="bottom">
|
|
143
|
-
<template #activator="{ props }">
|
|
144
|
-
<v-btn v-bind="props" variant="tonal" size="small" append-icon="mdi-table-arrow-right">
|
|
145
|
-
{{ displayedValue }}
|
|
146
|
-
</v-btn>
|
|
147
|
-
</template>
|
|
148
|
-
|
|
149
|
-
<v-card min-width="300">
|
|
150
|
-
<v-table>
|
|
151
|
-
<tbody>
|
|
152
|
-
<tr v-for="key in (columnConfiguration?.relation?.fields ?? [])" :key="key">
|
|
153
|
-
<td class="font-bold">
|
|
154
|
-
{{ key }}
|
|
155
|
-
</td>
|
|
156
|
-
<td>
|
|
157
|
-
{{ value[key ?? ''] }}
|
|
158
|
-
</td>
|
|
159
|
-
</tr>
|
|
160
|
-
</tbody>
|
|
161
|
-
</v-table>
|
|
162
|
-
</v-card>
|
|
163
|
-
</v-menu>
|
|
164
|
-
|
|
165
|
-
<span v-else>
|
|
166
|
-
{{ displayedValue }}
|
|
167
|
-
</span>
|
|
168
|
-
</template>
|
|
169
|
-
|
|
170
|
-
<style lang="scss" scoped></style>
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
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, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
6
|
-
import { useColumnStore } from '../../stores/columns'
|
|
7
|
-
|
|
8
|
-
import { useRecordStore } from '../../stores/records'
|
|
9
|
-
import { useTableStore } from '../../stores/table'
|
|
10
|
-
import ColumnForm from '../Columns/ColumnForm.vue'
|
|
11
|
-
import DeleteConfirmationDialog from '../Dialog/DeleteConfirmationDialog.vue'
|
|
12
|
-
import FiltersEditor from '../Filters/FiltersEditor.vue'
|
|
13
|
-
import RecordCell from '../Records/RecordCell.vue'
|
|
14
|
-
import RecordHeader from '../Records/RecordHeader.vue'
|
|
15
|
-
import RevisionHistory from '../Revisions/RevisionHistory.vue'
|
|
16
|
-
import RecordForm from './RecordForm.vue'
|
|
17
|
-
|
|
18
|
-
const columnStore = useColumnStore()
|
|
19
|
-
const recordStore = useRecordStore()
|
|
20
|
-
const tableStore = useTableStore()
|
|
21
|
-
|
|
22
|
-
const { table } = storeToRefs(tableStore)
|
|
23
|
-
const { delete: canDelete, update: canUpdate } = table.value?.permissions ?? {}
|
|
24
|
-
|
|
25
|
-
const { columns, isFetching: isFetchingColumns } = storeToRefs(columnStore)
|
|
26
|
-
const {
|
|
27
|
-
records,
|
|
28
|
-
metadata,
|
|
29
|
-
recordsPerPage,
|
|
30
|
-
currentPage,
|
|
31
|
-
isFetching: isFetchingRecords,
|
|
32
|
-
selectedRecords,
|
|
33
|
-
editModeIsActive,
|
|
34
|
-
} = storeToRefs(recordStore)
|
|
35
|
-
|
|
36
|
-
const selectedRecord = ref<TableRecord | null>()
|
|
37
|
-
|
|
38
|
-
type OverlayKey =
|
|
39
|
-
| 'COLUMN_CONFIGURATION'
|
|
40
|
-
| 'PERMISSION_CONFIGURATION'
|
|
41
|
-
| 'RELATION_CONFIGURATION'
|
|
42
|
-
| 'COLUMN_RELATION_CONFIGURATION'
|
|
43
|
-
| 'RECORD_HISTORY'
|
|
44
|
-
| 'RECORD_CREATE'
|
|
45
|
-
| 'RECORD_UPDATE'
|
|
46
|
-
| 'RECORD_DELETE'
|
|
47
|
-
| 'RECORD_DELETE_ALL'
|
|
48
|
-
| 'RECORD_DELETE_MULTIPLE'
|
|
49
|
-
| 'RECORD_IMPORT'
|
|
50
|
-
| 'RECORD_FILTER'
|
|
51
|
-
| null
|
|
52
|
-
|
|
53
|
-
const displayedOverlayKey = ref<OverlayKey>(null)
|
|
54
|
-
|
|
55
|
-
const tableHeaders = computed(() => {
|
|
56
|
-
return [
|
|
57
|
-
...columns.value.map((column: Column) => {
|
|
58
|
-
return {
|
|
59
|
-
key: column.name,
|
|
60
|
-
title: column.name,
|
|
61
|
-
}
|
|
62
|
-
}),
|
|
63
|
-
{
|
|
64
|
-
key: 'actions',
|
|
65
|
-
sortable: false,
|
|
66
|
-
align: 'end' as const,
|
|
67
|
-
},
|
|
68
|
-
]
|
|
69
|
-
})
|
|
70
|
-
function setDisplayedOverlayKey(key: OverlayKey) {
|
|
71
|
-
displayedOverlayKey.value = key
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function closeModal() {
|
|
75
|
-
selectedRecord.value = null
|
|
76
|
-
displayedOverlayKey.value = null
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function showRecordHistory(item: any) {
|
|
80
|
-
selectedRecord.value = null
|
|
81
|
-
setDisplayedOverlayKey('RECORD_HISTORY')
|
|
82
|
-
selectedRecord.value = { ...item }
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function showRecordUpdate(item: any) {
|
|
86
|
-
selectedRecord.value = null
|
|
87
|
-
setDisplayedOverlayKey('RECORD_UPDATE')
|
|
88
|
-
selectedRecord.value = { ...item }
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function showRecordCreate() {
|
|
92
|
-
selectedRecord.value = null
|
|
93
|
-
setDisplayedOverlayKey('RECORD_CREATE')
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function showRecordDelete(record: any) {
|
|
97
|
-
selectedRecord.value = record
|
|
98
|
-
setDisplayedOverlayKey('RECORD_DELETE')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function showFilterForm() {
|
|
102
|
-
setDisplayedOverlayKey('RECORD_FILTER')
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function deleteSelectedRecord() {
|
|
106
|
-
if (selectedRecord.value) {
|
|
107
|
-
recordStore.deleteRecords([selectedRecord.value.id])
|
|
108
|
-
}
|
|
109
|
-
closeModal()
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function editModeKeydown(event: any) {
|
|
113
|
-
if (event.ctrlKey && event.altKey && event.code === 'KeyE') {
|
|
114
|
-
editModeIsActive.value = !editModeIsActive.value
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (!editModeIsActive.value || event.type !== 'keydown') {
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (event.key === 'Tab') {
|
|
122
|
-
return recordStore.selectNextCell()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (!event.altKey || !event.ctrlKey) {
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
switch (event.key) {
|
|
129
|
-
case 'ArrowLeft':
|
|
130
|
-
recordStore.changeSelectedColumn(-1)
|
|
131
|
-
break
|
|
132
|
-
case 'ArrowRight':
|
|
133
|
-
recordStore.changeSelectedColumn(1)
|
|
134
|
-
break
|
|
135
|
-
case 'ArrowUp':
|
|
136
|
-
recordStore.changeSelectedRow(-1)
|
|
137
|
-
break
|
|
138
|
-
case 'ArrowDown':
|
|
139
|
-
recordStore.changeSelectedRow(1)
|
|
140
|
-
break
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
onMounted(() => {
|
|
145
|
-
window.addEventListener('keydown', editModeKeydown)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
onBeforeUnmount(() => {
|
|
149
|
-
window.removeEventListener('keydown', editModeKeydown)
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
const editableColumn = ref<Column | null>(null)
|
|
153
|
-
</script>
|
|
154
|
-
|
|
155
|
-
<template>
|
|
156
|
-
<column-form :column="editableColumn" @close="editableColumn = null" />
|
|
157
|
-
|
|
158
|
-
<record-form
|
|
159
|
-
:is-displayed="['RECORD_UPDATE', 'RECORD_CREATE'].includes(displayedOverlayKey ?? '')"
|
|
160
|
-
:record="selectedRecord"
|
|
161
|
-
@close="closeModal"
|
|
162
|
-
/>
|
|
163
|
-
|
|
164
|
-
<revision-history
|
|
165
|
-
:record="selectedRecord"
|
|
166
|
-
:displayed="displayedOverlayKey === 'RECORD_HISTORY'"
|
|
167
|
-
@close="closeModal"
|
|
168
|
-
/>
|
|
169
|
-
|
|
170
|
-
<delete-confirmation-dialog
|
|
171
|
-
:model-value="displayedOverlayKey === 'RECORD_DELETE'"
|
|
172
|
-
message="Are you sure you want to delete this record? This action cannot be undone."
|
|
173
|
-
@confirm="deleteSelectedRecord"
|
|
174
|
-
/>
|
|
175
|
-
|
|
176
|
-
<filters-editor :is-expanded="displayedOverlayKey === 'RECORD_FILTER'" @close="closeModal" />
|
|
177
|
-
|
|
178
|
-
<v-data-table-server
|
|
179
|
-
v-model:items-per-page="recordsPerPage"
|
|
180
|
-
v-model:model-value="selectedRecords"
|
|
181
|
-
fixed-header
|
|
182
|
-
:headers="tableHeaders"
|
|
183
|
-
:items="records"
|
|
184
|
-
:items-length="metadata.count ?? 0"
|
|
185
|
-
hover
|
|
186
|
-
:items-per-page-options="[
|
|
187
|
-
{ value: 10, title: '10' },
|
|
188
|
-
{ value: 25, title: '25' },
|
|
189
|
-
{ value: 50, title: '50' },
|
|
190
|
-
{ value: 100, title: '100' },
|
|
191
|
-
{ value: 250, title: '250' },
|
|
192
|
-
]"
|
|
193
|
-
:loading="isFetchingRecords || isFetchingColumns"
|
|
194
|
-
:page="currentPage"
|
|
195
|
-
show-current-page
|
|
196
|
-
show-select
|
|
197
|
-
true
|
|
198
|
-
item-key="id"
|
|
199
|
-
class="h-full records-table"
|
|
200
|
-
density="compact"
|
|
201
|
-
hide-no-data
|
|
202
|
-
:hide-default-header="columns.length === 0"
|
|
203
|
-
hide-default-footer
|
|
204
|
-
@update:options="recordStore.fetchRecords"
|
|
205
|
-
>
|
|
206
|
-
<template #loading>
|
|
207
|
-
<v-skeleton-loader type="table-row@5" />
|
|
208
|
-
</template>
|
|
209
|
-
<template v-for="column in columns" :key="column.name" #[`header.${column.name}`]>
|
|
210
|
-
<record-header :column="column" @edit="() => (editableColumn = column)" />
|
|
211
|
-
</template>
|
|
212
|
-
<template v-for="column in columns" :key="column.key" #[`item.${column.name}`]="{ item }">
|
|
213
|
-
<record-cell :column="column" :record-id="item.id" :value="item[column.name]" />
|
|
214
|
-
</template>
|
|
215
|
-
<template #[`item.actions`]="{ item }">
|
|
216
|
-
<div class="ml-auto min-w-[120px]">
|
|
217
|
-
<v-btn
|
|
218
|
-
v-tooltip="'History'"
|
|
219
|
-
icon="mdi-history"
|
|
220
|
-
size="small"
|
|
221
|
-
variant="text"
|
|
222
|
-
color="grey-darken-1"
|
|
223
|
-
tooltip-location="start"
|
|
224
|
-
@click="() => showRecordHistory(item)"
|
|
225
|
-
/>
|
|
226
|
-
<v-btn
|
|
227
|
-
v-if="canUpdate"
|
|
228
|
-
v-tooltip="'Edit'"
|
|
229
|
-
icon="mdi-pencil"
|
|
230
|
-
size="small"
|
|
231
|
-
variant="text"
|
|
232
|
-
color="grey-darken-1"
|
|
233
|
-
tooltip-location="start"
|
|
234
|
-
@click="() => showRecordUpdate(item)"
|
|
235
|
-
/>
|
|
236
|
-
<v-btn
|
|
237
|
-
v-if="canDelete"
|
|
238
|
-
v-tooltip="'Delete'"
|
|
239
|
-
icon="mdi-delete"
|
|
240
|
-
size="small"
|
|
241
|
-
variant="text"
|
|
242
|
-
color="grey-darken-1"
|
|
243
|
-
tooltip-location="start"
|
|
244
|
-
@click="showRecordDelete(item)"
|
|
245
|
-
/>
|
|
246
|
-
</div>
|
|
247
|
-
</template>
|
|
248
|
-
<template #body.append>
|
|
249
|
-
<tr>
|
|
250
|
-
<td colspan="100%" class="text-center">
|
|
251
|
-
<v-btn class="w-full" color="primary" variant="text" @click="showRecordCreate">
|
|
252
|
-
<v-icon>mdi-plus</v-icon>
|
|
253
|
-
<span class="ml-2">Add Record</span>
|
|
254
|
-
</v-btn>
|
|
255
|
-
</td>
|
|
256
|
-
</tr>
|
|
257
|
-
</template>
|
|
258
|
-
|
|
259
|
-
<template #bottom>
|
|
260
|
-
<v-sheet class="d-flex justify-between items-center px-4 py-2" color="transparent">
|
|
261
|
-
<v-data-table-footer
|
|
262
|
-
class="w-full"
|
|
263
|
-
:items-per-page="recordsPerPage"
|
|
264
|
-
:items-length="metadata.count ?? 0"
|
|
265
|
-
:page="currentPage"
|
|
266
|
-
:loading="isFetchingRecords || isFetchingColumns"
|
|
267
|
-
:show-select="true"
|
|
268
|
-
:hide-default-footer="columns.length === 0"
|
|
269
|
-
/>
|
|
270
|
-
<v-btn variant="plain" flat icon="mdi-filter-outline" @click="showFilterForm" />
|
|
271
|
-
</v-sheet>
|
|
272
|
-
</template>
|
|
273
|
-
</v-data-table-server>
|
|
274
|
-
</template>
|