@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,136 +0,0 @@
|
|
|
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>
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { TableList } from '@antcde/connect-ts'
|
|
3
|
-
import DeleteConfirmationDialog from '../Dialog/DeleteConfirmationDialog.vue'
|
|
4
|
-
import { ref } from 'vue'
|
|
5
|
-
import { storeToRefs } from 'pinia'
|
|
6
|
-
import { useTableStore } from '../../stores/table'
|
|
7
|
-
import { useRecordStore } from '../../stores/records'
|
|
8
|
-
|
|
9
|
-
const emit = defineEmits<{
|
|
10
|
-
(e: 'edit'): void
|
|
11
|
-
}>()
|
|
12
|
-
|
|
13
|
-
defineProps<{
|
|
14
|
-
table: TableList
|
|
15
|
-
selectedTable: TableList | null
|
|
16
|
-
permissions: {
|
|
17
|
-
canCreate: boolean
|
|
18
|
-
canUpdate: boolean
|
|
19
|
-
canDelete: boolean
|
|
20
|
-
canConfigure: boolean
|
|
21
|
-
}
|
|
22
|
-
}>()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const tableStore = useTableStore()
|
|
26
|
-
|
|
27
|
-
const recordStore = useRecordStore()
|
|
28
|
-
const { selectedRecords } = storeToRefs(recordStore)
|
|
29
|
-
|
|
30
|
-
const showDeleteConfirmation = ref(false)
|
|
31
|
-
const showDeleteAllConfirmation = ref(false)
|
|
32
|
-
const showDeleteSelectedConfirmation = ref(false)
|
|
33
|
-
|
|
34
|
-
const fileInputRef = ref<HTMLInputElement | null>(null) // Ref for hidden input
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Handle CSV file change and process API call
|
|
38
|
-
async function handleFileChange(event: Event) {
|
|
39
|
-
const target = event.target as HTMLInputElement
|
|
40
|
-
if (!target.files || target.files.length === 0) {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const file = target.files[0]
|
|
45
|
-
if (file) {
|
|
46
|
-
await recordStore.importRecords(file)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Clear the input value so the same file can be uploaded again
|
|
50
|
-
target.value = ''
|
|
51
|
-
}
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<template>
|
|
55
|
-
<delete-confirmation-dialog
|
|
56
|
-
v-model="showDeleteConfirmation"
|
|
57
|
-
:message="`Are you sure you want to delete the table ${table.name}? This action cannot be undone.`"
|
|
58
|
-
@confirm="tableStore.deleteTable"
|
|
59
|
-
/>
|
|
60
|
-
|
|
61
|
-
<delete-confirmation-dialog
|
|
62
|
-
v-model="showDeleteSelectedConfirmation"
|
|
63
|
-
:message="`Are you sure you want to delete selected records in the table ${table.name}? This action cannot be undone.`"
|
|
64
|
-
@confirm="recordStore.deleteSelectedRecords"
|
|
65
|
-
/>
|
|
66
|
-
|
|
67
|
-
<delete-confirmation-dialog
|
|
68
|
-
v-model="showDeleteAllConfirmation"
|
|
69
|
-
:message="`Are you sure you want to delete all records in the table ${table.name}? This action cannot be undone.`"
|
|
70
|
-
@confirm="recordStore.deleteAllRecords"
|
|
71
|
-
/>
|
|
72
|
-
|
|
73
|
-
<input
|
|
74
|
-
ref="fileInputRef"
|
|
75
|
-
type="file"
|
|
76
|
-
accept=".csv"
|
|
77
|
-
@change="handleFileChange"
|
|
78
|
-
class="hidden"
|
|
79
|
-
/>
|
|
80
|
-
|
|
81
|
-
<v-list-item
|
|
82
|
-
:active="selectedTable?.id === table?.id"
|
|
83
|
-
color="primary"
|
|
84
|
-
rounded="shaped"
|
|
85
|
-
:title="table.name"
|
|
86
|
-
@click="() => selectedTable?.id === table.id ? null : tableStore.fetchTable(table.id)"
|
|
87
|
-
>
|
|
88
|
-
<template v-if="selectedTable?.id === table?.id && permissions.canConfigure" #append>
|
|
89
|
-
<v-list-item-action class="flex-column align-end">
|
|
90
|
-
<v-menu position="start">
|
|
91
|
-
<template #activator="{ props: activatorProps }">
|
|
92
|
-
<v-btn
|
|
93
|
-
v-bind="activatorProps"
|
|
94
|
-
variant="text"
|
|
95
|
-
icon="mdi-dots-horizontal"
|
|
96
|
-
size="small"
|
|
97
|
-
color="primary"
|
|
98
|
-
/>
|
|
99
|
-
</template>
|
|
100
|
-
<v-card width="300" class="px-2">
|
|
101
|
-
<v-list>
|
|
102
|
-
<v-list-item
|
|
103
|
-
color="primary"
|
|
104
|
-
title="Edit Table"
|
|
105
|
-
density="compact"
|
|
106
|
-
prepend-icon="mdi-table-edit"
|
|
107
|
-
rounded="shaped"
|
|
108
|
-
@click="emit('edit')"
|
|
109
|
-
/>
|
|
110
|
-
<v-divider />
|
|
111
|
-
<v-list-item
|
|
112
|
-
color="primary"
|
|
113
|
-
title="Import Records"
|
|
114
|
-
density="compact"
|
|
115
|
-
prepend-icon="mdi-import"
|
|
116
|
-
rounded="shaped"
|
|
117
|
-
@click="fileInputRef?.click()"
|
|
118
|
-
/>
|
|
119
|
-
|
|
120
|
-
<v-list-item
|
|
121
|
-
color="primary"
|
|
122
|
-
title="Export Records"
|
|
123
|
-
density="compact"
|
|
124
|
-
prepend-icon="mdi-export"
|
|
125
|
-
rounded="shaped"
|
|
126
|
-
@click="recordStore.exportTableRecords"
|
|
127
|
-
/>
|
|
128
|
-
<v-divider />
|
|
129
|
-
|
|
130
|
-
<v-list-item
|
|
131
|
-
color="danger"
|
|
132
|
-
:disabled="!selectedRecords.length"
|
|
133
|
-
title="Delete selected Records"
|
|
134
|
-
prepend-icon="mdi-table-off"
|
|
135
|
-
density="compact"
|
|
136
|
-
rounded="shaped"
|
|
137
|
-
@click="() => (showDeleteSelectedConfirmation = true)"
|
|
138
|
-
/>
|
|
139
|
-
|
|
140
|
-
<v-list-item
|
|
141
|
-
color="danger"
|
|
142
|
-
title="Delete all Records"
|
|
143
|
-
prepend-icon="mdi-table-off"
|
|
144
|
-
density="compact"
|
|
145
|
-
rounded="shaped"
|
|
146
|
-
@click="() => (showDeleteAllConfirmation = true)"
|
|
147
|
-
/>
|
|
148
|
-
<v-list-item
|
|
149
|
-
color="error"
|
|
150
|
-
title="Delete Table"
|
|
151
|
-
density="compact"
|
|
152
|
-
prepend-icon="mdi-table-remove"
|
|
153
|
-
rounded="shaped"
|
|
154
|
-
@click="() => (showDeleteConfirmation = true)"
|
|
155
|
-
/>
|
|
156
|
-
</v-list>
|
|
157
|
-
</v-card>
|
|
158
|
-
</v-menu>
|
|
159
|
-
</v-list-item-action>
|
|
160
|
-
</template>
|
|
161
|
-
</v-list-item>
|
|
162
|
-
</template>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { ApplicationProps } from '../../types/app'
|
|
3
|
-
import { storeToRefs } from 'pinia'
|
|
4
|
-
import RecordsTable from '../Records/RecordsTable.vue'
|
|
5
|
-
import RevisionComparisonTable from '../Revisions/RevisionComparisonTable.vue'
|
|
6
|
-
import { useClientStore } from '../../stores/client'
|
|
7
|
-
import { useRevisionStore } from '../../stores/revisions'
|
|
8
|
-
import { useTableStore } from '../../stores/table'
|
|
9
|
-
|
|
10
|
-
const { client } = defineProps<ApplicationProps>()
|
|
11
|
-
|
|
12
|
-
const clientStore = useClientStore()
|
|
13
|
-
clientStore.setClient(client)
|
|
14
|
-
|
|
15
|
-
const tableStore = useTableStore()
|
|
16
|
-
|
|
17
|
-
const revisionStore = useRevisionStore()
|
|
18
|
-
const { inComparisonMode } = storeToRefs(revisionStore)
|
|
19
|
-
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<template>
|
|
23
|
-
<v-skeleton-loader v-if="tableStore.isFetching" type="table" />
|
|
24
|
-
<records-table v-else />
|
|
25
|
-
<!-- <template v-else>
|
|
26
|
-
<revision-comparison-table v-if="inComparisonMode" />
|
|
27
|
-
</template> -->
|
|
28
|
-
</template>
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { TableList } from '@antcde/connect-ts'
|
|
3
|
-
import { storeToRefs } from 'pinia'
|
|
4
|
-
import { computed, ref } from 'vue'
|
|
5
|
-
import { useTableStore } from '../../stores/table'
|
|
6
|
-
import { useTablesStore } from '../../stores/tables'
|
|
7
|
-
import TableItem from './TableItem.vue'
|
|
8
|
-
import { useRecordStore } from '../../stores/records'
|
|
9
|
-
|
|
10
|
-
const props = defineProps<{
|
|
11
|
-
tables: TableList[]
|
|
12
|
-
canCreate: boolean
|
|
13
|
-
}>()
|
|
14
|
-
|
|
15
|
-
const emit = defineEmits<{
|
|
16
|
-
(e: 'table:edit'): void
|
|
17
|
-
}>()
|
|
18
|
-
|
|
19
|
-
const tableStore = useTableStore()
|
|
20
|
-
|
|
21
|
-
const { table: selectedTable, isCreating, permissions } = storeToRefs(tableStore)
|
|
22
|
-
|
|
23
|
-
const searchTerm = ref('')
|
|
24
|
-
|
|
25
|
-
const tableData = ref({
|
|
26
|
-
name: ''
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
const displayedTables = computed(() =>
|
|
30
|
-
props.tables.filter((table) => table.name.toLowerCase().includes(searchTerm.value.toLowerCase()))
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
function createTable() {
|
|
34
|
-
if (tableData.value.name.length === 0) {
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
tableStore.createTable(tableData.value.name).then(() => {
|
|
38
|
-
tableData.value.name = ''
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<template>
|
|
44
|
-
<v-list>
|
|
45
|
-
<v-list-item class="" color="info" rounded="lg">
|
|
46
|
-
<v-text-field
|
|
47
|
-
v-model="searchTerm"
|
|
48
|
-
class="w-full"
|
|
49
|
-
variant="outlined"
|
|
50
|
-
density="compact"
|
|
51
|
-
color="primary"
|
|
52
|
-
placeholder="Search..."
|
|
53
|
-
hide-details
|
|
54
|
-
>
|
|
55
|
-
<template v-if="canCreate" #append>
|
|
56
|
-
<v-menu :close-on-content-click="false" offset-y transition="slide-y-transition">
|
|
57
|
-
<template #activator="{ props: activatorProps }">
|
|
58
|
-
<v-btn
|
|
59
|
-
v-bind="activatorProps"
|
|
60
|
-
class="!h-full"
|
|
61
|
-
prepend-icon="mdi-plus"
|
|
62
|
-
size="small"
|
|
63
|
-
color="primary"
|
|
64
|
-
variant="tonal"
|
|
65
|
-
text="New Table"
|
|
66
|
-
density="default"
|
|
67
|
-
/>
|
|
68
|
-
</template>
|
|
69
|
-
<v-card width="300">
|
|
70
|
-
<v-card-item>
|
|
71
|
-
<v-sheet class="d-flex flex-column">
|
|
72
|
-
<v-label class="mr-2 font-semibold"> Table Name </v-label>
|
|
73
|
-
<v-text-field
|
|
74
|
-
v-model="tableData.name"
|
|
75
|
-
variant="outlined"
|
|
76
|
-
color="primary"
|
|
77
|
-
density="compact"
|
|
78
|
-
placeholder="Table Name"
|
|
79
|
-
hint="Press enter to create"
|
|
80
|
-
persistent-hint
|
|
81
|
-
@keydown.enter="createTable"
|
|
82
|
-
/>
|
|
83
|
-
</v-sheet>
|
|
84
|
-
<v-divider class="my-4" />
|
|
85
|
-
<v-sheet class="d-flex gap-4 justify-end">
|
|
86
|
-
<v-btn
|
|
87
|
-
color="primary"
|
|
88
|
-
variant="tonal"
|
|
89
|
-
:disabled="isCreating || tableData.name.length === 0"
|
|
90
|
-
@click="createTable"
|
|
91
|
-
>
|
|
92
|
-
Create
|
|
93
|
-
</v-btn>
|
|
94
|
-
</v-sheet>
|
|
95
|
-
</v-card-item>
|
|
96
|
-
</v-card>
|
|
97
|
-
</v-menu>
|
|
98
|
-
</template>
|
|
99
|
-
</v-text-field>
|
|
100
|
-
</v-list-item>
|
|
101
|
-
|
|
102
|
-
<v-divider class="my-4" />
|
|
103
|
-
|
|
104
|
-
<table-item
|
|
105
|
-
v-for="table in displayedTables"
|
|
106
|
-
:key="table.id"
|
|
107
|
-
:table="table"
|
|
108
|
-
:selected-table="selectedTable"
|
|
109
|
-
:permissions="permissions"
|
|
110
|
-
@edit="emit('table:edit')"
|
|
111
|
-
/>
|
|
112
|
-
|
|
113
|
-
</v-list>
|
|
114
|
-
</template>
|
|
115
|
-
|
|
116
|
-
<style scoped></style>
|
package/lib/TableViewer/index.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { FileResponse } from '@antcde/connect-ts/services/ProjectService'
|
|
2
|
-
import type { FileInRequest } from '@antcde/connect-ts/services/UserService'
|
|
3
|
-
|
|
4
|
-
const FileHandler = {
|
|
5
|
-
handleFile(file: File): Promise<FileInRequest> | undefined {
|
|
6
|
-
if (typeof file === 'object') {
|
|
7
|
-
const selectedFile = file
|
|
8
|
-
const apiObject: FileInRequest = {
|
|
9
|
-
name: '',
|
|
10
|
-
extension: '',
|
|
11
|
-
data: '',
|
|
12
|
-
}
|
|
13
|
-
apiObject.name = this.getFileName(selectedFile.name)
|
|
14
|
-
apiObject.extension = this.getFileExtension(selectedFile.name)
|
|
15
|
-
|
|
16
|
-
return new Promise((resolve) => {
|
|
17
|
-
const reader = new FileReader()
|
|
18
|
-
reader.readAsDataURL(file)
|
|
19
|
-
reader.onloadend = (e) => {
|
|
20
|
-
const re = /(?:base64,(.*))?$/
|
|
21
|
-
apiObject.data = re.exec(e.target.result)[1]
|
|
22
|
-
|
|
23
|
-
resolve(apiObject)
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
getFileExtension(fileName: string) {
|
|
29
|
-
const re = /(?:\.([^.]+))?$/
|
|
30
|
-
|
|
31
|
-
return re.exec(fileName)[1]
|
|
32
|
-
},
|
|
33
|
-
getFileName(fileName: string) {
|
|
34
|
-
const extension = fileName.substring(fileName.lastIndexOf('.'))
|
|
35
|
-
return fileName.replace(extension, '')
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
async downloadFile(file: File | Uint8Array | string, fileName: string, fileType: string) {
|
|
39
|
-
const blob = new Blob([file], { type: fileType })
|
|
40
|
-
const url = window.URL.createObjectURL(blob)
|
|
41
|
-
const link = document.createElement('a')
|
|
42
|
-
|
|
43
|
-
link.setAttribute('href', url)
|
|
44
|
-
link.setAttribute('download', `${fileName}.${fileType}`)
|
|
45
|
-
link.style.visibility = 'hidden'
|
|
46
|
-
document.body.appendChild(link)
|
|
47
|
-
link.click()
|
|
48
|
-
document.body.removeChild(link)
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
async b64toUint8Array(base64Data: string) {
|
|
52
|
-
const byteCharacters = atob(base64Data)
|
|
53
|
-
const byteNumbers = new Array(byteCharacters.length)
|
|
54
|
-
|
|
55
|
-
for (let i = 0; i < byteCharacters.length; i++) {
|
|
56
|
-
byteNumbers[i] = byteCharacters.charCodeAt(i)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return new Uint8Array(byteNumbers)
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
async downloadRecordDocument(projectId: string, tableId: string, documentId: string, connect: any) {
|
|
63
|
-
if (!connect)
|
|
64
|
-
return
|
|
65
|
-
const response: FileResponse = await connect.records.getRecordDocument(
|
|
66
|
-
projectId,
|
|
67
|
-
tableId,
|
|
68
|
-
documentId,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
const element = document.createElement('a')
|
|
72
|
-
element.setAttribute('href', `data:${response.mimetype};base64,${response.file}`)
|
|
73
|
-
element.setAttribute('download', `${response.name}.${response.extension}`)
|
|
74
|
-
|
|
75
|
-
element.style.display = 'none'
|
|
76
|
-
document.body.appendChild(element)
|
|
77
|
-
|
|
78
|
-
element.click()
|
|
79
|
-
|
|
80
|
-
document.body.removeChild(element)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default FileHandler
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { UseCommsClient } from '@antcde/vue-utils'
|
|
2
|
-
import { defineStore } from 'pinia'
|
|
3
|
-
import { ref } from 'vue'
|
|
4
|
-
|
|
5
|
-
export const useClientStore = defineStore('ant.apps.table.viewer.client', () => {
|
|
6
|
-
const client = ref<UseCommsClient | null>(null)
|
|
7
|
-
|
|
8
|
-
function setClient(appClient: UseCommsClient) {
|
|
9
|
-
if (!client.value) {
|
|
10
|
-
client.value = appClient
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
client,
|
|
16
|
-
setClient,
|
|
17
|
-
}
|
|
18
|
-
})
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { ColumnRelation, StoreRelationRequestData } from '@antcde/connect-ts/services/Table/ColumnRelationService'
|
|
2
|
-
import { defineStore, storeToRefs } from 'pinia'
|
|
3
|
-
import qs from 'qs'
|
|
4
|
-
import { computed } from 'vue'
|
|
5
|
-
import { useClientStore } from './client'
|
|
6
|
-
import { useColumnStore } from './columns'
|
|
7
|
-
import { useTablesStore } from './tables'
|
|
8
|
-
|
|
9
|
-
export const useColumnRelationStore = defineStore('ant.apps.table.viewer.columns.relation', () => {
|
|
10
|
-
const clientStore = useClientStore()
|
|
11
|
-
const columnStore = useColumnStore()
|
|
12
|
-
const tablesStore = useTablesStore()
|
|
13
|
-
|
|
14
|
-
const { client } = clientStore
|
|
15
|
-
const { tables } = storeToRefs(tablesStore)
|
|
16
|
-
|
|
17
|
-
const connect = computed(() => client?.connect)
|
|
18
|
-
const context = computed(() => client?.context)
|
|
19
|
-
|
|
20
|
-
const license = computed(() => context.value?.license)
|
|
21
|
-
const project = computed(() => context.value?.project)
|
|
22
|
-
|
|
23
|
-
async function addColumnRelation(columnId: string, data: StoreRelationRequestData) {
|
|
24
|
-
const columnRelation = await connect.value?.columnRelations.addColumnRelation(
|
|
25
|
-
columnId,
|
|
26
|
-
data,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
if (!columnRelation) {
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
columnStore.setColumnRelation(columnId, columnRelation?.data)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function deleteColumnRelation(columnId: string, columnRelationId: string) {
|
|
37
|
-
await connect.value?.columnRelations.deleteColumnRelation(columnId, columnRelationId)
|
|
38
|
-
columnStore.setColumnRelation(columnId, null)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function updateColumnRelation(columnId: string, columnRelationId: string, data: Partial<ColumnRelation>) {
|
|
42
|
-
const columnRelation = await connect.value?.columnRelations.updateColumnRelation(columnId, columnRelationId, data)
|
|
43
|
-
|
|
44
|
-
if (!columnRelation) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
columnStore.setColumnRelation(columnId, columnRelation?.data)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function prepareTaskQueryPayload(projectId: string, searchTerm: string) {
|
|
52
|
-
return qs.stringify({
|
|
53
|
-
filters: {
|
|
54
|
-
project: {
|
|
55
|
-
$eq: projectId,
|
|
56
|
-
},
|
|
57
|
-
title: {
|
|
58
|
-
$contains: searchTerm,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
fields: {
|
|
62
|
-
tasks: ['id', 'title'].join(','),
|
|
63
|
-
},
|
|
64
|
-
sort: ['title'],
|
|
65
|
-
per_page: 10,
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function getRelationOptions(relation: ColumnRelation, searchTerm: string) {
|
|
70
|
-
if (!license.value || !project.value) {
|
|
71
|
-
return Promise.resolve([])
|
|
72
|
-
}
|
|
73
|
-
const { related_entity, related_table_id } = relation
|
|
74
|
-
switch (related_entity) {
|
|
75
|
-
case 'project':
|
|
76
|
-
return connect.value?.projects.getProjects(license.value.id, {
|
|
77
|
-
filters: searchTerm ? { name: searchTerm } : {},
|
|
78
|
-
})
|
|
79
|
-
case 'task':
|
|
80
|
-
return (await connect.value?.tasks.getV2Tasks(
|
|
81
|
-
license.value.id,
|
|
82
|
-
prepareTaskQueryPayload(project.value.id, searchTerm),
|
|
83
|
-
))?.data || []
|
|
84
|
-
case 'user':
|
|
85
|
-
return (await connect.value?.projectUsers.fetchUsers(project.value.id))?.data || []
|
|
86
|
-
case 'table':
|
|
87
|
-
return tables.value
|
|
88
|
-
case 'table_record':
|
|
89
|
-
return (await connect.value?.records.getRecords(project.value.id, related_table_id ?? '', {
|
|
90
|
-
searchFields: ['id', relation.display_label ?? 'id'],
|
|
91
|
-
search: {
|
|
92
|
-
phrase: searchTerm,
|
|
93
|
-
},
|
|
94
|
-
}))?.records || []
|
|
95
|
-
default:
|
|
96
|
-
break
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
getRelationOptions,
|
|
102
|
-
addColumnRelation,
|
|
103
|
-
deleteColumnRelation,
|
|
104
|
-
updateColumnRelation,
|
|
105
|
-
}
|
|
106
|
-
})
|