@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
|
@@ -7,9 +7,13 @@ import { useColumnStore } from '../../stores/columns'
|
|
|
7
7
|
|
|
8
8
|
import { useRecordStore } from '../../stores/records'
|
|
9
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'
|
|
10
13
|
import RecordCell from '../Records/RecordCell.vue'
|
|
11
14
|
import RecordHeader from '../Records/RecordHeader.vue'
|
|
12
|
-
import
|
|
15
|
+
import RevisionHistory from '../Revisions/RevisionHistory.vue'
|
|
16
|
+
import RecordForm from './RecordForm.vue'
|
|
13
17
|
|
|
14
18
|
const columnStore = useColumnStore()
|
|
15
19
|
const recordStore = useRecordStore()
|
|
@@ -25,16 +29,17 @@ const {
|
|
|
25
29
|
recordsPerPage,
|
|
26
30
|
currentPage,
|
|
27
31
|
isFetching: isFetchingRecords,
|
|
32
|
+
selectedRecords,
|
|
28
33
|
editModeIsActive,
|
|
29
34
|
} = storeToRefs(recordStore)
|
|
30
35
|
|
|
31
36
|
const selectedRecord = ref<TableRecord | null>()
|
|
32
|
-
const selectedRecords = ref<string[]>([])
|
|
33
37
|
|
|
34
|
-
type
|
|
38
|
+
type OverlayKey =
|
|
35
39
|
| 'COLUMN_CONFIGURATION'
|
|
36
40
|
| 'PERMISSION_CONFIGURATION'
|
|
37
41
|
| 'RELATION_CONFIGURATION'
|
|
42
|
+
| 'COLUMN_RELATION_CONFIGURATION'
|
|
38
43
|
| 'RECORD_HISTORY'
|
|
39
44
|
| 'RECORD_CREATE'
|
|
40
45
|
| 'RECORD_UPDATE'
|
|
@@ -42,59 +47,66 @@ type DialogKey =
|
|
|
42
47
|
| 'RECORD_DELETE_ALL'
|
|
43
48
|
| 'RECORD_DELETE_MULTIPLE'
|
|
44
49
|
| 'RECORD_IMPORT'
|
|
50
|
+
| 'RECORD_FILTER'
|
|
45
51
|
| null
|
|
46
52
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const headers = computed(() =>
|
|
50
|
-
columns.value.map((column: Column) => {
|
|
51
|
-
return {
|
|
52
|
-
column,
|
|
53
|
-
align: 'start',
|
|
54
|
-
id: column.id,
|
|
55
|
-
key: column.name,
|
|
56
|
-
name: column.name,
|
|
57
|
-
type: column.type,
|
|
58
|
-
sortable: false,
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
)
|
|
53
|
+
const displayedOverlayKey = ref<OverlayKey>(null)
|
|
62
54
|
|
|
63
55
|
const tableHeaders = computed(() => {
|
|
64
56
|
return [
|
|
65
|
-
...
|
|
57
|
+
...columns.value.map((column: Column) => {
|
|
58
|
+
return {
|
|
59
|
+
key: column.name,
|
|
60
|
+
title: column.name,
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
66
63
|
{
|
|
67
|
-
id: 'actions',
|
|
68
64
|
key: 'actions',
|
|
69
|
-
name: 'Actions',
|
|
70
65
|
sortable: false,
|
|
71
|
-
align: 'end',
|
|
66
|
+
align: 'end' as const,
|
|
72
67
|
},
|
|
73
68
|
]
|
|
74
69
|
})
|
|
75
|
-
function
|
|
76
|
-
|
|
70
|
+
function setDisplayedOverlayKey(key: OverlayKey) {
|
|
71
|
+
displayedOverlayKey.value = key
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
function closeModal() {
|
|
80
|
-
|
|
75
|
+
selectedRecord.value = null
|
|
76
|
+
displayedOverlayKey.value = null
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
function showRecordHistory(item: any) {
|
|
84
80
|
selectedRecord.value = null
|
|
85
|
-
|
|
81
|
+
setDisplayedOverlayKey('RECORD_HISTORY')
|
|
86
82
|
selectedRecord.value = { ...item }
|
|
87
83
|
}
|
|
88
84
|
|
|
89
85
|
function showRecordUpdate(item: any) {
|
|
90
86
|
selectedRecord.value = null
|
|
91
|
-
|
|
87
|
+
setDisplayedOverlayKey('RECORD_UPDATE')
|
|
92
88
|
selectedRecord.value = { ...item }
|
|
93
89
|
}
|
|
94
90
|
|
|
91
|
+
function showRecordCreate() {
|
|
92
|
+
selectedRecord.value = null
|
|
93
|
+
setDisplayedOverlayKey('RECORD_CREATE')
|
|
94
|
+
}
|
|
95
|
+
|
|
95
96
|
function showRecordDelete(record: any) {
|
|
96
97
|
selectedRecord.value = record
|
|
97
|
-
|
|
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()
|
|
98
110
|
}
|
|
99
111
|
|
|
100
112
|
function editModeKeydown(event: any) {
|
|
@@ -136,9 +148,33 @@ onMounted(() => {
|
|
|
136
148
|
onBeforeUnmount(() => {
|
|
137
149
|
window.removeEventListener('keydown', editModeKeydown)
|
|
138
150
|
})
|
|
151
|
+
|
|
152
|
+
const editableColumn = ref<Column | null>(null)
|
|
139
153
|
</script>
|
|
140
154
|
|
|
141
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
|
+
|
|
142
178
|
<v-data-table-server
|
|
143
179
|
v-model:items-per-page="recordsPerPage"
|
|
144
180
|
v-model:model-value="selectedRecords"
|
|
@@ -146,6 +182,7 @@ onBeforeUnmount(() => {
|
|
|
146
182
|
:headers="tableHeaders"
|
|
147
183
|
:items="records"
|
|
148
184
|
:items-length="metadata.count ?? 0"
|
|
185
|
+
hover
|
|
149
186
|
:items-per-page-options="[
|
|
150
187
|
{ value: 10, title: '10' },
|
|
151
188
|
{ value: 25, title: '25' },
|
|
@@ -158,43 +195,22 @@ onBeforeUnmount(() => {
|
|
|
158
195
|
show-current-page
|
|
159
196
|
show-select
|
|
160
197
|
true
|
|
161
|
-
color="primary"
|
|
162
198
|
item-key="id"
|
|
163
199
|
class="h-full records-table"
|
|
164
200
|
density="compact"
|
|
201
|
+
hide-no-data
|
|
202
|
+
:hide-default-header="columns.length === 0"
|
|
203
|
+
hide-default-footer
|
|
165
204
|
@update:options="recordStore.fetchRecords"
|
|
166
205
|
>
|
|
167
206
|
<template #loading>
|
|
168
207
|
<v-skeleton-loader type="table-row@5" />
|
|
169
208
|
</template>
|
|
170
|
-
<template #
|
|
171
|
-
<
|
|
172
|
-
:headers="headers"
|
|
173
|
-
:selected-records="selectedRecords"
|
|
174
|
-
:selected-record="selectedRecord"
|
|
175
|
-
:displayed-dialog-key="displayedDialogKey"
|
|
176
|
-
@close-modal="closeModal"
|
|
177
|
-
@open-modal="openModal"
|
|
178
|
-
/>
|
|
209
|
+
<template v-for="column in columns" :key="column.name" #[`header.${column.name}`]>
|
|
210
|
+
<record-header :column="column" @edit="() => (editableColumn = column)" />
|
|
179
211
|
</template>
|
|
180
|
-
<template
|
|
181
|
-
|
|
182
|
-
:key="header.key"
|
|
183
|
-
#[`header.${header.key}`]
|
|
184
|
-
>
|
|
185
|
-
<record-header :header="header" />
|
|
186
|
-
</template>
|
|
187
|
-
<template
|
|
188
|
-
v-for="header in headers.filter((h: any) => h.column)"
|
|
189
|
-
:key="header.key"
|
|
190
|
-
#[`item.${header.key}`]="{ item }"
|
|
191
|
-
>
|
|
192
|
-
<record-cell
|
|
193
|
-
:column="header.column"
|
|
194
|
-
:record-id="item.id"
|
|
195
|
-
:value="item[header.name]"
|
|
196
|
-
@dblclick="recordStore.selectCell(item.id, header.column.id)"
|
|
197
|
-
/>
|
|
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]" />
|
|
198
214
|
</template>
|
|
199
215
|
<template #[`item.actions`]="{ item }">
|
|
200
216
|
<div class="ml-auto min-w-[120px]">
|
|
@@ -229,5 +245,30 @@ onBeforeUnmount(() => {
|
|
|
229
245
|
/>
|
|
230
246
|
</div>
|
|
231
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>
|
|
232
273
|
</v-data-table-server>
|
|
233
274
|
</template>
|
|
@@ -8,11 +8,8 @@ import { useColumnStore } from '../../stores/columns'
|
|
|
8
8
|
import { useRecordStore } from '../../stores/records'
|
|
9
9
|
import { useRevisionStore } from '../../stores/revisions'
|
|
10
10
|
import { useTableStore } from '../../stores/table'
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import QueriesMenu from '../Queries/QueriesMenu.vue'
|
|
14
|
-
import RecordDialog from '../Records/RecordDialog.vue'
|
|
15
|
-
import RelationsConfiguration from '../Relations/RelationsConfiguration.vue'
|
|
11
|
+
import QueriesMenu from '../Filters/QueriesList.vue'
|
|
12
|
+
// import RecordDialog from './RecordForm.vue'
|
|
16
13
|
import RevisionHistory from '../Revisions/RevisionHistory.vue'
|
|
17
14
|
import RevisionSelector from '../Revisions/RevisionSelector.vue'
|
|
18
15
|
|
|
@@ -72,19 +69,7 @@ const recordsToBeDeleted = computed(() => {
|
|
|
72
69
|
})
|
|
73
70
|
|
|
74
71
|
function handleDeleteAction() {
|
|
75
|
-
|
|
76
|
-
tableStore.deleteTable()
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
recordStore.deleteRecords(recordsToBeDeleted.value)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function updateTable() {
|
|
84
|
-
if (!tableName.value || isUpdating.value) {
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
tableStore.updateTable(tableName.value)
|
|
72
|
+
recordStore.deleteRecords(recordsToBeDeleted.value)
|
|
88
73
|
}
|
|
89
74
|
|
|
90
75
|
watch(
|
|
@@ -92,19 +77,37 @@ watch(
|
|
|
92
77
|
() => (tableName.value = table.value?.name ?? ''),
|
|
93
78
|
{ immediate: true },
|
|
94
79
|
)
|
|
80
|
+
|
|
81
|
+
const fileInputRef = ref<HTMLInputElement | null>(null) // Ref for hidden input
|
|
82
|
+
|
|
83
|
+
// Function to trigger file input click programmatically
|
|
84
|
+
function setupImport() {
|
|
85
|
+
fileInputRef.value?.click()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Handle CSV file change and process API call
|
|
89
|
+
async function handleFileChange(event: Event) {
|
|
90
|
+
const target = event.target as HTMLInputElement
|
|
91
|
+
if (!target.files || target.files.length === 0) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const file = target.files[0]
|
|
96
|
+
if (file) {
|
|
97
|
+
await recordStore.importRecords(file)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Clear the input value so the same file can be uploaded again
|
|
101
|
+
target.value = ''
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
function sendExportRequest() {
|
|
106
|
+
recordStore.exportTableRecords()
|
|
107
|
+
}
|
|
95
108
|
</script>
|
|
96
109
|
|
|
97
110
|
<template>
|
|
98
|
-
<!-- <base-import-dialog
|
|
99
|
-
accept=".csv, .xls, .xlsx"
|
|
100
|
-
:columns="columns"
|
|
101
|
-
:displayed="recordImportDialog"
|
|
102
|
-
:is-loading="isLoading"
|
|
103
|
-
:title="t('project.records.dialog.importTitle')"
|
|
104
|
-
:upload-action="importRecords"
|
|
105
|
-
@close="closeRecordImportDialog"
|
|
106
|
-
/> -->
|
|
107
|
-
|
|
108
111
|
<BaseDeleteDialog
|
|
109
112
|
:delete-action="handleDeleteAction"
|
|
110
113
|
:displayed="
|
|
@@ -119,99 +122,13 @@ watch(
|
|
|
119
122
|
@close="emit('closeModal')"
|
|
120
123
|
/>
|
|
121
124
|
|
|
122
|
-
<record-dialog
|
|
123
|
-
:display-dialog="
|
|
124
|
-
!!displayedDialogKey && ['RECORD_UPDATE', 'RECORD_CREATE'].includes(displayedDialogKey)
|
|
125
|
-
"
|
|
126
|
-
:record="selectedRecord"
|
|
127
|
-
@close="emit('closeModal')"
|
|
128
|
-
/>
|
|
129
125
|
|
|
130
126
|
<revision-history :headers="headers" :record="selectedRecord" :displayed="displayedDialogKey === 'RECORD_HISTORY'" @close="emit('closeModal')" />
|
|
131
127
|
|
|
132
|
-
<
|
|
133
|
-
:displayed="displayedDialogKey === 'COLUMN_CONFIGURATION'"
|
|
134
|
-
@close="emit('closeModal')"
|
|
135
|
-
/>
|
|
136
|
-
|
|
137
|
-
<permissions-configuration
|
|
138
|
-
:displayed="displayedDialogKey === 'PERMISSION_CONFIGURATION'"
|
|
139
|
-
@close="emit('closeModal')"
|
|
140
|
-
/>
|
|
141
|
-
|
|
142
|
-
<relations-configuration
|
|
143
|
-
:displayed="displayedDialogKey === 'RELATION_CONFIGURATION'"
|
|
144
|
-
@close="emit('closeModal')"
|
|
145
|
-
/>
|
|
146
|
-
|
|
147
|
-
<v-toolbar color="primary" density="compact">
|
|
128
|
+
<v-toolbar color="grey-lighten-3" density="compact">
|
|
148
129
|
<v-toolbar-title class="flex-0-0 mr-4">
|
|
149
130
|
{{ table?.name ?? t('project.records.tableMenu.records') }}
|
|
150
131
|
</v-toolbar-title>
|
|
151
|
-
<v-toolbar-items>
|
|
152
|
-
<v-btn
|
|
153
|
-
v-if="canDelete"
|
|
154
|
-
v-tooltip="t('system.buttons.delete')"
|
|
155
|
-
size="small"
|
|
156
|
-
icon="mdi-delete"
|
|
157
|
-
@click="() => emit('openModal', 'TABLE_DELETE')"
|
|
158
|
-
/>
|
|
159
|
-
|
|
160
|
-
<v-menu v-if="canUpdate" :close-on-content-click="false" location="end">
|
|
161
|
-
<template #activator="{ props: activatorProps }">
|
|
162
|
-
<v-btn
|
|
163
|
-
v-tooltip="t('system.buttons.update')"
|
|
164
|
-
size="small"
|
|
165
|
-
icon="mdi-pencil"
|
|
166
|
-
v-bind="activatorProps"
|
|
167
|
-
/>
|
|
168
|
-
</template>
|
|
169
|
-
<v-card class="w-[300px]" :title="t('project.tables.tableName')">
|
|
170
|
-
<v-card-text>
|
|
171
|
-
<v-text-field
|
|
172
|
-
v-model="tableName"
|
|
173
|
-
:placeholder="t('project.tables.tableName')"
|
|
174
|
-
variant="outlined"
|
|
175
|
-
color="primary"
|
|
176
|
-
density="compact"
|
|
177
|
-
hide-details
|
|
178
|
-
>
|
|
179
|
-
<template #append-inner>
|
|
180
|
-
<v-progress-circular
|
|
181
|
-
v-if="isUpdating"
|
|
182
|
-
size="small"
|
|
183
|
-
color="grey-darken-2"
|
|
184
|
-
indeterminate
|
|
185
|
-
/>
|
|
186
|
-
<v-btn
|
|
187
|
-
v-else
|
|
188
|
-
variant="text"
|
|
189
|
-
size="small"
|
|
190
|
-
icon="mdi-content-save-check-outline"
|
|
191
|
-
color="grey-darken-2"
|
|
192
|
-
@click="updateTable"
|
|
193
|
-
/>
|
|
194
|
-
</template>
|
|
195
|
-
</v-text-field>
|
|
196
|
-
</v-card-text>
|
|
197
|
-
<v-divider />
|
|
198
|
-
<v-card-actions>
|
|
199
|
-
<v-spacer />
|
|
200
|
-
<v-btn
|
|
201
|
-
variant="tonal"
|
|
202
|
-
:disabled="!tableName.length || isUpdating"
|
|
203
|
-
:loading="isUpdating"
|
|
204
|
-
class="px-4"
|
|
205
|
-
size="small"
|
|
206
|
-
color="primary"
|
|
207
|
-
@click="updateTable"
|
|
208
|
-
>
|
|
209
|
-
{{ t('system.buttons.update') }}
|
|
210
|
-
</v-btn>
|
|
211
|
-
</v-card-actions>
|
|
212
|
-
</v-card>
|
|
213
|
-
</v-menu>
|
|
214
|
-
</v-toolbar-items>
|
|
215
132
|
|
|
216
133
|
<revision-selector
|
|
217
134
|
show-add-revision
|
|
@@ -240,30 +157,6 @@ watch(
|
|
|
240
157
|
@click="recordStore.toggleEditMode"
|
|
241
158
|
/>
|
|
242
159
|
|
|
243
|
-
<v-btn
|
|
244
|
-
v-if="canConfigure"
|
|
245
|
-
v-tooltip="t('project.tableConfig.columns.title')"
|
|
246
|
-
size="small"
|
|
247
|
-
icon="mdi-table-column"
|
|
248
|
-
@click="() => emit('openModal', 'COLUMN_CONFIGURATION')"
|
|
249
|
-
/>
|
|
250
|
-
|
|
251
|
-
<v-btn
|
|
252
|
-
v-if="canConfigure"
|
|
253
|
-
v-tooltip="t('project.tableConfig.permissions.title')"
|
|
254
|
-
size="small"
|
|
255
|
-
icon="mdi-shield-crown-outline"
|
|
256
|
-
@click="() => emit('openModal', 'PERMISSION_CONFIGURATION')"
|
|
257
|
-
/>
|
|
258
|
-
|
|
259
|
-
<v-btn
|
|
260
|
-
v-if="canConfigure"
|
|
261
|
-
v-tooltip="t('project.tableConfig.relations.title')"
|
|
262
|
-
size="small"
|
|
263
|
-
icon="mdi-relation-many-to-many"
|
|
264
|
-
@click="() => emit('openModal', 'RELATION_CONFIGURATION')"
|
|
265
|
-
/>
|
|
266
|
-
|
|
267
160
|
<queries-menu />
|
|
268
161
|
|
|
269
162
|
<v-menu location="start">
|
|
@@ -272,12 +165,19 @@ watch(
|
|
|
272
165
|
</template>
|
|
273
166
|
|
|
274
167
|
<v-list color="primary" density="compact">
|
|
275
|
-
|
|
168
|
+
<v-list-item @click="setupImport">
|
|
276
169
|
<template #prepend>
|
|
277
170
|
<v-icon icon="mdi-file-import" size="small" />
|
|
278
171
|
</template>
|
|
279
172
|
<v-list-item-title>{{ t('project.records.tableMenu.import') }}</v-list-item-title>
|
|
280
|
-
|
|
173
|
+
<input
|
|
174
|
+
ref="fileInputRef"
|
|
175
|
+
type="file"
|
|
176
|
+
style="display: none"
|
|
177
|
+
accept=".csv"
|
|
178
|
+
@change="handleFileChange"
|
|
179
|
+
>
|
|
180
|
+
</v-list-item>
|
|
281
181
|
<v-list-item
|
|
282
182
|
v-if="canDelete && selectedRecords.length > 1"
|
|
283
183
|
@click="() => emit('openModal', 'RECORD_DELETE_MULTIPLE')"
|
|
@@ -297,7 +197,7 @@ watch(
|
|
|
297
197
|
{{ t('project.records.tableMenu.deleteAll') }}
|
|
298
198
|
</v-list-item-title>
|
|
299
199
|
</v-list-item>
|
|
300
|
-
<v-list-item>
|
|
200
|
+
<v-list-item @click="sendExportRequest">
|
|
301
201
|
<template #prepend>
|
|
302
202
|
<v-icon icon="mdi-file-download" size="small" />
|
|
303
203
|
</template>
|
|
@@ -10,7 +10,6 @@ import RecordValue from '../Records/RecordValue.vue'
|
|
|
10
10
|
|
|
11
11
|
const props = defineProps<{
|
|
12
12
|
displayed: boolean
|
|
13
|
-
headers: any[]
|
|
14
13
|
record?: TableRecord | null
|
|
15
14
|
}>()
|
|
16
15
|
|
|
@@ -34,7 +33,25 @@ const historyTableHeaders = computed(() => {
|
|
|
34
33
|
sortable: false,
|
|
35
34
|
align: 'start',
|
|
36
35
|
},
|
|
37
|
-
...
|
|
36
|
+
...columns.value.map((column) => {
|
|
37
|
+
return {
|
|
38
|
+
id: column.id,
|
|
39
|
+
key: column.name,
|
|
40
|
+
name: column.name,
|
|
41
|
+
sortable: false,
|
|
42
|
+
align: 'start',
|
|
43
|
+
width: 180,
|
|
44
|
+
column: column,
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
{
|
|
48
|
+
id: 'action',
|
|
49
|
+
key: 'action',
|
|
50
|
+
name: 'Action',
|
|
51
|
+
sortable: false,
|
|
52
|
+
align: 'start',
|
|
53
|
+
width: 180,
|
|
54
|
+
},
|
|
38
55
|
{
|
|
39
56
|
id: 'revisioned',
|
|
40
57
|
key: 'revisioned',
|
|
@@ -94,6 +111,7 @@ watch(
|
|
|
94
111
|
<v-skeleton-loader type="table-row@4" />
|
|
95
112
|
</template>
|
|
96
113
|
|
|
114
|
+
|
|
97
115
|
<template
|
|
98
116
|
v-for="header in historyTableHeaders"
|
|
99
117
|
:key="header.key"
|
|
@@ -103,13 +121,13 @@ watch(
|
|
|
103
121
|
</template>
|
|
104
122
|
|
|
105
123
|
<template
|
|
106
|
-
v-for="
|
|
107
|
-
:key="
|
|
108
|
-
#[`item.${
|
|
124
|
+
v-for="column in columns"
|
|
125
|
+
:key="column.name"
|
|
126
|
+
#[`item.${column.name}`]="{ item }"
|
|
109
127
|
>
|
|
110
128
|
<record-value
|
|
111
|
-
:value="item[
|
|
112
|
-
:column="
|
|
129
|
+
:value="item[column.name]"
|
|
130
|
+
:column="column"
|
|
113
131
|
:record-id="item.id"
|
|
114
132
|
/>
|
|
115
133
|
</template>
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column } from '@antcde/connect-ts'
|
|
3
|
+
import { storeToRefs } from 'pinia'
|
|
4
|
+
import { ref, watch } from 'vue'
|
|
5
|
+
import { useColumnStore } from '../../stores/columns'
|
|
6
|
+
import { useTableStore } from '../../stores/table'
|
|
7
|
+
import ColumnsList from '../Columns/ColumnsList.vue'
|
|
8
|
+
import ForeignKeyColumnsList from '../Columns/ForeignKeyColumnsList.vue'
|
|
9
|
+
|
|
10
|
+
const isExpanded = defineModel<boolean>('isExpanded')
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const columnStore = useColumnStore()
|
|
14
|
+
const { columns: tableColumns } = storeToRefs(columnStore)
|
|
15
|
+
const { addColumn, updateColumn} = columnStore
|
|
16
|
+
|
|
17
|
+
const tableStore = useTableStore()
|
|
18
|
+
const { table: selectedTable, isUpdating } = storeToRefs(tableStore)
|
|
19
|
+
const { updateTable } = tableStore
|
|
20
|
+
|
|
21
|
+
const table = ref({
|
|
22
|
+
name: selectedTable.value?.name || '',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const columns = ref<Partial<Column>[]>([])
|
|
26
|
+
|
|
27
|
+
async function saveTable() {
|
|
28
|
+
await updateTable(table.value.name)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function saveColumn(columnIndex: number, data: Partial<Column>) {
|
|
32
|
+
const column = columns.value[columnIndex]
|
|
33
|
+
if (column?.id) {
|
|
34
|
+
await updateColumn(column.id, {
|
|
35
|
+
name: data.name ?? '',
|
|
36
|
+
default_value: data.default_value?.toString() ?? '',
|
|
37
|
+
required: data.required ?? false,
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
await addColumn({ ...data } as Column)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function deleteColumn(index: number) {
|
|
46
|
+
const column = columns.value[index]
|
|
47
|
+
if (column?.id) {
|
|
48
|
+
await columnStore.deleteColumn(column.id)
|
|
49
|
+
} else {
|
|
50
|
+
columns.value.splice(index, 1)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
watch(
|
|
55
|
+
() => selectedTable.value,
|
|
56
|
+
t => (table.value = t ? { ...t } : { name: '' }),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
watch(
|
|
60
|
+
() => tableColumns.value,
|
|
61
|
+
(c) => columns.value = c ? [...c] : [],
|
|
62
|
+
{ immediate: true, deep: true },
|
|
63
|
+
)
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<v-navigation-drawer
|
|
68
|
+
v-model="isExpanded"
|
|
69
|
+
:width="800"
|
|
70
|
+
:elevation="1"
|
|
71
|
+
location="right"
|
|
72
|
+
:border="0"
|
|
73
|
+
temporary
|
|
74
|
+
absolute
|
|
75
|
+
persistent
|
|
76
|
+
scrim
|
|
77
|
+
>
|
|
78
|
+
<v-sheet class="d-flex flex-col h-full">
|
|
79
|
+
<v-toolbar
|
|
80
|
+
class="d-flex flex-row justify-between align-center pe-4"
|
|
81
|
+
color="grey-lighten-3"
|
|
82
|
+
variant="tonal"
|
|
83
|
+
density="compact"
|
|
84
|
+
>
|
|
85
|
+
<v-toolbar-title class="text-h6 font-semibold">
|
|
86
|
+
{{ 'Update Table' }}
|
|
87
|
+
</v-toolbar-title>
|
|
88
|
+
<v-spacer />
|
|
89
|
+
<v-btn icon @click="isExpanded = false">
|
|
90
|
+
<v-icon>mdi-close</v-icon>
|
|
91
|
+
</v-btn>
|
|
92
|
+
</v-toolbar>
|
|
93
|
+
<v-divider />
|
|
94
|
+
<v-card class="d-flex flex-column h-full overflow-auto" rounded="lg" :elevation="0">
|
|
95
|
+
<v-card-item class="px-8">
|
|
96
|
+
<v-sheet class="d-flex flex-column">
|
|
97
|
+
<v-label class="mr-2 font-semibold">
|
|
98
|
+
Table Name
|
|
99
|
+
</v-label>
|
|
100
|
+
<v-text-field
|
|
101
|
+
v-model="table.name"
|
|
102
|
+
variant="outlined"
|
|
103
|
+
color="primary"
|
|
104
|
+
density="compact"
|
|
105
|
+
hint="Press enter to save"
|
|
106
|
+
persistent-hint
|
|
107
|
+
:loading="isUpdating"
|
|
108
|
+
:disabled="isUpdating"
|
|
109
|
+
@keydown.enter="saveTable"
|
|
110
|
+
/>
|
|
111
|
+
</v-sheet>
|
|
112
|
+
</v-card-item>
|
|
113
|
+
|
|
114
|
+
<v-divider />
|
|
115
|
+
|
|
116
|
+
<v-card-item>
|
|
117
|
+
<v-card-title> Columns </v-card-title>
|
|
118
|
+
<columns-list
|
|
119
|
+
:columns="columns"
|
|
120
|
+
@columns:add="columns.push({})"
|
|
121
|
+
@columns:remove="index => deleteColumn(index)"
|
|
122
|
+
@columns:update="(columnIndex, data) => saveColumn(columnIndex, data)"
|
|
123
|
+
/>
|
|
124
|
+
</v-card-item>
|
|
125
|
+
|
|
126
|
+
<template v-if="columns.filter((c) => c.type === 'uuid').length > 0">
|
|
127
|
+
<v-divider />
|
|
128
|
+
<v-card-item>
|
|
129
|
+
<v-card-title> Foreign Keys </v-card-title>
|
|
130
|
+
<foreign-key-columns-list :columns="columns" />
|
|
131
|
+
</v-card-item>
|
|
132
|
+
</template>
|
|
133
|
+
</v-card>
|
|
134
|
+
</v-sheet>
|
|
135
|
+
</v-navigation-drawer>
|
|
136
|
+
</template>
|