@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,325 +0,0 @@
|
|
|
1
|
-
import type { RecordRequest, RecordsFile } from '@antcde/connect-ts'
|
|
2
|
-
|
|
3
|
-
import type { Stats, TableRecord } from '@antcde/connect-ts/services/TableService'
|
|
4
|
-
import { defineStore } from 'pinia'
|
|
5
|
-
import { computed, ref } from 'vue'
|
|
6
|
-
import { useClientStore } from './client'
|
|
7
|
-
import { useColumnStore } from './columns'
|
|
8
|
-
import { useTableStore } from './table'
|
|
9
|
-
import { convertFileToBase64 } from '../composables/records'
|
|
10
|
-
|
|
11
|
-
interface Pagination {
|
|
12
|
-
page?: number
|
|
13
|
-
itemsPerPage?: number
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const useRecordStore = defineStore('ant.apps.table.viewer.records', () => {
|
|
17
|
-
const currentPage = ref(1)
|
|
18
|
-
const recordsPerPage = ref(10)
|
|
19
|
-
const records = ref<TableRecord[]>([])
|
|
20
|
-
const selectedRecords = ref<string[]>([])
|
|
21
|
-
const metadata = ref<Stats>({
|
|
22
|
-
count: 0,
|
|
23
|
-
offset: 0,
|
|
24
|
-
limit: recordsPerPage.value,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
const isFetching = ref(false)
|
|
28
|
-
const isImporting = ref(false)
|
|
29
|
-
const isUpdating = ref(false)
|
|
30
|
-
const isCreating = ref(false)
|
|
31
|
-
const isDeleting = ref(false)
|
|
32
|
-
|
|
33
|
-
const selectedRowIndex = ref(-1)
|
|
34
|
-
const selectedColumnIndex = ref(-1)
|
|
35
|
-
const editModeIsActive = ref(false)
|
|
36
|
-
|
|
37
|
-
const clientStore = useClientStore()
|
|
38
|
-
const { client } = clientStore
|
|
39
|
-
const connect = client?.connect
|
|
40
|
-
const tableStore = useTableStore()
|
|
41
|
-
const columnStore = useColumnStore()
|
|
42
|
-
|
|
43
|
-
const queryPayload = computed(() => {
|
|
44
|
-
return {
|
|
45
|
-
offset: (currentPage.value - 1) * recordsPerPage.value,
|
|
46
|
-
limit: recordsPerPage.value,
|
|
47
|
-
tables: [
|
|
48
|
-
{
|
|
49
|
-
id: tableStore.table?.id,
|
|
50
|
-
as: tableStore.table?.id,
|
|
51
|
-
columns: columnStore.columnsConfiguration,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
async function fetchRecords(pagination: Pagination | null = null) {
|
|
58
|
-
try {
|
|
59
|
-
if (!tableStore.table?.id || !connect) {
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
currentPage.value = pagination?.page ?? 1
|
|
63
|
-
recordsPerPage.value = pagination?.itemsPerPage ?? recordsPerPage.value
|
|
64
|
-
isFetching.value = true
|
|
65
|
-
const response = await connect.tables.queryTables(queryPayload.value)
|
|
66
|
-
const tableResponse = response[tableStore.table.id]
|
|
67
|
-
records.value = (tableResponse?.records as TableRecord[]) ?? []
|
|
68
|
-
metadata.value = tableResponse?.stats ?? { count: 0, offset: 0, limit: recordsPerPage.value }
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
isFetching.value = false
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function exportTableRecords() {
|
|
76
|
-
try {
|
|
77
|
-
if (!tableStore.table?.id || !connect) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
await connect.tables.queryTablesExport(queryPayload.value)
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
isFetching.value = false
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function importRecords(file: File) {
|
|
88
|
-
try {
|
|
89
|
-
if (!tableStore.table?.id || !connect) {
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
// Convert file to Base64 and strip prefix
|
|
93
|
-
const base64String = await convertFileToBase64(file)
|
|
94
|
-
|
|
95
|
-
const body = {
|
|
96
|
-
records: base64String, // Base64 encoded CSV content (no prefix)
|
|
97
|
-
}
|
|
98
|
-
isImporting.value = true
|
|
99
|
-
await connect.records.importRecords(tableStore.table.id, body as RecordsFile)
|
|
100
|
-
await fetchRecords()
|
|
101
|
-
}
|
|
102
|
-
finally {
|
|
103
|
-
isImporting.value = false
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function updateRecord(recordId: string, data: Record<string, any>) {
|
|
108
|
-
try {
|
|
109
|
-
if (!tableStore.table?.id || !connect) {
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
isUpdating.value = true
|
|
113
|
-
const updatedRecord = await connect.records.updateRecord(
|
|
114
|
-
tableStore.table.id,
|
|
115
|
-
recordId,
|
|
116
|
-
data,
|
|
117
|
-
)
|
|
118
|
-
const index = records.value.findIndex((record: { id: string }) => record.id === recordId)
|
|
119
|
-
records.value.splice(index, 1, updatedRecord)
|
|
120
|
-
return Promise.resolve(updatedRecord)
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
isUpdating.value = false
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async function createRecord(data: Record<string, any>) {
|
|
128
|
-
try {
|
|
129
|
-
if (!tableStore.table?.id || !connect) {
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
isCreating.value = true
|
|
133
|
-
const newRecord = await connect.records.createRecord(tableStore.table.id, data as RecordRequest)
|
|
134
|
-
records.value.push(newRecord)
|
|
135
|
-
return Promise.resolve(newRecord)
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
isCreating.value = false
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async function deleteRecords(recordIds: string[]) {
|
|
143
|
-
try {
|
|
144
|
-
if (!tableStore.table?.id || !connect) {
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
isDeleting.value = true
|
|
148
|
-
await connect.records.deleteRecord({
|
|
149
|
-
project: tableStore.table.project,
|
|
150
|
-
table: tableStore.table.id,
|
|
151
|
-
records: recordIds,
|
|
152
|
-
})
|
|
153
|
-
records.value = records.value.filter((record: { id: string }) => !recordIds.includes(record.id))
|
|
154
|
-
}
|
|
155
|
-
finally {
|
|
156
|
-
isDeleting.value = false
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async function deleteSelectedRecords() {
|
|
161
|
-
try {
|
|
162
|
-
if (!tableStore.table?.id || !connect) {
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
isDeleting.value = true
|
|
166
|
-
await deleteRecords(selectedRecords.value)
|
|
167
|
-
selectedRecords.value = []
|
|
168
|
-
}
|
|
169
|
-
finally {
|
|
170
|
-
isDeleting.value = false
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async function deleteAllRecords() {
|
|
175
|
-
try {
|
|
176
|
-
if (!tableStore.table?.id || !connect) {
|
|
177
|
-
return
|
|
178
|
-
}
|
|
179
|
-
isDeleting.value = true
|
|
180
|
-
await deleteRecords(records.value.map((record: { id: string }) => record.id))
|
|
181
|
-
records.value = []
|
|
182
|
-
}
|
|
183
|
-
finally {
|
|
184
|
-
isDeleting.value = false
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
async function fetchRecordHistory(record: TableRecord) {
|
|
189
|
-
if (!tableStore.table?.id || !connect) {
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
return tableStore.table
|
|
193
|
-
? await connect.records
|
|
194
|
-
.getRecordHistory(tableStore.table.id, record.id)
|
|
195
|
-
.then(records => Promise.resolve(records))
|
|
196
|
-
.catch(() => Promise.resolve([]))
|
|
197
|
-
: []
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function toggleEditMode() {
|
|
201
|
-
editModeIsActive.value = !editModeIsActive.value
|
|
202
|
-
if (editModeIsActive.value) {
|
|
203
|
-
selectedRowIndex.value = 0
|
|
204
|
-
selectedColumnIndex.value = 0
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
selectedRowIndex.value = -1
|
|
208
|
-
selectedColumnIndex.value = -1
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function changeSelectedRow(offset = 1) {
|
|
213
|
-
let newIndex = selectedRowIndex.value + offset
|
|
214
|
-
if (newIndex < 0) {
|
|
215
|
-
newIndex = records.value.length - 1
|
|
216
|
-
}
|
|
217
|
-
else if (newIndex >= records.value.length) {
|
|
218
|
-
newIndex = 0
|
|
219
|
-
}
|
|
220
|
-
selectedRowIndex.value = newIndex
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function changeSelectedColumn(offset = 1) {
|
|
224
|
-
const columns = columnStore.columns
|
|
225
|
-
let newIndex = selectedColumnIndex.value + offset
|
|
226
|
-
if (newIndex < 0) {
|
|
227
|
-
newIndex = columns.length - 1
|
|
228
|
-
}
|
|
229
|
-
else if (newIndex >= columns.length) {
|
|
230
|
-
newIndex = 0
|
|
231
|
-
}
|
|
232
|
-
selectedColumnIndex.value = newIndex
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function getCellPosition(recordId: string, columnId: string) {
|
|
236
|
-
return {
|
|
237
|
-
row: records.value.findIndex((r: { id: string }) => r.id === recordId),
|
|
238
|
-
column: columnStore.getColumnIndex(columnId),
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function selectCell(recordId: string, columnId: string) {
|
|
243
|
-
if (!editModeIsActive.value) {
|
|
244
|
-
return
|
|
245
|
-
}
|
|
246
|
-
const { row, column: col } = getCellPosition(recordId, columnId)
|
|
247
|
-
selectedRowIndex.value = row
|
|
248
|
-
selectedColumnIndex.value = col
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function selectNextCell() {
|
|
252
|
-
if (!editModeIsActive.value) {
|
|
253
|
-
return
|
|
254
|
-
}
|
|
255
|
-
const columns = columnStore.columns
|
|
256
|
-
const rows = records.value
|
|
257
|
-
let row = selectedRowIndex.value
|
|
258
|
-
let col = selectedColumnIndex.value
|
|
259
|
-
if (col === columns.length - 1) {
|
|
260
|
-
col = 0
|
|
261
|
-
row = row === rows.length - 1 ? 0 : row + 1
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
col++
|
|
265
|
-
}
|
|
266
|
-
selectedRowIndex.value = row
|
|
267
|
-
selectedColumnIndex.value = col
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function isCellSelected(recordId: string, columnId: string) {
|
|
271
|
-
if (!editModeIsActive.value) {
|
|
272
|
-
return false
|
|
273
|
-
}
|
|
274
|
-
const { row, column: col } = getCellPosition(recordId, columnId)
|
|
275
|
-
return row === selectedRowIndex.value && col === selectedColumnIndex.value
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function reset() {
|
|
279
|
-
isFetching.value = false
|
|
280
|
-
recordsPerPage.value = 10
|
|
281
|
-
currentPage.value = 1
|
|
282
|
-
records.value = []
|
|
283
|
-
metadata.value = {
|
|
284
|
-
count: 0,
|
|
285
|
-
offset: 0,
|
|
286
|
-
limit: recordsPerPage.value,
|
|
287
|
-
}
|
|
288
|
-
selectedRowIndex.value = -1
|
|
289
|
-
selectedColumnIndex.value = -1
|
|
290
|
-
editModeIsActive.value = false
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return {
|
|
294
|
-
metadata,
|
|
295
|
-
records,
|
|
296
|
-
isImporting,
|
|
297
|
-
isFetching,
|
|
298
|
-
isCreating,
|
|
299
|
-
isUpdating,
|
|
300
|
-
isDeleting,
|
|
301
|
-
currentPage,
|
|
302
|
-
recordsPerPage,
|
|
303
|
-
selectedRowIndex,
|
|
304
|
-
selectedColumnIndex,
|
|
305
|
-
editModeIsActive,
|
|
306
|
-
queryPayload,
|
|
307
|
-
selectedRecords,
|
|
308
|
-
reset,
|
|
309
|
-
fetchRecords,
|
|
310
|
-
updateRecord,
|
|
311
|
-
createRecord,
|
|
312
|
-
deleteRecords,
|
|
313
|
-
deleteAllRecords,
|
|
314
|
-
deleteSelectedRecords,
|
|
315
|
-
importRecords,
|
|
316
|
-
exportTableRecords,
|
|
317
|
-
fetchRecordHistory,
|
|
318
|
-
selectCell,
|
|
319
|
-
selectNextCell,
|
|
320
|
-
isCellSelected,
|
|
321
|
-
toggleEditMode,
|
|
322
|
-
changeSelectedRow,
|
|
323
|
-
changeSelectedColumn,
|
|
324
|
-
}
|
|
325
|
-
})
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { Column } from '@antcde/connect-ts/services/ColumnService'
|
|
2
|
-
import type { TableRelation } from '@antcde/connect-ts/services/TableService'
|
|
3
|
-
import { defineStore } from 'pinia'
|
|
4
|
-
import { ref } from 'vue'
|
|
5
|
-
import { useClientStore } from './client'
|
|
6
|
-
import { useTableStore } from './table'
|
|
7
|
-
|
|
8
|
-
export const useRelationStore = defineStore('ant.apps.table.viewer.relations', () => {
|
|
9
|
-
const relations = ref<TableRelation[]>([])
|
|
10
|
-
const columns = ref<Column[]>([])
|
|
11
|
-
const isFetching = ref(false)
|
|
12
|
-
const isUpdating = ref(false)
|
|
13
|
-
const isCreating = ref(false)
|
|
14
|
-
const isDeleting = ref(false)
|
|
15
|
-
const isFetchingColumns = ref(false)
|
|
16
|
-
|
|
17
|
-
const clientStore = useClientStore()
|
|
18
|
-
const { client } = clientStore
|
|
19
|
-
const connect = client?.connect
|
|
20
|
-
const tableStore = useTableStore()
|
|
21
|
-
|
|
22
|
-
async function fetchRelations() {
|
|
23
|
-
try {
|
|
24
|
-
if (!tableStore.table?.id || !connect) {
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
isFetching.value = true
|
|
28
|
-
relations.value = await connect.tables.getRelations(tableStore.table.id)
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
isFetching.value = false
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function fetchTableColumns(id: string) {
|
|
36
|
-
try {
|
|
37
|
-
if (!connect) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
isFetchingColumns.value = true
|
|
41
|
-
columns.value = await connect.columns.getColumns(id)
|
|
42
|
-
}
|
|
43
|
-
finally {
|
|
44
|
-
isFetchingColumns.value = false
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function createRelation(data: Partial<TableRelation>) {
|
|
49
|
-
try {
|
|
50
|
-
if (!connect) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
isCreating.value = true
|
|
54
|
-
const res = await connect.tables.createRelation(data)
|
|
55
|
-
relations.value.push(res)
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
isCreating.value = false
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function deleteRelation(id: string) {
|
|
63
|
-
try {
|
|
64
|
-
if (!connect) {
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
isDeleting.value = true
|
|
68
|
-
await connect.tables.deleteRelation(id)
|
|
69
|
-
relations.value = relations.value.filter(r => r.id !== id)
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
isDeleting.value = false
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
relations,
|
|
78
|
-
columns,
|
|
79
|
-
isFetching,
|
|
80
|
-
isUpdating,
|
|
81
|
-
isCreating,
|
|
82
|
-
isDeleting,
|
|
83
|
-
isFetchingColumns,
|
|
84
|
-
fetchRelations,
|
|
85
|
-
fetchTableColumns,
|
|
86
|
-
createRelation,
|
|
87
|
-
deleteRelation,
|
|
88
|
-
}
|
|
89
|
-
})
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import type { TableRecord, TableRevision } from '@antcde/connect-ts/services/TableService'
|
|
2
|
-
import { defineStore } from 'pinia'
|
|
3
|
-
import { computed, ref } from 'vue'
|
|
4
|
-
import { useClientStore } from './client'
|
|
5
|
-
import { useTableStore } from './table'
|
|
6
|
-
|
|
7
|
-
export const useRevisionStore = defineStore('ant.apps.table.viewer.revisions', () => {
|
|
8
|
-
const revisions = ref<TableRevision[]>([])
|
|
9
|
-
|
|
10
|
-
const isCreating = ref(false)
|
|
11
|
-
const isFetching = ref(false)
|
|
12
|
-
const inComparisonMode = ref(false)
|
|
13
|
-
const isLoadingComparisonData = ref(false)
|
|
14
|
-
|
|
15
|
-
const firstRevision = ref<TableRevision | null>(null)
|
|
16
|
-
const firstRevisionRecords = ref<TableRecord[]>([])
|
|
17
|
-
|
|
18
|
-
const secondRevision = ref<TableRevision | null>(null)
|
|
19
|
-
const secondRevisionRecords = ref<TableRecord[]>([])
|
|
20
|
-
|
|
21
|
-
const tableStore = useTableStore()
|
|
22
|
-
const clientStore = useClientStore()
|
|
23
|
-
const { client } = clientStore
|
|
24
|
-
const connect = client?.connect
|
|
25
|
-
|
|
26
|
-
async function addRevision(revisionReason: string) {
|
|
27
|
-
const table = tableStore.table
|
|
28
|
-
if (!table || !connect) {
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
isCreating.value = true
|
|
32
|
-
const revision = await connect.tables.createTableRevision(
|
|
33
|
-
table.id,
|
|
34
|
-
revisionReason,
|
|
35
|
-
table.project,
|
|
36
|
-
)
|
|
37
|
-
isCreating.value = false
|
|
38
|
-
revisions.value.push(revision)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function fetchRevisions() {
|
|
42
|
-
isFetching.value = true
|
|
43
|
-
|
|
44
|
-
const table = tableStore.table
|
|
45
|
-
|
|
46
|
-
if (!table || !connect) {
|
|
47
|
-
isFetching.value = false
|
|
48
|
-
revisions.value = []
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
revisions.value = await connect.tables.getTableRevisions(table.id)
|
|
53
|
-
isFetching.value = false
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function compareRevisions(revision1: null | TableRevision, revision2: null | TableRevision) {
|
|
57
|
-
const table = tableStore.table
|
|
58
|
-
|
|
59
|
-
if (!table || !connect) {
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
isLoadingComparisonData.value = true
|
|
64
|
-
inComparisonMode.value = true
|
|
65
|
-
|
|
66
|
-
firstRevision.value = revision1
|
|
67
|
-
secondRevision.value = revision2
|
|
68
|
-
|
|
69
|
-
const [firstRevisionResponse, secondRevisionResponse] = await Promise.allSettled([
|
|
70
|
-
connect.records.getRevisionRecords(table.project, table.id, revision1?.id),
|
|
71
|
-
connect.records.getRevisionRecords(table.project, table.id, revision2?.id),
|
|
72
|
-
])
|
|
73
|
-
|
|
74
|
-
if (firstRevisionResponse.status === 'fulfilled') {
|
|
75
|
-
firstRevisionRecords.value = firstRevisionResponse.value.records as TableRecord[]
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (secondRevisionResponse.status === 'fulfilled') {
|
|
79
|
-
secondRevisionRecords.value = secondRevisionResponse.value.records as TableRecord[]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
isLoadingComparisonData.value = false
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function setFirstRevision(revision: null | TableRevision) {
|
|
86
|
-
isLoadingComparisonData.value = true
|
|
87
|
-
|
|
88
|
-
firstRevision.value = revision
|
|
89
|
-
|
|
90
|
-
const table = tableStore.table
|
|
91
|
-
|
|
92
|
-
if (!table || !connect) {
|
|
93
|
-
return
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
await connect.records
|
|
97
|
-
.getRevisionRecords(table.project, table.id, revision?.id)
|
|
98
|
-
.then(({ records }) => (firstRevisionRecords.value = records))
|
|
99
|
-
.finally(() => (isLoadingComparisonData.value = false))
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function setSecondRevision(revision: null | TableRevision) {
|
|
103
|
-
isLoadingComparisonData.value = true
|
|
104
|
-
|
|
105
|
-
secondRevision.value = revision
|
|
106
|
-
|
|
107
|
-
const table = tableStore.table
|
|
108
|
-
|
|
109
|
-
if (!table || !connect) {
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
await connect.records
|
|
114
|
-
.getRevisionRecords(table.project, table.id, revision?.id)
|
|
115
|
-
.then(({ records }) => (secondRevisionRecords.value = records))
|
|
116
|
-
.finally(() => (isLoadingComparisonData.value = false))
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function swapRevisions() {
|
|
120
|
-
const tempRevision = { ...firstRevision.value } as TableRevision
|
|
121
|
-
firstRevision.value = { ...secondRevision.value } as TableRevision
|
|
122
|
-
secondRevision.value = tempRevision as TableRevision
|
|
123
|
-
|
|
124
|
-
const tempRecords = [...firstRevisionRecords.value]
|
|
125
|
-
firstRevisionRecords.value = [...secondRevisionRecords.value]
|
|
126
|
-
secondRevisionRecords.value = tempRecords
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function reset() {
|
|
130
|
-
isCreating.value = false
|
|
131
|
-
isLoadingComparisonData.value = false
|
|
132
|
-
isFetching.value = false
|
|
133
|
-
inComparisonMode.value = false
|
|
134
|
-
|
|
135
|
-
revisions.value = []
|
|
136
|
-
firstRevision.value = null
|
|
137
|
-
secondRevision.value = null
|
|
138
|
-
firstRevisionRecords.value = []
|
|
139
|
-
secondRevisionRecords.value = []
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const sortedRevisions = computed(() => revisions.value.sort((a, b) => b.version - a.version))
|
|
143
|
-
|
|
144
|
-
const comparisonRecords = computed(() => {
|
|
145
|
-
const records: { new: TableRecord | null, old: TableRecord | null }[] = []
|
|
146
|
-
firstRevisionRecords.value.forEach((record: TableRecord) => {
|
|
147
|
-
const revisionRecord = secondRevisionRecords.value.find(
|
|
148
|
-
revisionRecord => revisionRecord.id === record.id,
|
|
149
|
-
)
|
|
150
|
-
if (!revisionRecord) {
|
|
151
|
-
records.push({
|
|
152
|
-
new: record,
|
|
153
|
-
old: null,
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
records.push({
|
|
158
|
-
new: record,
|
|
159
|
-
old: revisionRecord,
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
secondRevisionRecords.value.forEach((record: TableRecord) => {
|
|
164
|
-
const firstRecord = firstRevisionRecords.value.find(rec => rec.id === record.id)
|
|
165
|
-
if (firstRecord) {
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
records.push({
|
|
169
|
-
new: null,
|
|
170
|
-
old: record,
|
|
171
|
-
})
|
|
172
|
-
})
|
|
173
|
-
return records
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
isCreating,
|
|
178
|
-
isFetching,
|
|
179
|
-
inComparisonMode,
|
|
180
|
-
isLoadingComparisonData,
|
|
181
|
-
firstRevision,
|
|
182
|
-
secondRevision,
|
|
183
|
-
revisions,
|
|
184
|
-
sortedRevisions,
|
|
185
|
-
comparisonRecords,
|
|
186
|
-
reset,
|
|
187
|
-
addRevision,
|
|
188
|
-
fetchRevisions,
|
|
189
|
-
swapRevisions,
|
|
190
|
-
compareRevisions,
|
|
191
|
-
setFirstRevision,
|
|
192
|
-
setSecondRevision,
|
|
193
|
-
}
|
|
194
|
-
})
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { PermissionData } from '@antcde/connect-ts/services/RBAC/PermissionService'
|
|
2
|
-
import type { Role, RoleData, RoleUpdate } from '@antcde/connect-ts/services/RBAC/RoleService'
|
|
3
|
-
import { defineStore } from 'pinia'
|
|
4
|
-
import { ref } from 'vue'
|
|
5
|
-
import { useClientStore } from './client'
|
|
6
|
-
|
|
7
|
-
export const useRoleStore = defineStore('ant.apps.table.viewer.rbacRoles', () => {
|
|
8
|
-
const roles = ref<Role[]>([])
|
|
9
|
-
const selectedRole = ref<Role | null>(null)
|
|
10
|
-
const isFetching = ref(false)
|
|
11
|
-
const isCreating = ref(false)
|
|
12
|
-
|
|
13
|
-
const clientStore = useClientStore()
|
|
14
|
-
const { client } = clientStore
|
|
15
|
-
const connect = client?.connect
|
|
16
|
-
|
|
17
|
-
async function fetchRoles(resourceId?: string) {
|
|
18
|
-
if (!resourceId || !connect) {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
isFetching.value = true
|
|
23
|
-
const rolesResponse = await connect.rbacRoles.fetchRoles('projects', resourceId) // TODO Add licenses if needed
|
|
24
|
-
roles.value = rolesResponse?.data ?? []
|
|
25
|
-
}
|
|
26
|
-
finally {
|
|
27
|
-
isFetching.value = false
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function createRole(data: RoleData, resourceId?: string) {
|
|
32
|
-
if (!resourceId || !connect) {
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
isCreating.value = true
|
|
37
|
-
const createdRoleResponse = await connect.rbacRoles.createRole('projects', resourceId, data)
|
|
38
|
-
roles.value.push(createdRoleResponse.data)
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
isCreating.value = false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function updateRole(roleId: string, data: RoleUpdate) {
|
|
46
|
-
if (!connect) {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
const updatedRoleResponse = await connect.rbacRoles.updateRole(roleId, data)
|
|
50
|
-
const roleIndex = roles.value.findIndex(role => role.id === roleId)
|
|
51
|
-
roles.value.splice(roleIndex, 1, updatedRoleResponse.data)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function syncPermissions(roleId: string, permissions: PermissionData[]) {
|
|
55
|
-
if (!connect) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
const permissionResponse = await connect.rbacRoles.syncPermissions(roleId, permissions)
|
|
59
|
-
const roleIndex = roles.value.findIndex(role => role.id === roleId)
|
|
60
|
-
roles.value[roleIndex].permissions = permissionResponse.data
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function givePermission(roleId: string, permission: PermissionData) {
|
|
64
|
-
if (!connect) {
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
const permissionResponse = await connect.rbacRoles.givePermission(roleId, permission)
|
|
68
|
-
const roleIndex = roles.value.findIndex(role => role.id === roleId)
|
|
69
|
-
roles.value[roleIndex].permissions?.push(permissionResponse.data)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function revokePermission(roleId: string, permission: PermissionData) {
|
|
73
|
-
if (!connect) {
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
const permissionResponse = await connect.rbacRoles.revokePermission(roleId, permission)
|
|
77
|
-
const roleIndex = roles.value.findIndex(role => role.id === roleId)
|
|
78
|
-
roles.value[roleIndex].permissions = roles.value[roleIndex].permissions?.filter(p => p.id !== permissionResponse.data.id)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function syncUsers(roleId: string, users: string[]) {
|
|
82
|
-
if (!connect) {
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
const userResponse = await connect.rbacRoles.syncUsers(roleId, users)
|
|
86
|
-
const roleIndex = roles.value.findIndex(role => role.id === roleId)
|
|
87
|
-
roles.value[roleIndex].users = userResponse.data
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function reset() {
|
|
91
|
-
roles.value = []
|
|
92
|
-
selectedRole.value = null
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
roles,
|
|
97
|
-
selectedRole,
|
|
98
|
-
isFetching,
|
|
99
|
-
isCreating,
|
|
100
|
-
reset,
|
|
101
|
-
updateRole,
|
|
102
|
-
createRole,
|
|
103
|
-
fetchRoles,
|
|
104
|
-
givePermission,
|
|
105
|
-
syncPermissions,
|
|
106
|
-
revokePermission,
|
|
107
|
-
syncUsers,
|
|
108
|
-
}
|
|
109
|
-
})
|