@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
|
@@ -1,175 +1,82 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import type { Column } from '@antcde/connect-ts'
|
|
3
3
|
import { computed, ref, watch } from 'vue'
|
|
4
|
-
import { useI18n } from 'vue-i18n'
|
|
5
4
|
import { useColumnStore } from '../../stores/columns'
|
|
6
|
-
import {
|
|
5
|
+
import { useTableStore } from '../../stores/table'
|
|
6
|
+
import DeleteConfirmationDialog from '../Dialog/DeleteConfirmationDialog.vue'
|
|
7
|
+
import { storeToRefs } from 'pinia'
|
|
7
8
|
|
|
8
9
|
const props = defineProps<{
|
|
9
|
-
|
|
10
|
+
column: Column
|
|
10
11
|
}>()
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const emit = defineEmits<{
|
|
14
|
+
(e: 'edit', column: Column): void
|
|
15
|
+
}>()
|
|
13
16
|
|
|
14
|
-
const conditionStore = useConditionStore()
|
|
15
17
|
const columnStore = useColumnStore()
|
|
18
|
+
const tableStore = useTableStore()
|
|
16
19
|
|
|
17
|
-
const {
|
|
18
|
-
const alias = ref('')
|
|
19
|
-
const showAlias = ref(false)
|
|
20
|
+
const { permissions } = storeToRefs(tableStore)
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
const conditions = computed(() => column.value ? conditionStore.getColumnConditions(column.value) : [])
|
|
23
|
-
const columnAlias = computed(() => columnsAlias.value[column.value.id] ?? '')
|
|
22
|
+
const columnData = ref<Partial<Column>>({})
|
|
24
23
|
|
|
25
|
-
const
|
|
24
|
+
const canConfigure = computed(() => !!props.column && permissions)
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
watch(
|
|
27
|
+
() => props.column,
|
|
28
|
+
(c) => (columnData.value = c ? { ...c } : {}),
|
|
29
|
+
{ immediate: true }
|
|
31
30
|
)
|
|
32
31
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
watch(columnAlias, (value: string) => alias.value = value, { immediate: true })
|
|
32
|
+
const showDeleteConfirmation = ref(false)
|
|
36
33
|
</script>
|
|
37
34
|
|
|
38
35
|
<template>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<v-icon
|
|
46
|
-
v-if="column.required"
|
|
47
|
-
v-tooltip="t('project.tableConfig.columns.is_required')"
|
|
48
|
-
size="8"
|
|
49
|
-
color="error"
|
|
50
|
-
icon="mdi-asterisk"
|
|
51
|
-
/>
|
|
52
|
-
</span>
|
|
53
|
-
|
|
54
|
-
<div class="transition-all transition-duration-200" :class="[isHovering ? 'opacity-100' : 'opacity-0']">
|
|
55
|
-
<v-menu v-if="showAlias" :close-on-content-click="false" @click.stop.prevent>
|
|
56
|
-
<template #activator="{ props: activatorProps }">
|
|
57
|
-
<v-btn
|
|
58
|
-
size="small"
|
|
59
|
-
variant="plain"
|
|
60
|
-
icon="mdi-pencil"
|
|
61
|
-
v-bind="activatorProps"
|
|
62
|
-
@click.stop.prevent
|
|
63
|
-
/>
|
|
64
|
-
</template>
|
|
65
|
-
<v-card width="400">
|
|
66
|
-
<v-card-title class="d-flex items-center justify-between">
|
|
67
|
-
{{ t('project.tableConfig.columns.alias') }}
|
|
68
|
-
</v-card-title>
|
|
69
|
-
<v-divider class="my-0" />
|
|
70
|
-
<v-card-text class="p-4">
|
|
71
|
-
<v-text-field
|
|
72
|
-
v-model="alias"
|
|
73
|
-
:label="t('project.tableConfig.columns.alias')"
|
|
74
|
-
variant="outlined"
|
|
75
|
-
color="primary"
|
|
76
|
-
density="compact"
|
|
77
|
-
append-inner-icon="mdi-content-save-check"
|
|
78
|
-
hide-details
|
|
79
|
-
@click:append-inner="() => columnStore.setColumnAlias(column, alias)"
|
|
80
|
-
/>
|
|
81
|
-
</v-card-text>
|
|
82
|
-
</v-card>
|
|
83
|
-
</v-menu>
|
|
36
|
+
<delete-confirmation-dialog
|
|
37
|
+
v-if="column"
|
|
38
|
+
v-model="showDeleteConfirmation"
|
|
39
|
+
:message="`Are you sure you want to delete the column ${column.name}? This action cannot be undone.`"
|
|
40
|
+
@confirm="columnStore.deleteColumn(column.id)"
|
|
41
|
+
/>
|
|
84
42
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<v-card-title class="d-flex items-center justify-between">
|
|
99
|
-
{{ t('project.tableConfig.conditions.title') }}
|
|
100
|
-
<v-btn
|
|
101
|
-
v-tooltip="t('project.tableConfig.conditions.addCondition')"
|
|
102
|
-
size="small"
|
|
103
|
-
variant="plain"
|
|
104
|
-
icon="mdi-filter-plus-outline"
|
|
105
|
-
@click="() => conditionStore.addCondition(column)"
|
|
106
|
-
/>
|
|
107
|
-
</v-card-title>
|
|
108
|
-
<v-divider class="my-0" />
|
|
109
|
-
<v-card-text class="max-h-[275px] overflow-auto p-0">
|
|
110
|
-
<v-list class="pt-0">
|
|
111
|
-
<template v-for="(condition, index) in conditions" :key="condition.id">
|
|
112
|
-
<v-list-item>
|
|
113
|
-
<div class="d-flex items-center gap-4 py-2">
|
|
114
|
-
<v-select
|
|
115
|
-
v-model="condition.operator"
|
|
116
|
-
:items="['=', '>', '<', '>=', '<=', '<>']"
|
|
117
|
-
:label="t('project.tableConfig.conditions.operator')"
|
|
118
|
-
variant="outlined"
|
|
119
|
-
color="primary"
|
|
120
|
-
density="compact"
|
|
121
|
-
class="flex-1"
|
|
122
|
-
hide-details
|
|
123
|
-
/>
|
|
124
|
-
<v-btn
|
|
125
|
-
variant="plain"
|
|
126
|
-
:disabled="conditions.length === 1"
|
|
127
|
-
icon="mdi-trash-can-outline"
|
|
128
|
-
@click="() => conditionStore.removeCondition(condition.id)"
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
<v-text-field
|
|
132
|
-
v-model="condition.value"
|
|
133
|
-
:label="t('project.tableConfig.conditions.value')"
|
|
134
|
-
variant="outlined"
|
|
135
|
-
color="primary"
|
|
136
|
-
density="compact"
|
|
137
|
-
class="mt-2"
|
|
138
|
-
hide-details
|
|
139
|
-
/>
|
|
140
|
-
</v-list-item>
|
|
141
|
-
<v-divider v-if="index < conditions.length - 1" class="my-3" />
|
|
142
|
-
</template>
|
|
143
|
-
</v-list>
|
|
144
|
-
</v-card-text>
|
|
145
|
-
<v-divider class="my-0" />
|
|
146
|
-
<v-card-actions>
|
|
147
|
-
<v-spacer />
|
|
148
|
-
<v-btn
|
|
149
|
-
variant="text"
|
|
150
|
-
class="px-4"
|
|
151
|
-
size="small"
|
|
152
|
-
color="primary"
|
|
153
|
-
@click="() => conditionStore.clearColumnConditions(column)"
|
|
154
|
-
>
|
|
155
|
-
{{ t('project.tableConfig.conditions.clear') }}
|
|
156
|
-
</v-btn>
|
|
157
|
-
<v-btn
|
|
158
|
-
variant="tonal"
|
|
159
|
-
class="px-4"
|
|
160
|
-
size="small"
|
|
161
|
-
color="primary"
|
|
162
|
-
@click="() => conditionStore.applyColumnConditions(column)"
|
|
163
|
-
>
|
|
164
|
-
{{ t('project.tableConfig.conditions.apply') }}
|
|
165
|
-
</v-btn>
|
|
166
|
-
</v-card-actions>
|
|
167
|
-
</v-card>
|
|
168
|
-
</v-menu>
|
|
169
|
-
</div>
|
|
43
|
+
<v-menu :disabled="!canConfigure" offset-y transition="slide-y-transition">
|
|
44
|
+
<template #activator="{ props: activatorProps }">
|
|
45
|
+
<v-card
|
|
46
|
+
flat
|
|
47
|
+
variant="plain"
|
|
48
|
+
v-bind="activatorProps"
|
|
49
|
+
color=""
|
|
50
|
+
class="d-flex items-center h-full px-2 font-semibold font-italic"
|
|
51
|
+
>
|
|
52
|
+
{{ column.name }}
|
|
53
|
+
<v-chip label class="ms-2 px-1" size="small" density="compact" variant="flat">
|
|
54
|
+
{{ column.type }}
|
|
55
|
+
</v-chip>
|
|
170
56
|
</v-card>
|
|
171
57
|
</template>
|
|
172
|
-
|
|
58
|
+
<v-card>
|
|
59
|
+
<v-list>
|
|
60
|
+
<template v-if="canConfigure && column">
|
|
61
|
+
<v-list-item
|
|
62
|
+
prepend-icon="mdi-pen"
|
|
63
|
+
title="Edit Column"
|
|
64
|
+
density="compact"
|
|
65
|
+
@click="emit('edit', { ...column })"
|
|
66
|
+
/>
|
|
67
|
+
<v-divider />
|
|
68
|
+
</template>
|
|
69
|
+
<template v-if="canConfigure">
|
|
70
|
+
<v-divider />
|
|
71
|
+
<v-list-item
|
|
72
|
+
base-color="red-darken-1"
|
|
73
|
+
density="compact"
|
|
74
|
+
prepend-icon="mdi-delete"
|
|
75
|
+
title="Delete Column"
|
|
76
|
+
@click="() => (showDeleteConfirmation = true)"
|
|
77
|
+
/>
|
|
78
|
+
</template>
|
|
79
|
+
</v-list>
|
|
80
|
+
</v-card>
|
|
81
|
+
</v-menu>
|
|
173
82
|
</template>
|
|
174
|
-
|
|
175
|
-
<style lang="scss" scoped></style>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { Column, SbsRecord } from '@antcde/connect-ts'
|
|
3
|
+
import { useDebounceFn } from '@vueuse/core'
|
|
3
4
|
import { storeToRefs } from 'pinia'
|
|
4
|
-
import { computed, ref } from 'vue'
|
|
5
|
+
import { computed, onMounted, ref } from 'vue'
|
|
5
6
|
import { useI18n } from 'vue-i18n'
|
|
6
7
|
import { useClientStore } from '../../stores/client'
|
|
8
|
+
import { useColumnRelationStore } from '../../stores/columnRelation'
|
|
7
9
|
import { useTableStore } from '../../stores/table'
|
|
8
10
|
import { useTablesStore } from '../../stores/tables'
|
|
9
11
|
|
|
@@ -22,14 +24,20 @@ const model = defineModel()
|
|
|
22
24
|
const tableStore = useTableStore()
|
|
23
25
|
const tablesStore = useTablesStore()
|
|
24
26
|
const clientStore = useClientStore()
|
|
27
|
+
const columnRelationStore = useColumnRelationStore()
|
|
25
28
|
|
|
26
29
|
const sbsRecords = ref<SbsRecord[]>([])
|
|
27
30
|
const isLoadingSbs = ref(false)
|
|
31
|
+
const options = ref<any[]>([])
|
|
28
32
|
|
|
29
33
|
const { client } = storeToRefs(clientStore)
|
|
30
34
|
const { table } = storeToRefs(tableStore)
|
|
31
35
|
const { tables } = storeToRefs(tablesStore)
|
|
32
36
|
|
|
37
|
+
const hasRelation = computed(() => props.column.type === 'uuid' && props.column.column_relation)
|
|
38
|
+
|
|
39
|
+
const serverSideFilter = computed(() => !['user', 'table'].includes(props.column.column_relation?.related_entity ?? ''))
|
|
40
|
+
|
|
33
41
|
const inputComponent = computed(() => {
|
|
34
42
|
switch (props.column.type) {
|
|
35
43
|
case 'text':
|
|
@@ -50,6 +58,8 @@ const inputComponent = computed(() => {
|
|
|
50
58
|
return 'v-file-input'
|
|
51
59
|
case 'date':
|
|
52
60
|
return 'v-date-input'
|
|
61
|
+
case 'uuid':
|
|
62
|
+
return hasRelation.value ? 'v-autocomplete' : 'v-text-field'
|
|
53
63
|
default:
|
|
54
64
|
return 'v-text-field'
|
|
55
65
|
}
|
|
@@ -57,10 +67,12 @@ const inputComponent = computed(() => {
|
|
|
57
67
|
|
|
58
68
|
const inputProps = computed(() => {
|
|
59
69
|
let defaultProps: any = {
|
|
60
|
-
variant: '
|
|
70
|
+
variant: 'outlined',
|
|
61
71
|
color: 'primary',
|
|
62
72
|
density: 'compact',
|
|
63
|
-
placeholder: props.column.name,
|
|
73
|
+
placeholder: convertToTitleCase(props.column.name),
|
|
74
|
+
autocomplete: 'none',
|
|
75
|
+
hideDetails: props.hideLabel,
|
|
64
76
|
}
|
|
65
77
|
switch (props.column.type) {
|
|
66
78
|
case 'email':
|
|
@@ -87,7 +99,7 @@ const inputProps = computed(() => {
|
|
|
87
99
|
case 'dropdown':
|
|
88
100
|
defaultProps = {
|
|
89
101
|
...defaultProps,
|
|
90
|
-
items: props.column.options_value
|
|
102
|
+
items: props.column.options_value || [],
|
|
91
103
|
}
|
|
92
104
|
break
|
|
93
105
|
case 'sbscode':
|
|
@@ -100,6 +112,15 @@ const inputProps = computed(() => {
|
|
|
100
112
|
itemValue: 'code',
|
|
101
113
|
}
|
|
102
114
|
break
|
|
115
|
+
case 'uuid':
|
|
116
|
+
defaultProps = {
|
|
117
|
+
...defaultProps,
|
|
118
|
+
noFilter: serverSideFilter.value,
|
|
119
|
+
items: options.value,
|
|
120
|
+
itemTitle: props.column.column_relation?.display_label ?? 'id',
|
|
121
|
+
itemValue: 'id',
|
|
122
|
+
}
|
|
123
|
+
break
|
|
103
124
|
case 'date':
|
|
104
125
|
defaultProps = {
|
|
105
126
|
...defaultProps,
|
|
@@ -115,12 +136,18 @@ const inputProps = computed(() => {
|
|
|
115
136
|
}
|
|
116
137
|
})
|
|
117
138
|
|
|
139
|
+
const debouncedChange = useDebounceFn((value: any) => searchRelationRecords(value), 800)
|
|
140
|
+
|
|
118
141
|
const inputEvents = computed(() => {
|
|
119
142
|
switch (props.column.type) {
|
|
120
143
|
case 'sbscode':
|
|
121
144
|
return {
|
|
122
145
|
'update:search': searchSearchSbs,
|
|
123
146
|
}
|
|
147
|
+
case 'uuid':
|
|
148
|
+
return {
|
|
149
|
+
'update:search': serverSideFilter.value ? debouncedChange : () => {},
|
|
150
|
+
}
|
|
124
151
|
default:
|
|
125
152
|
return {}
|
|
126
153
|
}
|
|
@@ -154,30 +181,54 @@ async function searchSearchSbs(searchTerm: string) {
|
|
|
154
181
|
isLoadingSbs.value = false
|
|
155
182
|
}
|
|
156
183
|
}
|
|
184
|
+
|
|
185
|
+
async function searchRelationRecords(searchTerm: string) {
|
|
186
|
+
if (!props.column.column_relation)
|
|
187
|
+
return
|
|
188
|
+
const response = await columnRelationStore.getRelationOptions(
|
|
189
|
+
props.column.column_relation,
|
|
190
|
+
searchTerm,
|
|
191
|
+
)
|
|
192
|
+
options.value = response as any[]
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
onMounted(() => {
|
|
196
|
+
if (props.column.type === 'uuid' && props.column.column_relation) {
|
|
197
|
+
// searchRelationRecords('')
|
|
198
|
+
}
|
|
199
|
+
if (props.column.type === 'sbscode') {
|
|
200
|
+
// searchSearchSbs('')
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
function convertToTitleCase(str: string) {
|
|
205
|
+
return str
|
|
206
|
+
.split('_')
|
|
207
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
208
|
+
.join(' ')
|
|
209
|
+
}
|
|
157
210
|
</script>
|
|
158
211
|
|
|
159
212
|
<template>
|
|
160
|
-
<div>
|
|
161
|
-
<v-label v-if="!hideLabel" class="mb-2">
|
|
162
|
-
{{ column.name }}
|
|
163
|
-
<v-icon
|
|
213
|
+
<div class="d-flex flex-row" v-if="column">
|
|
214
|
+
<v-label v-if="!hideLabel" class="mb-2 font-semibold w-[200px]">
|
|
215
|
+
{{ convertToTitleCase(column.name) }}
|
|
216
|
+
<!-- <v-icon
|
|
164
217
|
v-if="column.required"
|
|
165
218
|
v-tooltip="t('project.tableConfig.columns.is_required')"
|
|
166
219
|
size="8"
|
|
167
220
|
color="error"
|
|
168
221
|
icon="mdi-asterisk"
|
|
169
|
-
/>
|
|
222
|
+
/> -->
|
|
170
223
|
</v-label>
|
|
224
|
+
|
|
171
225
|
<component
|
|
172
226
|
:is="inputComponent"
|
|
173
227
|
v-model="model"
|
|
228
|
+
class="flex-grow flex-1"
|
|
174
229
|
:rules="[validateValue]"
|
|
175
230
|
v-bind="inputProps"
|
|
176
231
|
v-on="inputEvents"
|
|
177
|
-
|
|
178
|
-
<template v-if="isLoading" #append-inner>
|
|
179
|
-
<v-progress-circular size="24" color="grey-darken-2" indeterminate />
|
|
180
|
-
</template>
|
|
181
|
-
</component>
|
|
232
|
+
/>
|
|
182
233
|
</div>
|
|
183
234
|
</template>
|
|
@@ -5,6 +5,7 @@ import { storeToRefs } from 'pinia'
|
|
|
5
5
|
import { computed } from 'vue'
|
|
6
6
|
import { useDownloadDocument } from '../../composables/useFile'
|
|
7
7
|
import { useClientStore } from '../../stores/client'
|
|
8
|
+
import { useColumnStore } from '../../stores/columns'
|
|
8
9
|
import { useTableStore } from '../../stores/table'
|
|
9
10
|
import { useTablesStore } from '../../stores/tables'
|
|
10
11
|
|
|
@@ -17,18 +18,29 @@ const props = defineProps<{
|
|
|
17
18
|
const tableStore = useTableStore()
|
|
18
19
|
const tablesStore = useTablesStore()
|
|
19
20
|
const clientStore = useClientStore()
|
|
21
|
+
const columnStore = useColumnStore()
|
|
20
22
|
|
|
23
|
+
const { columnsConfiguration } = storeToRefs(columnStore)
|
|
21
24
|
const { client } = storeToRefs(clientStore)
|
|
22
25
|
const { table } = storeToRefs(tableStore)
|
|
23
26
|
const { tables } = storeToRefs(tablesStore) // FIXME Get tables locally to unlink stores
|
|
24
27
|
|
|
25
28
|
const tableId = computed(() => table.value?.id ?? null)
|
|
26
29
|
|
|
27
|
-
const linkedTable = computed(() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const linkedTable = computed(() =>
|
|
31
|
+
!!props.value && props.column.type === 'table'
|
|
32
|
+
? tables.value.find((t: { id: any }) => t.id === props.value)
|
|
33
|
+
: null,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
// check if value is object and has a name property
|
|
37
|
+
const isObject = (value: any) => typeof value === 'object' && value !== null
|
|
38
|
+
|
|
39
|
+
const hasRelation = computed(
|
|
40
|
+
() => isObject(props.value) && props.column.type === 'uuid' && !!props.column.column_relation,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
const columnConfiguration = computed(() => columnsConfiguration.value.find(c => c.name === props.column.name))
|
|
32
44
|
|
|
33
45
|
const displayedValue = computed(() => {
|
|
34
46
|
const { type } = props.column
|
|
@@ -42,11 +54,15 @@ const displayedValue = computed(() => {
|
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
if (type === 'document') {
|
|
45
|
-
return `${props.value.name}.${props.value.extension}`
|
|
57
|
+
return props.value ? `${props.value.name}.${props.value.extension}` : '-'
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
if (type === 'date') {
|
|
49
|
-
return dayjs(props.value).format('MMMM D, YYYY')
|
|
61
|
+
return props.value ? dayjs(props.value).format('MMMM D, YYYY') : '-'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (hasRelation.value) {
|
|
65
|
+
return props.value[props.column.column_relation?.display_label ?? ''] ?? null
|
|
50
66
|
}
|
|
51
67
|
|
|
52
68
|
return props.value
|
|
@@ -68,10 +84,6 @@ async function openLinkedTable() {
|
|
|
68
84
|
if (!linkedTable.value) {
|
|
69
85
|
return
|
|
70
86
|
}
|
|
71
|
-
// router.push({
|
|
72
|
-
// name: 'table-view',
|
|
73
|
-
// params: { table: linkedTable.value.id },
|
|
74
|
-
// })
|
|
75
87
|
await tableStore.fetchTable(linkedTable.value.id)
|
|
76
88
|
}
|
|
77
89
|
|
|
@@ -92,32 +104,67 @@ function isEmpty(val: any) {
|
|
|
92
104
|
</span>
|
|
93
105
|
|
|
94
106
|
<v-btn
|
|
95
|
-
v-else-if="column.type === 'table'"
|
|
96
|
-
|
|
107
|
+
v-else-if="column.type === 'table'"
|
|
108
|
+
v-tooltip="displayedValue"
|
|
109
|
+
size="small"
|
|
110
|
+
variant="text"
|
|
111
|
+
color="grey-darken-1"
|
|
112
|
+
icon
|
|
113
|
+
@click="openLinkedTable"
|
|
97
114
|
>
|
|
98
115
|
<v-icon>mdi-table-arrow-right</v-icon>
|
|
99
116
|
</v-btn>
|
|
100
117
|
|
|
101
118
|
<v-btn
|
|
102
|
-
v-else-if="column.type === 'link'"
|
|
103
|
-
|
|
119
|
+
v-else-if="column.type === 'link'"
|
|
120
|
+
v-tooltip="displayedValue"
|
|
121
|
+
size="small"
|
|
122
|
+
variant="text"
|
|
123
|
+
color="grey-darken-1"
|
|
124
|
+
:href="value"
|
|
125
|
+
icon
|
|
104
126
|
>
|
|
105
127
|
<v-icon>mdi-link</v-icon>
|
|
106
128
|
</v-btn>
|
|
107
129
|
|
|
108
130
|
<v-btn
|
|
109
|
-
v-else-if="column.type === 'document'"
|
|
110
|
-
|
|
131
|
+
v-else-if="column.type === 'document'"
|
|
132
|
+
v-tooltip="displayedValue"
|
|
133
|
+
size="small"
|
|
134
|
+
variant="text"
|
|
135
|
+
color="grey-darken-1"
|
|
136
|
+
@click="downloadDocument"
|
|
111
137
|
>
|
|
112
138
|
<span class="pr-2">{{ displayedValue }}</span>
|
|
113
139
|
<v-icon>mdi-download</v-icon>
|
|
114
140
|
</v-btn>
|
|
115
141
|
|
|
142
|
+
<v-menu v-else-if="hasRelation" :close-on-content-click="false" location="bottom">
|
|
143
|
+
<template #activator="{ props }">
|
|
144
|
+
<v-btn v-bind="props" variant="tonal" size="small" append-icon="mdi-table-arrow-right">
|
|
145
|
+
{{ displayedValue }}
|
|
146
|
+
</v-btn>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<v-card min-width="300">
|
|
150
|
+
<v-table>
|
|
151
|
+
<tbody>
|
|
152
|
+
<tr v-for="key in (columnConfiguration?.relation?.fields ?? [])" :key="key">
|
|
153
|
+
<td class="font-bold">
|
|
154
|
+
{{ key }}
|
|
155
|
+
</td>
|
|
156
|
+
<td>
|
|
157
|
+
{{ value[key ?? ''] }}
|
|
158
|
+
</td>
|
|
159
|
+
</tr>
|
|
160
|
+
</tbody>
|
|
161
|
+
</v-table>
|
|
162
|
+
</v-card>
|
|
163
|
+
</v-menu>
|
|
164
|
+
|
|
116
165
|
<span v-else>
|
|
117
166
|
{{ displayedValue }}
|
|
118
167
|
</span>
|
|
119
168
|
</template>
|
|
120
169
|
|
|
121
|
-
<style lang="scss" scoped>
|
|
122
|
-
|
|
123
|
-
</style>
|
|
170
|
+
<style lang="scss" scoped></style>
|