@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
|
@@ -3,14 +3,15 @@ import type { DmsFile } from '@antcde/connect-ts'
|
|
|
3
3
|
import type { UseCommsClient } from '@antcde/vue-utils'
|
|
4
4
|
import { BaseClickableIcon, BaseConfirmDialog } from '@antcde/component-library'
|
|
5
5
|
import { clone } from '@antcde/connect-ts'
|
|
6
|
+
import { useAntColorMode } from '@antcde/vue-utils'
|
|
6
7
|
import { useDateFormat } from '@vueuse/core'
|
|
7
8
|
import dayjs from 'dayjs'
|
|
8
9
|
|
|
9
10
|
import { computed, reactive, ref, watch } from 'vue'
|
|
10
11
|
import { useI18n } from 'vue-i18n'
|
|
11
12
|
import { useRoute, useRouter } from 'vue-router'
|
|
13
|
+
import { useTheme } from 'vuetify'
|
|
12
14
|
import DocumentDrop from './DocumentDrop.vue'
|
|
13
|
-
import { useDarkMode } from './hooks/useDarkMode'
|
|
14
15
|
import { useDms } from './hooks/useDms'
|
|
15
16
|
import { isImageExtension } from './utils'
|
|
16
17
|
|
|
@@ -22,7 +23,6 @@ const { client } = defineProps<ApplicationProps>()
|
|
|
22
23
|
|
|
23
24
|
const { data, isFetching, isCreating, isUploading, getPreviewUrl, createFolder, fetchData, uploadFileS3, getDownloadUrl, deleteFile } = useDms(client)
|
|
24
25
|
|
|
25
|
-
useDarkMode(client)
|
|
26
26
|
const { t } = useI18n()
|
|
27
27
|
|
|
28
28
|
const itemMenu = ref(false)
|
|
@@ -38,8 +38,13 @@ const folderName = ref('')
|
|
|
38
38
|
|
|
39
39
|
const route = useRoute()
|
|
40
40
|
const router = useRouter()
|
|
41
|
+
const colorMode = useAntColorMode(client)
|
|
42
|
+
const theme = useTheme()
|
|
41
43
|
|
|
42
44
|
const sortBy = ref([{ key: 'title_sort', order: 'asc' }])
|
|
45
|
+
|
|
46
|
+
watch(colorMode.isDark, isDark => theme.global.name.value = isDark ? 'dark' : 'light')
|
|
47
|
+
|
|
43
48
|
watch(
|
|
44
49
|
() => sortBy.value,
|
|
45
50
|
(update) => {
|
|
@@ -270,8 +275,8 @@ async function getPreviewUrlHandler(item: DmsFile) {
|
|
|
270
275
|
</script>
|
|
271
276
|
|
|
272
277
|
<template>
|
|
273
|
-
<
|
|
274
|
-
<v-card class="
|
|
278
|
+
<v-card rounded="0" border="0" class="d-flex flex-row flex-1 pa-6">
|
|
279
|
+
<v-card class="d-flex flex-column flex-1">
|
|
275
280
|
<input
|
|
276
281
|
id="file-input-dms"
|
|
277
282
|
ref="fileInput"
|
|
@@ -494,7 +499,7 @@ async function getPreviewUrlHandler(item: DmsFile) {
|
|
|
494
499
|
</v-col>
|
|
495
500
|
</v-row>
|
|
496
501
|
</v-card>
|
|
497
|
-
</
|
|
502
|
+
</v-card>
|
|
498
503
|
<v-dialog
|
|
499
504
|
v-model="isFolderDialogShown"
|
|
500
505
|
width="auto"
|
|
@@ -1,205 +1,79 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { ApplicationProps } from './types/app'
|
|
3
|
-
import type { TableList } from './types/tables'
|
|
4
|
-
|
|
5
3
|
import { storeToRefs } from 'pinia'
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import { ref, watch } from 'vue'
|
|
5
|
+
import TableEditor from './core/Tables/TableEditor.vue'
|
|
6
|
+
import TablesList from './core/Tables/TablesList.vue'
|
|
7
|
+
import TableViewer from './core/Tables/TableViewer.vue'
|
|
9
8
|
import { useClientStore } from './stores/client'
|
|
9
|
+
import { useColumnStore } from './stores/columns'
|
|
10
10
|
|
|
11
11
|
import { useTableStore } from './stores/table'
|
|
12
12
|
import { useTablesStore } from './stores/tables'
|
|
13
|
-
import TableView from './TableView.vue'
|
|
14
13
|
|
|
15
14
|
const { client } = defineProps<ApplicationProps>()
|
|
16
|
-
// init stores
|
|
17
15
|
const clientStore = useClientStore()
|
|
18
16
|
clientStore.setClient(client)
|
|
19
17
|
|
|
18
|
+
const columnStore = useColumnStore()
|
|
20
19
|
const tablesStore = useTablesStore()
|
|
21
20
|
const tableStore = useTableStore()
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const { isFetchingTables, tableType, selectedTable } = storeToRefs(tablesStore)
|
|
26
|
-
const { isCreating } = storeToRefs(tableStore)
|
|
27
|
-
const tableSearch = ref('')
|
|
28
|
-
const tableName = ref('')
|
|
29
|
-
|
|
30
|
-
const tables = computed(() => {
|
|
31
|
-
let tables: TableList[] = []
|
|
32
|
-
|
|
33
|
-
switch (tableType.value) {
|
|
34
|
-
case 'data':
|
|
35
|
-
tables = tablesStore.dataTables
|
|
36
|
-
break
|
|
37
|
-
case 'config':
|
|
38
|
-
tables = tablesStore.configTables
|
|
39
|
-
break
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (tableSearch.value) {
|
|
43
|
-
return tables.filter(table =>
|
|
44
|
-
table.name.toLocaleLowerCase().includes(tableSearch.value.toLocaleLowerCase()),
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return tables
|
|
49
|
-
})
|
|
22
|
+
const { tableType } = storeToRefs(tablesStore)
|
|
23
|
+
const { table: selectedTable } = storeToRefs(tableStore)
|
|
50
24
|
|
|
51
|
-
|
|
52
|
-
if (!tableName.value) {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
const table = await tableStore.createTable(tableName.value) as unknown as TableList
|
|
56
|
-
tableName.value = ''
|
|
57
|
-
await selectTable(table)
|
|
58
|
-
}
|
|
25
|
+
const { columns } = storeToRefs(columnStore)
|
|
59
26
|
|
|
60
|
-
|
|
61
|
-
if (!table) {
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
selectedTable.value = table
|
|
65
|
-
}
|
|
27
|
+
const isTableEditorShown = ref(false)
|
|
66
28
|
|
|
67
29
|
watch(
|
|
68
30
|
() => client.context.value.project,
|
|
69
31
|
async project => project && tablesStore.fetchTables(),
|
|
70
32
|
{ immediate: true },
|
|
71
33
|
)
|
|
34
|
+
|
|
72
35
|
</script>
|
|
73
36
|
|
|
74
37
|
<template>
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
<v-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
v-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
title="Table name"
|
|
112
|
-
>
|
|
113
|
-
<v-card-text>
|
|
114
|
-
<v-text-field
|
|
115
|
-
v-model="tableName"
|
|
116
|
-
placeholder="Table Name"
|
|
117
|
-
variant="outlined"
|
|
118
|
-
color="primary"
|
|
119
|
-
density="compact"
|
|
120
|
-
hide-details
|
|
121
|
-
>
|
|
122
|
-
<template #append-inner>
|
|
123
|
-
<v-progress-circular
|
|
124
|
-
v-if="isCreating"
|
|
125
|
-
size="small"
|
|
126
|
-
color="grey-darken-2"
|
|
127
|
-
indeterminate
|
|
128
|
-
/>
|
|
129
|
-
<v-btn
|
|
130
|
-
v-else
|
|
131
|
-
variant="text"
|
|
132
|
-
size="small"
|
|
133
|
-
icon="mdi-content-save-check-outline"
|
|
134
|
-
color="grey-darken-2"
|
|
135
|
-
@click="createTable"
|
|
136
|
-
/>
|
|
137
|
-
</template>
|
|
138
|
-
</v-text-field>
|
|
139
|
-
</v-card-text>
|
|
140
|
-
<v-divider />
|
|
141
|
-
<v-card-actions>
|
|
142
|
-
<v-spacer />
|
|
143
|
-
<v-btn
|
|
144
|
-
variant="tonal"
|
|
145
|
-
:disabled="!tableName.length || isCreating"
|
|
146
|
-
:loading="isCreating"
|
|
147
|
-
class="px-4"
|
|
148
|
-
size="small"
|
|
149
|
-
color="primary"
|
|
150
|
-
@click="createTable"
|
|
151
|
-
>
|
|
152
|
-
Create
|
|
153
|
-
</v-btn>
|
|
154
|
-
</v-card-actions>
|
|
155
|
-
</v-card>
|
|
156
|
-
</v-menu>
|
|
157
|
-
<base-clickable-icon
|
|
158
|
-
:icon="tableType === 'data' ? 'mdi-table-multiple' : 'mdi-table-cog'"
|
|
159
|
-
size="large"
|
|
160
|
-
@click="tablesStore.toggleTableType"
|
|
38
|
+
<v-app>
|
|
39
|
+
<v-layout class="w-screen overflow-hidden">
|
|
40
|
+
<v-navigation-drawer :width="400" permanent persistent>
|
|
41
|
+
<v-card
|
|
42
|
+
class="h-full overflow-hidden d-flex flex-col w-[400px]"
|
|
43
|
+
>
|
|
44
|
+
<v-tabs v-model="tableType" align-tabs="center" grow hide-slider color="primary">
|
|
45
|
+
<v-tab value="data" prepend-icon="mdi-table-multiple" variant="tonal">
|
|
46
|
+
Data Tables
|
|
47
|
+
</v-tab>
|
|
48
|
+
|
|
49
|
+
<v-tab value="config" prepend-icon="mdi-table-cog" variant="tonal">
|
|
50
|
+
Config Tables
|
|
51
|
+
</v-tab>
|
|
52
|
+
</v-tabs>
|
|
53
|
+
|
|
54
|
+
<v-divider />
|
|
55
|
+
|
|
56
|
+
<v-tabs-window v-model="tableType" class="h-full overflow-auto px-2">
|
|
57
|
+
<v-tabs-window-item value="data">
|
|
58
|
+
<tables-list :tables="tablesStore.dataTables" can-create @table:edit="isTableEditorShown = true" />
|
|
59
|
+
</v-tabs-window-item>
|
|
60
|
+
<v-tabs-window-item value="config">
|
|
61
|
+
<tables-list :tables="tablesStore.configTables" :can-create="false" @table:edit="isTableEditorShown = true" />
|
|
62
|
+
</v-tabs-window-item>
|
|
63
|
+
</v-tabs-window>
|
|
64
|
+
</v-card>
|
|
65
|
+
</v-navigation-drawer>
|
|
66
|
+
|
|
67
|
+
<v-main class="w-screen">
|
|
68
|
+
<v-sheet class="h-full w-full" flat :elevated="0">
|
|
69
|
+
<table-viewer v-if="selectedTable" :key="selectedTable?.id" :client="client" />
|
|
70
|
+
<table-editor
|
|
71
|
+
v-model:is-expanded="isTableEditorShown"
|
|
72
|
+
:table="selectedTable"
|
|
73
|
+
:columns="columns"
|
|
161
74
|
/>
|
|
162
|
-
</
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<v-list-item
|
|
167
|
-
v-for="(table, index) in tables"
|
|
168
|
-
:id="index === 0 ? 'ant-tour-table' : null"
|
|
169
|
-
:key="table.id"
|
|
170
|
-
:active="selectedTable?.id === table?.id"
|
|
171
|
-
:data-index="index"
|
|
172
|
-
:style="`--index: ${index}`"
|
|
173
|
-
:value="table"
|
|
174
|
-
color="primary"
|
|
175
|
-
@click="selectTable(table)"
|
|
176
|
-
>
|
|
177
|
-
<v-list-item-title>{{ table.name }}</v-list-item-title>
|
|
178
|
-
</v-list-item>
|
|
179
|
-
</div>
|
|
180
|
-
</v-list>
|
|
181
|
-
</BaseResizePanel>
|
|
182
|
-
|
|
183
|
-
<div class="full-height full-width flex-grow-1 d-flex overflow-y-auto">
|
|
184
|
-
<v-empty-state
|
|
185
|
-
v-if="!selectedTable"
|
|
186
|
-
class="flex-grow-1"
|
|
187
|
-
title="No table selected!"
|
|
188
|
-
text="Select a table from to view its data."
|
|
189
|
-
>
|
|
190
|
-
<template #media>
|
|
191
|
-
<v-icon icon="mdi-table" color="grey-darken-2" size="120" />
|
|
192
|
-
</template>
|
|
193
|
-
</v-empty-state>
|
|
194
|
-
|
|
195
|
-
<TableView v-else :client="client" :table-id="selectedTable.id" />
|
|
196
|
-
</div>
|
|
197
|
-
</div>
|
|
75
|
+
</v-sheet>
|
|
76
|
+
</v-main>
|
|
77
|
+
</v-layout>
|
|
78
|
+
</v-app>
|
|
198
79
|
</template>
|
|
199
|
-
|
|
200
|
-
<style lang="scss" scoped>
|
|
201
|
-
.vh-100 {
|
|
202
|
-
height: 100vh;
|
|
203
|
-
overflow-y: auto;
|
|
204
|
-
}
|
|
205
|
-
</style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type ColumnGroup = 'text' | 'number' | 'boolean' | 'date' | 'enum' | 'uuid' | 'file'
|
|
2
|
+
|
|
3
|
+
export type ColumnType =
|
|
4
|
+
| 'uuid'
|
|
5
|
+
| 'text'
|
|
6
|
+
| 'email'
|
|
7
|
+
| 'text-field'
|
|
8
|
+
| 'link'
|
|
9
|
+
| 'dropdown'
|
|
10
|
+
| 'boolean'
|
|
11
|
+
| 'integer'
|
|
12
|
+
| 'float'
|
|
13
|
+
| 'document'
|
|
14
|
+
| 'date'
|
|
15
|
+
|
|
16
|
+
export interface ColumnTypeGroup {
|
|
17
|
+
key: ColumnType
|
|
18
|
+
group: ColumnGroup
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const columnsTypes: ColumnTypeGroup[] = [
|
|
22
|
+
{ key: 'boolean', group: 'boolean' },
|
|
23
|
+
|
|
24
|
+
{ key: 'date', group: 'date' },
|
|
25
|
+
{ key: 'dropdown', group: 'enum' },
|
|
26
|
+
{ key: 'document', group: 'file' },
|
|
27
|
+
|
|
28
|
+
{ key: 'text', group: 'text' },
|
|
29
|
+
{ key: 'text-field', group: 'text' },
|
|
30
|
+
{ key: 'email', group: 'text' },
|
|
31
|
+
{ key: 'link', group: 'text' },
|
|
32
|
+
|
|
33
|
+
{ key: 'integer', group: 'number' },
|
|
34
|
+
{ key: 'float', group: 'number' },
|
|
35
|
+
|
|
36
|
+
{ key: 'uuid', group: 'uuid' }
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
export function convertToTitleCase(str: string) {
|
|
40
|
+
return str
|
|
41
|
+
.split('_')
|
|
42
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
43
|
+
.join(' ')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getColumnTypesOptions() {
|
|
47
|
+
return columnsTypes.map((column) => ({
|
|
48
|
+
label: convertToTitleCase(column.key),
|
|
49
|
+
value: column.key?.toLowerCase(),
|
|
50
|
+
}))
|
|
51
|
+
}
|
|
@@ -20,13 +20,15 @@ export async function parseRecordBody(columns: Column[], data: any) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
for (const column of columns) {
|
|
23
|
-
console.log(data[column.name] instanceof File, column.name, data[column.name])
|
|
24
23
|
if (column.type === 'document') {
|
|
25
24
|
if (data[column.name] instanceof File) {
|
|
26
25
|
body.record[column.name] = await FileHandler.handleFile(data[column.name])
|
|
27
26
|
}
|
|
28
27
|
continue
|
|
29
28
|
}
|
|
29
|
+
if (column.type === 'uuid' && data[column.name]) {
|
|
30
|
+
body.record[column.name] = data[column.name]?.id ?? data[column.name];
|
|
31
|
+
}
|
|
30
32
|
else {
|
|
31
33
|
body.record[column.name] = parseData(column.type, data[column.name])
|
|
32
34
|
}
|
|
@@ -51,3 +53,18 @@ function parseData(type: string, value: any) {
|
|
|
51
53
|
return value
|
|
52
54
|
}
|
|
53
55
|
}
|
|
56
|
+
|
|
57
|
+
// Helper function to convert file to a Base64 string
|
|
58
|
+
export async function convertFileToBase64(file: File): Promise<string> {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const reader = new FileReader()
|
|
61
|
+
reader.onload = () => {
|
|
62
|
+
const result = reader.result?.toString() ?? ''
|
|
63
|
+
// Split at ";base64," to ensure we only get the actual base64 data
|
|
64
|
+
const base64String = result.split(';base64,')[1]
|
|
65
|
+
resolve(base64String || '') // Resolve empty string if splitting fails
|
|
66
|
+
}
|
|
67
|
+
reader.onerror = error => reject(error)
|
|
68
|
+
reader.readAsDataURL(file) // Read file as Base64
|
|
69
|
+
})
|
|
70
|
+
}
|