@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
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column } from '@antcde/connect-ts'
|
|
3
|
+
import { computed, ref, watch } from 'vue'
|
|
4
|
+
import { getColumnTypesOptions } from '../../composables/columns'
|
|
5
|
+
import { useColumnStore } from '../../stores/columns'
|
|
6
|
+
import { storeToRefs } from 'pinia'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
column: Partial<Column>
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const emit = defineEmits<{
|
|
13
|
+
(e: 'column:save', column: Partial<Column>): void
|
|
14
|
+
(e: 'column:remove'): void
|
|
15
|
+
}>()
|
|
16
|
+
|
|
17
|
+
const column = ref<Partial<Column>>({})
|
|
18
|
+
|
|
19
|
+
const columnStore = useColumnStore()
|
|
20
|
+
const { isUpdating, isCreating } = storeToRefs(columnStore)
|
|
21
|
+
|
|
22
|
+
const inEditMode = computed(() => !!column.value.id)
|
|
23
|
+
|
|
24
|
+
const isValid = computed(() => {
|
|
25
|
+
return (
|
|
26
|
+
column.value.name &&
|
|
27
|
+
column.value.type &&
|
|
28
|
+
(column.value.type !== 'dropdown' || column.value.options_value?.length)
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
function addOptionValue(value: string) {
|
|
33
|
+
if (!value.length || column.value.options_value?.includes(value)) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
if (!column.value.options_value) {
|
|
37
|
+
column.value.options_value = []
|
|
38
|
+
}
|
|
39
|
+
if (value && !column.value.options_value.includes(value)) {
|
|
40
|
+
column.value.options_value.push(value)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
watch(
|
|
45
|
+
() => props.column,
|
|
46
|
+
(c) => (column.value = c ? { ...c } : {}),
|
|
47
|
+
{ immediate: true, deep: true },
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
watch(
|
|
51
|
+
() => column.value,
|
|
52
|
+
(c) => {
|
|
53
|
+
if (c?.is_unique) {
|
|
54
|
+
column.value.default_value = null
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{ deep: true }
|
|
58
|
+
)
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<tr>
|
|
63
|
+
<td class="pr-2 pl-0">
|
|
64
|
+
<v-text-field
|
|
65
|
+
v-model="column.name"
|
|
66
|
+
variant="outlined"
|
|
67
|
+
color="primary"
|
|
68
|
+
hide-details
|
|
69
|
+
density="compact"
|
|
70
|
+
class="w-full"
|
|
71
|
+
/>
|
|
72
|
+
</td>
|
|
73
|
+
|
|
74
|
+
<td class="pr-2 pl-0">
|
|
75
|
+
<v-select
|
|
76
|
+
v-model="column.type"
|
|
77
|
+
:items="getColumnTypesOptions()"
|
|
78
|
+
variant="outlined"
|
|
79
|
+
color="primary"
|
|
80
|
+
hide-details
|
|
81
|
+
density="compact"
|
|
82
|
+
:disabled="inEditMode"
|
|
83
|
+
item-value="value"
|
|
84
|
+
item-title="label"
|
|
85
|
+
/>
|
|
86
|
+
</td>
|
|
87
|
+
|
|
88
|
+
<td class="pr-2 pl-0">
|
|
89
|
+
<v-menu v-if="column.type === 'dropdown'" :close-on-content-click="false">
|
|
90
|
+
<template #activator="{ props: activatorProps }">
|
|
91
|
+
<v-text-field
|
|
92
|
+
v-bind="activatorProps"
|
|
93
|
+
:model-value="`${column.options_value?.length ?? 0} added`"
|
|
94
|
+
density="compact"
|
|
95
|
+
color="primary"
|
|
96
|
+
variant="outlined"
|
|
97
|
+
readonly
|
|
98
|
+
hide-details
|
|
99
|
+
:disabled="inEditMode"
|
|
100
|
+
append-inner-icon="mdi-chevron-down"
|
|
101
|
+
/>
|
|
102
|
+
</template>
|
|
103
|
+
<v-card class="d-flex flex-column" width="400">
|
|
104
|
+
<v-card-item>
|
|
105
|
+
<v-text-field
|
|
106
|
+
variant="outlined"
|
|
107
|
+
color="primary"
|
|
108
|
+
density="compact"
|
|
109
|
+
class="w-full"
|
|
110
|
+
hint="Press Enter to add value"
|
|
111
|
+
persistent-hint
|
|
112
|
+
@keydown.enter="addOptionValue($event.target.value)"
|
|
113
|
+
/>
|
|
114
|
+
</v-card-item>
|
|
115
|
+
<v-divider />
|
|
116
|
+
<v-card-item class="d-flex flex-row flex-wrap">
|
|
117
|
+
<v-chip
|
|
118
|
+
v-for="(item, optionIndex) in (column.options_value ?? [])"
|
|
119
|
+
:key="optionIndex"
|
|
120
|
+
class="ma-1"
|
|
121
|
+
small
|
|
122
|
+
closable
|
|
123
|
+
@click:close="() => column.options_value?.splice(optionIndex, 1)"
|
|
124
|
+
>
|
|
125
|
+
{{ item }}
|
|
126
|
+
</v-chip>
|
|
127
|
+
</v-card-item>
|
|
128
|
+
</v-card>
|
|
129
|
+
</v-menu>
|
|
130
|
+
</td>
|
|
131
|
+
|
|
132
|
+
<td class="pr-2 pl-0">
|
|
133
|
+
<v-select
|
|
134
|
+
v-if="column.type === 'dropdown'"
|
|
135
|
+
v-model="(column.default_value as string)"
|
|
136
|
+
:items="column.options_value ?? []"
|
|
137
|
+
variant="outlined"
|
|
138
|
+
color="primary"
|
|
139
|
+
hide-details
|
|
140
|
+
density="compact"
|
|
141
|
+
:disabled="Boolean(column.is_unique)"
|
|
142
|
+
/>
|
|
143
|
+
<v-switch
|
|
144
|
+
v-else-if="column.type === 'boolean'"
|
|
145
|
+
v-model="column.default_value"
|
|
146
|
+
color="primary"
|
|
147
|
+
hide-details
|
|
148
|
+
density="compact"
|
|
149
|
+
variant="outlined"
|
|
150
|
+
type="switch"
|
|
151
|
+
base-color="grey-lighten-2"
|
|
152
|
+
true-value="1"
|
|
153
|
+
false-value="0"
|
|
154
|
+
:disabled="Boolean(column.is_unique)"
|
|
155
|
+
/>
|
|
156
|
+
<v-text-field
|
|
157
|
+
v-else
|
|
158
|
+
v-model="column.default_value"
|
|
159
|
+
variant="outlined"
|
|
160
|
+
color="primary"
|
|
161
|
+
hide-details
|
|
162
|
+
density="compact"
|
|
163
|
+
class="w-full"
|
|
164
|
+
:disabled="
|
|
165
|
+
Boolean(column.is_unique) || ['document', 'uuid', 'date'].includes(column.type ?? '')
|
|
166
|
+
"
|
|
167
|
+
/>
|
|
168
|
+
</td>
|
|
169
|
+
|
|
170
|
+
<td class="text-center">
|
|
171
|
+
<v-checkbox
|
|
172
|
+
v-model="column.is_unique"
|
|
173
|
+
color="primary"
|
|
174
|
+
hide-details
|
|
175
|
+
density="compact"
|
|
176
|
+
variant="outlined"
|
|
177
|
+
type="switch"
|
|
178
|
+
:disabled="inEditMode || ['document', 'date', 'boolean'].includes(column.type ?? '')"
|
|
179
|
+
/>
|
|
180
|
+
</td>
|
|
181
|
+
|
|
182
|
+
<td class="text-center">
|
|
183
|
+
<v-checkbox
|
|
184
|
+
v-model="column.required"
|
|
185
|
+
color="primary"
|
|
186
|
+
hide-details
|
|
187
|
+
density="compact"
|
|
188
|
+
variant="outlined"
|
|
189
|
+
type="switch"
|
|
190
|
+
/>
|
|
191
|
+
</td>
|
|
192
|
+
|
|
193
|
+
<td class="text-center">
|
|
194
|
+
<div class="d-flex gap-4">
|
|
195
|
+
<v-btn
|
|
196
|
+
v-tooltip="'Save'"
|
|
197
|
+
size="small"
|
|
198
|
+
density="compact"
|
|
199
|
+
variant="text"
|
|
200
|
+
icon
|
|
201
|
+
color="primary"
|
|
202
|
+
:disabled="!isValid || isUpdating || isCreating"
|
|
203
|
+
@click="() => emit('column:save', column)"
|
|
204
|
+
>
|
|
205
|
+
<v-icon>
|
|
206
|
+
{{ inEditMode ? 'mdi-content-save-edit-outline' : 'mdi-content-save-plus-outline' }}
|
|
207
|
+
</v-icon>
|
|
208
|
+
</v-btn>
|
|
209
|
+
<v-btn
|
|
210
|
+
size="small"
|
|
211
|
+
density="compact"
|
|
212
|
+
variant="text"
|
|
213
|
+
icon
|
|
214
|
+
color="red-lighten-1"
|
|
215
|
+
:disabled="isUpdating || isCreating"
|
|
216
|
+
@click="() => emit('column:remove')"
|
|
217
|
+
>
|
|
218
|
+
<v-icon>mdi-delete</v-icon>
|
|
219
|
+
</v-btn>
|
|
220
|
+
</div>
|
|
221
|
+
</td>
|
|
222
|
+
</tr>
|
|
223
|
+
</template>
|
|
224
|
+
|
|
225
|
+
<style scoped></style>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column } from '@antcde/connect-ts/services/ColumnService'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
4
|
+
import ColumnItem from './ColumnItem.vue'
|
|
5
|
+
|
|
6
|
+
defineProps<{
|
|
7
|
+
columns: Partial<Column>[]
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
const emit = defineEmits<{
|
|
11
|
+
(e: 'columns:add'): void
|
|
12
|
+
(e: 'columns:remove', index: number): void
|
|
13
|
+
(e: 'columns:update', index: number, data: Partial<Column>): void
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const { t } = useI18n()
|
|
17
|
+
|
|
18
|
+
const columnHeaders = [
|
|
19
|
+
{
|
|
20
|
+
title: t('project.tableConfig.columns.dialog.name'),
|
|
21
|
+
key: 'name',
|
|
22
|
+
width: 200,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: t('project.tableConfig.columns.dialog.type'),
|
|
26
|
+
key: 'type',
|
|
27
|
+
width: 200,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: t('project.tableConfig.columns.dialog.values'),
|
|
31
|
+
key: 'options_value',
|
|
32
|
+
width: 200,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: t('project.tableConfig.columns.dialog.default_value'),
|
|
36
|
+
key: 'default_value',
|
|
37
|
+
width: 200,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: t('project.tableConfig.columns.dialog.unique'),
|
|
41
|
+
key: 'is_unique',
|
|
42
|
+
width: 100,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: t('project.tableConfig.columns.dialog.required'),
|
|
46
|
+
key: 'required',
|
|
47
|
+
width: 100,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: '',
|
|
51
|
+
key: 'actions',
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<v-table>
|
|
58
|
+
<thead>
|
|
59
|
+
<tr>
|
|
60
|
+
<th v-for="header in columnHeaders" :key="header.key" :width="header.width">
|
|
61
|
+
{{ header.title }}
|
|
62
|
+
</th>
|
|
63
|
+
</tr>
|
|
64
|
+
</thead>
|
|
65
|
+
<tbody>
|
|
66
|
+
<!-- ID Column -->
|
|
67
|
+
<tr>
|
|
68
|
+
<td class="pr-2 pl-0">
|
|
69
|
+
<v-text-field
|
|
70
|
+
model-value="ID"
|
|
71
|
+
disabled
|
|
72
|
+
variant="outlined"
|
|
73
|
+
hide-details
|
|
74
|
+
density="compact"
|
|
75
|
+
class="w-full"
|
|
76
|
+
/>
|
|
77
|
+
</td>
|
|
78
|
+
<td class="pr-2 pl-0">
|
|
79
|
+
<v-select
|
|
80
|
+
model-value="UUID"
|
|
81
|
+
:items="['UUID']"
|
|
82
|
+
variant="outlined"
|
|
83
|
+
color="primary"
|
|
84
|
+
hide-details
|
|
85
|
+
density="compact"
|
|
86
|
+
:menu-props="{ maxHeight: '400', width: '400' }"
|
|
87
|
+
disabled
|
|
88
|
+
/>
|
|
89
|
+
</td>
|
|
90
|
+
<td />
|
|
91
|
+
<td />
|
|
92
|
+
<td>
|
|
93
|
+
<v-checkbox
|
|
94
|
+
disabled
|
|
95
|
+
:model-value="true"
|
|
96
|
+
color="primary"
|
|
97
|
+
hide-details
|
|
98
|
+
density="compact"
|
|
99
|
+
variant="outlined"
|
|
100
|
+
type="switch"
|
|
101
|
+
/>
|
|
102
|
+
</td>
|
|
103
|
+
<td>
|
|
104
|
+
<v-checkbox
|
|
105
|
+
disabled
|
|
106
|
+
:model-value="true"
|
|
107
|
+
color="primary"
|
|
108
|
+
hide-details
|
|
109
|
+
density="compact"
|
|
110
|
+
variant="outlined"
|
|
111
|
+
type="switch"
|
|
112
|
+
/>
|
|
113
|
+
</td>
|
|
114
|
+
<td />
|
|
115
|
+
</tr>
|
|
116
|
+
<column-item
|
|
117
|
+
v-for="(column, index) in columns"
|
|
118
|
+
:key="column.id"
|
|
119
|
+
:column="column"
|
|
120
|
+
@column:save="(data) => emit('columns:update', index, data)"
|
|
121
|
+
@column:remove="emit('columns:remove', index)"
|
|
122
|
+
/>
|
|
123
|
+
</tbody>
|
|
124
|
+
<tfoot>
|
|
125
|
+
<tr>
|
|
126
|
+
<td colspan="7" class="text-center">
|
|
127
|
+
<v-btn
|
|
128
|
+
size="small"
|
|
129
|
+
variant="text"
|
|
130
|
+
color="primary"
|
|
131
|
+
prepend-icon="mdi-plus"
|
|
132
|
+
@click="emit('columns:add')"
|
|
133
|
+
>
|
|
134
|
+
Add new column
|
|
135
|
+
</v-btn>
|
|
136
|
+
</td>
|
|
137
|
+
</tr>
|
|
138
|
+
</tfoot>
|
|
139
|
+
</v-table>
|
|
140
|
+
</template>
|
|
141
|
+
|
|
142
|
+
<style scoped></style>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column } from '@antcde/connect-ts'
|
|
3
|
+
import type { RelatedEntity } from '@antcde/connect-ts/services/Table/ColumnRelationService'
|
|
4
|
+
import { storeToRefs } from 'pinia'
|
|
5
|
+
import { computed, ref, watch } from 'vue'
|
|
6
|
+
import { useColumnRelationStore } from '../../stores/columnRelation'
|
|
7
|
+
import { useColumnStore } from '../../stores/columns'
|
|
8
|
+
import { useTablesStore } from '../../stores/tables'
|
|
9
|
+
import { relationTypes } from '../../composables/relations'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
column: Partial<Column>
|
|
13
|
+
}>()
|
|
14
|
+
const columnStore = useColumnStore()
|
|
15
|
+
const columnRelationStore = useColumnRelationStore()
|
|
16
|
+
|
|
17
|
+
const tablesStore = useTablesStore()
|
|
18
|
+
const { tables } = storeToRefs(tablesStore)
|
|
19
|
+
|
|
20
|
+
const displayLabelItems = ref<string[]>([])
|
|
21
|
+
|
|
22
|
+
watch(
|
|
23
|
+
() => props.column,
|
|
24
|
+
async (c) => {
|
|
25
|
+
if (c.column_relation?.related_entity === 'table_record') {
|
|
26
|
+
const columns = await columnStore.fetchTableColumns(c.column_relation.related_table_id ?? '')
|
|
27
|
+
displayLabelItems.value = columns.filter(column => ['text', 'text-field', 'email', 'link'].includes(column.type)).map(column => column.name)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{ immediate: true },
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
function getColumnRelationLabel(column: Partial<Column>) {
|
|
34
|
+
const columnRelation = column.column_relation
|
|
35
|
+
const table = tables.value.find(table => table.id === columnRelation?.related_table_id)
|
|
36
|
+
return table ? table.name : columnRelation?.related_entity
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function createColumnRelation(columnId: string, entity: RelatedEntity, tableId?: string) {
|
|
40
|
+
if (entity === 'table_record' && !tableId) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
columnRelationStore.addColumnRelation(columnId, {
|
|
45
|
+
related_entity: entity,
|
|
46
|
+
related_table_id: tableId ?? null,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function updateColumnRelation(
|
|
51
|
+
columnId: string,
|
|
52
|
+
columnRelationId: string,
|
|
53
|
+
displayLabel: string,
|
|
54
|
+
) {
|
|
55
|
+
columnRelationStore.updateColumnRelation(columnId, columnRelationId, {
|
|
56
|
+
display_label: displayLabel,
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<tr>
|
|
63
|
+
<td>
|
|
64
|
+
{{ column.name }}
|
|
65
|
+
</td>
|
|
66
|
+
<td>
|
|
67
|
+
<v-menu>
|
|
68
|
+
<template #activator="{ props: activatorProps }">
|
|
69
|
+
<v-text-field
|
|
70
|
+
v-bind="activatorProps"
|
|
71
|
+
:model-value="getColumnRelationLabel(column) ?? 'Select'"
|
|
72
|
+
variant="outlined"
|
|
73
|
+
hide-details
|
|
74
|
+
density="compact"
|
|
75
|
+
class="w-full"
|
|
76
|
+
color="primary"
|
|
77
|
+
append-inner-icon="mdi-chevron-down"
|
|
78
|
+
readonly
|
|
79
|
+
:disabled="column.column_relation?.id !== undefined"
|
|
80
|
+
/>
|
|
81
|
+
</template>
|
|
82
|
+
<v-card>
|
|
83
|
+
<v-list color="primary" max-height="400" class="overflow-auto">
|
|
84
|
+
<v-list-subheader> System </v-list-subheader>
|
|
85
|
+
|
|
86
|
+
<v-list-item
|
|
87
|
+
v-for="relationType in relationTypes"
|
|
88
|
+
:key="relationType.value"
|
|
89
|
+
:title="relationType.title"
|
|
90
|
+
:value="relationType.value"
|
|
91
|
+
:active="column.column_relation?.related_entity === relationType.value"
|
|
92
|
+
@click="createColumnRelation(column.id ?? '', relationType.value)"
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<v-divider />
|
|
96
|
+
<v-list-subheader> Table Records </v-list-subheader>
|
|
97
|
+
|
|
98
|
+
<v-list-item
|
|
99
|
+
v-for="table in tables"
|
|
100
|
+
:key="table.id"
|
|
101
|
+
:title="table.name"
|
|
102
|
+
:value="table.id"
|
|
103
|
+
:active="column.column_relation?.related_table_id === table.id"
|
|
104
|
+
density="compact"
|
|
105
|
+
@click="createColumnRelation(column.id ?? '', 'table_record', table.id)"
|
|
106
|
+
/>
|
|
107
|
+
</v-list>
|
|
108
|
+
</v-card>
|
|
109
|
+
</v-menu>
|
|
110
|
+
</td>
|
|
111
|
+
|
|
112
|
+
<td>
|
|
113
|
+
<v-menu
|
|
114
|
+
v-if="column.column_relation"
|
|
115
|
+
:disabled="column.column_relation?.related_entity !== 'table_record'"
|
|
116
|
+
>
|
|
117
|
+
<template #activator="{ props: activatorProps }">
|
|
118
|
+
<v-text-field
|
|
119
|
+
v-bind="activatorProps"
|
|
120
|
+
:model-value="column.column_relation.display_label"
|
|
121
|
+
variant="outlined"
|
|
122
|
+
hide-details
|
|
123
|
+
density="compact"
|
|
124
|
+
class="w-full"
|
|
125
|
+
color="primary"
|
|
126
|
+
append-inner-icon="mdi-chevron-down"
|
|
127
|
+
:disabled="column.column_relation?.related_entity !== 'table_record'"
|
|
128
|
+
readonly
|
|
129
|
+
/>
|
|
130
|
+
</template>
|
|
131
|
+
<v-card>
|
|
132
|
+
<v-list color="primary" max-height="400" class="overflow-auto">
|
|
133
|
+
<v-list-item
|
|
134
|
+
v-for="tableColumn in displayLabelItems"
|
|
135
|
+
:key="tableColumn"
|
|
136
|
+
density="compact"
|
|
137
|
+
:title="tableColumn"
|
|
138
|
+
:active="column.column_relation?.display_label === tableColumn"
|
|
139
|
+
:disabled="displayLabelItems.length === 0"
|
|
140
|
+
@click="updateColumnRelation(column.id ?? '', column.column_relation.id, tableColumn)"
|
|
141
|
+
/>
|
|
142
|
+
</v-list>
|
|
143
|
+
</v-card>
|
|
144
|
+
</v-menu>
|
|
145
|
+
</td>
|
|
146
|
+
|
|
147
|
+
<td>
|
|
148
|
+
<v-btn
|
|
149
|
+
v-if="column.column_relation"
|
|
150
|
+
size="small"
|
|
151
|
+
density="compact"
|
|
152
|
+
variant="text"
|
|
153
|
+
icon
|
|
154
|
+
color="red-lighten-1"
|
|
155
|
+
@click="
|
|
156
|
+
columnRelationStore.deleteColumnRelation(column.id ?? '', column.column_relation?.id ?? '')
|
|
157
|
+
"
|
|
158
|
+
>
|
|
159
|
+
<v-icon>mdi-delete</v-icon>
|
|
160
|
+
</v-btn>
|
|
161
|
+
</td>
|
|
162
|
+
</tr>
|
|
163
|
+
</template>
|
|
164
|
+
|
|
165
|
+
<style scoped></style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Column } from '@antcde/connect-ts'
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import ForeignKeyColumnsItem from './ForeignKeyColumnItem.vue'
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
columns: Partial<Column>[]
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const uuidColumns = computed(() => props.columns.filter(column => column.type === 'uuid'))
|
|
12
|
+
|
|
13
|
+
const relationHeaders: ReadonlyArray<{
|
|
14
|
+
title?: string
|
|
15
|
+
key: string
|
|
16
|
+
}> = [
|
|
17
|
+
{
|
|
18
|
+
title: 'Column',
|
|
19
|
+
key: 'name',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Related Table',
|
|
23
|
+
key: 'related_entity',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: 'Display Label',
|
|
27
|
+
key: 'display_label',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'actions',
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<v-table>
|
|
38
|
+
<thead>
|
|
39
|
+
<tr>
|
|
40
|
+
<th v-for="header in relationHeaders" :key="header.key" :width="header">
|
|
41
|
+
{{ header.title }}
|
|
42
|
+
</th>
|
|
43
|
+
</tr>
|
|
44
|
+
</thead>
|
|
45
|
+
<tbody>
|
|
46
|
+
<foreign-key-columns-item
|
|
47
|
+
v-for="column in uuidColumns"
|
|
48
|
+
:key="column.id"
|
|
49
|
+
:column="column"
|
|
50
|
+
/>
|
|
51
|
+
</tbody>
|
|
52
|
+
</v-table>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<style scoped></style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, watch, defineProps, defineEmits } from 'vue'
|
|
3
|
+
|
|
4
|
+
// Define props
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
modelValue: boolean
|
|
7
|
+
message?: string
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
// Define emits
|
|
11
|
+
const emit = defineEmits<{
|
|
12
|
+
(e: 'update:modelValue', value: boolean): void
|
|
13
|
+
(e: 'confirm'): void
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
// Local state for dialog visibility
|
|
17
|
+
const dialog = ref(props.modelValue)
|
|
18
|
+
|
|
19
|
+
// Watch for changes in the modelValue prop and sync with local state
|
|
20
|
+
watch(
|
|
21
|
+
() => props.modelValue,
|
|
22
|
+
(newValue) => {
|
|
23
|
+
dialog.value = newValue
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// Watch for changes in the local dialog state and emit updates
|
|
28
|
+
watch(dialog, (newValue) => {
|
|
29
|
+
emit('update:modelValue', newValue)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Methods
|
|
33
|
+
const confirmDelete = () => {
|
|
34
|
+
emit('confirm')
|
|
35
|
+
dialog.value = false
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const closeDialog = () => {
|
|
39
|
+
dialog.value = false
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<v-dialog v-model="dialog" max-width="500">
|
|
45
|
+
<v-card>
|
|
46
|
+
<v-card-title class="headline">Confirm Deletion</v-card-title>
|
|
47
|
+
<v-divider />
|
|
48
|
+
<v-card-text>
|
|
49
|
+
{{ message ?? 'Are you sure you want to delete this item? This action cannot be undone.' }}
|
|
50
|
+
</v-card-text>
|
|
51
|
+
<v-divider />
|
|
52
|
+
<v-card-actions>
|
|
53
|
+
<v-spacer />
|
|
54
|
+
<v-btn color="red" text @click="confirmDelete">Delete</v-btn>
|
|
55
|
+
<v-btn color="grey" text @click="closeDialog">Cancel</v-btn>
|
|
56
|
+
</v-card-actions>
|
|
57
|
+
</v-card>
|
|
58
|
+
</v-dialog>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<style scoped>
|
|
62
|
+
/* Add any custom styles here */
|
|
63
|
+
</style>
|