@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,133 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { useConditionStore, type Condition } from '../../stores/conditions'
|
|
3
|
+
import { useColumnStore } from '../../stores/columns'
|
|
4
|
+
import { storeToRefs } from 'pinia'
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
import RecordInput from '../Records/RecordInput.vue'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
condition: Condition
|
|
10
|
+
}>()
|
|
11
|
+
|
|
12
|
+
const columnStore = useColumnStore()
|
|
13
|
+
const conditionStore = useConditionStore()
|
|
14
|
+
|
|
15
|
+
const { columns } = storeToRefs(columnStore)
|
|
16
|
+
|
|
17
|
+
const selectedColumn = computed(() =>
|
|
18
|
+
columns.value.find((column) => column.id === props.condition.column)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const operators = computed(() => {
|
|
22
|
+
if (!selectedColumn.value) return []
|
|
23
|
+
|
|
24
|
+
if (['text', 'text-field', 'email', 'link'].includes(selectedColumn.value.type)) {
|
|
25
|
+
return ['=', '<>', 'like']
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (['integer', 'float', 'date'].includes(selectedColumn.value.type)) {
|
|
29
|
+
return ['=', '<>', '>', '<', '>=', '<=']
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (['boolean', 'dropdown', 'uuid'].includes(selectedColumn.value.type)) {
|
|
33
|
+
return ['=', '<>']
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return []
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const operatorWithLabels = computed(() => {
|
|
40
|
+
return operators.value.map((operator) => {
|
|
41
|
+
switch (operator) {
|
|
42
|
+
case '=':
|
|
43
|
+
return { value: operator, label: 'Equals' }
|
|
44
|
+
case '<>':
|
|
45
|
+
return { value: operator, label: 'Not Equals' }
|
|
46
|
+
case '>':
|
|
47
|
+
return { value: operator, label: 'Greater Than' }
|
|
48
|
+
case '<':
|
|
49
|
+
return { value: operator, label: 'Less Than' }
|
|
50
|
+
case '>=':
|
|
51
|
+
return { value: operator, label: 'Greater Than or Equal To' }
|
|
52
|
+
case '<=':
|
|
53
|
+
return { value: operator, label: 'Less Than or Equal To' }
|
|
54
|
+
default:
|
|
55
|
+
return { value: operator, label: operator }
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// const showFilterIcon = computed(() => ['text', 'integer', 'float', 'email', 'boolean'].includes(column.value.type))
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<template>
|
|
64
|
+
<v-card variant="outlined" color="grey-lighten-2" class="p-4">
|
|
65
|
+
<v-sheet class="d-flex flex-column gap-4">
|
|
66
|
+
<v-sheet class="d-flex flex-row gap-4 w-full items-center">
|
|
67
|
+
<v-sheet class="d-flex flex-column w-full">
|
|
68
|
+
<v-label class="mr-2 font-semibold"> Column </v-label>
|
|
69
|
+
<v-select
|
|
70
|
+
variant="outlined"
|
|
71
|
+
color="primary"
|
|
72
|
+
hide-details
|
|
73
|
+
density="compact"
|
|
74
|
+
:items="columns"
|
|
75
|
+
item-title="name"
|
|
76
|
+
item-value="id"
|
|
77
|
+
:model-value="condition.column ?? ''"
|
|
78
|
+
@update:model-value="
|
|
79
|
+
(column) => conditionStore.updateCondition(condition.id, { column })
|
|
80
|
+
"
|
|
81
|
+
class="flex-grow-1"
|
|
82
|
+
/>
|
|
83
|
+
</v-sheet>
|
|
84
|
+
<v-sheet class="d-flex flex-column w-full">
|
|
85
|
+
<v-label class="mr-2 font-semibold"> Operator </v-label>
|
|
86
|
+
<v-select
|
|
87
|
+
variant="outlined"
|
|
88
|
+
color="primary"
|
|
89
|
+
hide-details
|
|
90
|
+
:disabled="!selectedColumn"
|
|
91
|
+
density="compact"
|
|
92
|
+
:items="operatorWithLabels"
|
|
93
|
+
item-value="value"
|
|
94
|
+
item-title="label"
|
|
95
|
+
:model-value="condition.operator"
|
|
96
|
+
@update:model-value="
|
|
97
|
+
(operator) => conditionStore.updateCondition(condition.id, { operator })
|
|
98
|
+
"
|
|
99
|
+
class="flex-grow-1"
|
|
100
|
+
/>
|
|
101
|
+
</v-sheet>
|
|
102
|
+
<v-btn
|
|
103
|
+
variant="text"
|
|
104
|
+
color="red-lighten-1"
|
|
105
|
+
@click="conditionStore.removeCondition(condition.id)"
|
|
106
|
+
class="ml-4 mt-6"
|
|
107
|
+
icon="mdi-delete"
|
|
108
|
+
/>
|
|
109
|
+
</v-sheet>
|
|
110
|
+
|
|
111
|
+
<v-sheet class="d-flex flex-column">
|
|
112
|
+
<v-label class="mr-2 font-semibold"> Value </v-label>
|
|
113
|
+
<v-text-field
|
|
114
|
+
v-if="!selectedColumn"
|
|
115
|
+
disabled
|
|
116
|
+
variant="outlined"
|
|
117
|
+
color="primary"
|
|
118
|
+
hide-details
|
|
119
|
+
density="compact"
|
|
120
|
+
class="flex-grow-1"
|
|
121
|
+
/>
|
|
122
|
+
<record-input
|
|
123
|
+
v-if="selectedColumn"
|
|
124
|
+
:model-value="condition.value"
|
|
125
|
+
@update:model-value="(value) => conditionStore.updateCondition(condition.id, { value })"
|
|
126
|
+
:column="selectedColumn"
|
|
127
|
+
hide-label
|
|
128
|
+
class="flex-grow-1"
|
|
129
|
+
/>
|
|
130
|
+
</v-sheet>
|
|
131
|
+
</v-sheet>
|
|
132
|
+
</v-card>
|
|
133
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useConditionStore } from '../../stores/conditions'
|
|
3
|
+
import { watch } from 'vue'
|
|
4
|
+
import { storeToRefs } from 'pinia'
|
|
5
|
+
import ConditionItem from './ConditionItem.vue'
|
|
6
|
+
|
|
7
|
+
const emit = defineEmits<{
|
|
8
|
+
(e: 'close'): void
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const conditionStore = useConditionStore()
|
|
12
|
+
const { conditions } = storeToRefs(conditionStore)
|
|
13
|
+
|
|
14
|
+
const isExpanded = defineModel<boolean>('isExpanded')
|
|
15
|
+
|
|
16
|
+
function applyFilters() {
|
|
17
|
+
conditionStore.applyConditions()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function clearFilters() {
|
|
21
|
+
conditionStore.clearConditions()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
watch(
|
|
25
|
+
() => conditions.value,
|
|
26
|
+
(newConditions) => {
|
|
27
|
+
if (newConditions.length === 0) {
|
|
28
|
+
conditionStore.addCondition()
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{ immediate: true }
|
|
32
|
+
)
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<v-sheet class="d-flex h-full flex-col overflow-hidden">
|
|
37
|
+
<v-sheet class="h-full overflow-auto ">
|
|
38
|
+
<div class="d-flex gap-4 flex flex-column py-4 px-4">
|
|
39
|
+
<condition-item :condition="condition" v-for="condition in conditions" :key="condition.id"> </condition-item>
|
|
40
|
+
</div>
|
|
41
|
+
</v-sheet>
|
|
42
|
+
|
|
43
|
+
<v-divider />
|
|
44
|
+
<v-sheet class="d-flex justify-end gap-4 pa-4">
|
|
45
|
+
<v-btn color="primary" variant="tonal" @click="conditionStore.addCondition"> Add </v-btn>
|
|
46
|
+
<v-spacer />
|
|
47
|
+
<v-btn color="primary" variant="tonal" @click="clearFilters"> Clear </v-btn>
|
|
48
|
+
<v-btn color="primary" variant="outlined" @click="applyFilters"> Apply </v-btn>
|
|
49
|
+
</v-sheet>
|
|
50
|
+
</v-sheet>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<style scoped></style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import QueriesList from './QueriesList.vue'
|
|
4
|
+
import ConditionsList from './ConditionsList.vue'
|
|
5
|
+
|
|
6
|
+
const emit = defineEmits<{
|
|
7
|
+
(e: 'close'): void
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
const activeTab = ref<'queries' | 'conditions'>('conditions')
|
|
11
|
+
|
|
12
|
+
const isExpanded = defineModel<boolean>('isExpanded')
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<v-navigation-drawer
|
|
17
|
+
v-model="isExpanded"
|
|
18
|
+
:width="600"
|
|
19
|
+
:elevation="1"
|
|
20
|
+
location="right"
|
|
21
|
+
:border="0"
|
|
22
|
+
temporary
|
|
23
|
+
scrim
|
|
24
|
+
@update:model-value="emit('close')"
|
|
25
|
+
>
|
|
26
|
+
<v-card class="h-full overflow-hidden d-flex flex-col">
|
|
27
|
+
<v-tabs v-model="activeTab" align-tabs="center" grow hide-slider color="primary">
|
|
28
|
+
<v-tab value="conditions" prepend-icon="mdi-database-search" variant="tonal">
|
|
29
|
+
Conditions
|
|
30
|
+
</v-tab>
|
|
31
|
+
<v-tab value="queries" prepend-icon="mdi-table-filter" variant="tonal"> Queries </v-tab>
|
|
32
|
+
</v-tabs>
|
|
33
|
+
|
|
34
|
+
<v-divider />
|
|
35
|
+
|
|
36
|
+
<v-tabs-window v-model="activeTab" class="h-full overflow-auto">
|
|
37
|
+
<v-tabs-window-item value="queries" class="h-full overflow-auto">
|
|
38
|
+
<queries-list />
|
|
39
|
+
</v-tabs-window-item>
|
|
40
|
+
<v-tabs-window-item value="conditions" class="h-full overflow-auto">
|
|
41
|
+
<conditions-list />
|
|
42
|
+
</v-tabs-window-item>
|
|
43
|
+
</v-tabs-window>
|
|
44
|
+
</v-card>
|
|
45
|
+
</v-navigation-drawer>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped></style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TableQueryColumn } from '@antcde/connect-ts/services/TableQueryService'
|
|
3
|
+
import { storeToRefs } from 'pinia'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
import { useI18n } from 'vue-i18n'
|
|
6
|
+
import { useQueryStore } from '../../stores/queries'
|
|
7
|
+
import { useRecordStore } from '../../stores/records'
|
|
8
|
+
import { useConditionStore } from '../../stores/conditions'
|
|
9
|
+
import QueryItem from './QueryItem.vue'
|
|
10
|
+
|
|
11
|
+
const { t } = useI18n()
|
|
12
|
+
|
|
13
|
+
const queryStore = useQueryStore()
|
|
14
|
+
const { queries, isCreating } = storeToRefs(queryStore)
|
|
15
|
+
|
|
16
|
+
const recordStore = useRecordStore()
|
|
17
|
+
const { queryPayload } = storeToRefs(recordStore)
|
|
18
|
+
|
|
19
|
+
const conditionStore = useConditionStore()
|
|
20
|
+
const { appliedAndValidConditions } = storeToRefs(conditionStore)
|
|
21
|
+
|
|
22
|
+
const queryName = ref('')
|
|
23
|
+
|
|
24
|
+
function createQuery() {
|
|
25
|
+
if (!queryName.value || appliedAndValidConditions.value.length === 0) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
queryStore.createQuery(
|
|
30
|
+
queryName.value,
|
|
31
|
+
(queryPayload.value?.tables[0]?.columns as TableQueryColumn[]) ?? []
|
|
32
|
+
)
|
|
33
|
+
queryName.value = ''
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<v-sheet class="d-flex h-full flex-col overflow-hidden">
|
|
39
|
+
<v-sheet class="p-4">
|
|
40
|
+
<v-label class="mr-2 font-semibold"> Query Name </v-label>
|
|
41
|
+
<v-text-field
|
|
42
|
+
v-model="queryName"
|
|
43
|
+
color="primary"
|
|
44
|
+
@keydown.enter="createQuery"
|
|
45
|
+
:hint="
|
|
46
|
+
appliedAndValidConditions.length > 0
|
|
47
|
+
? 'Press Enter to create a new query'
|
|
48
|
+
: 'No conditions applied'
|
|
49
|
+
"
|
|
50
|
+
persistent-hint
|
|
51
|
+
variant="outlined"
|
|
52
|
+
density="compact"
|
|
53
|
+
:disabled="isCreating || appliedAndValidConditions.length === 0"
|
|
54
|
+
/>
|
|
55
|
+
</v-sheet>
|
|
56
|
+
<v-divider />
|
|
57
|
+
<v-expansion-panels :elevation="1" class="p-4" variant="accordion">
|
|
58
|
+
<query-item v-for="query in queries" :key="query.id" :query="query" />
|
|
59
|
+
</v-expansion-panels>
|
|
60
|
+
</v-sheet>
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<style scoped></style>
|
|
@@ -38,7 +38,7 @@ async function applyQuery() {
|
|
|
38
38
|
|
|
39
39
|
<template>
|
|
40
40
|
<v-expansion-panel>
|
|
41
|
-
<v-expansion-panel-title
|
|
41
|
+
<v-expansion-panel-title hide-actions>
|
|
42
42
|
<template #default="{ expanded }">
|
|
43
43
|
<v-row no-gutters>
|
|
44
44
|
{{ query.name }}
|
|
@@ -72,7 +72,7 @@ async function applyQuery() {
|
|
|
72
72
|
</template>
|
|
73
73
|
</v-expansion-panel-title>
|
|
74
74
|
|
|
75
|
-
<v-
|
|
75
|
+
<v-sheet class="px-0">
|
|
76
76
|
<v-table v-if="conditions.length" density="compact">
|
|
77
77
|
<thead>
|
|
78
78
|
<tr>
|
|
@@ -103,7 +103,7 @@ async function applyQuery() {
|
|
|
103
103
|
icon="mdi-database-search"
|
|
104
104
|
:text="t('project.tableConfig.queries.failedToParse')"
|
|
105
105
|
/>
|
|
106
|
-
</v-
|
|
106
|
+
</v-sheet>
|
|
107
107
|
</v-expansion-panel>
|
|
108
108
|
</template>
|
|
109
109
|
|
|
@@ -23,31 +23,24 @@ const { update: canUpdate } = table.value?.permissions ?? {}
|
|
|
23
23
|
|
|
24
24
|
const isSelected = computed(() => recordStore.isCellSelected(props.recordId, props.column.id))
|
|
25
25
|
|
|
26
|
-
const updateOnChange = computed(
|
|
27
|
-
'text',
|
|
28
|
-
|
|
29
|
-
'link',
|
|
30
|
-
'float',
|
|
31
|
-
'email',
|
|
32
|
-
'text-field',
|
|
33
|
-
].includes(props.column.type))
|
|
26
|
+
const updateOnChange = computed(
|
|
27
|
+
() => !['text', 'integer', 'link', 'float', 'email', 'text-field'].includes(props.column.type)
|
|
28
|
+
)
|
|
34
29
|
|
|
35
30
|
async function updateRecord() {
|
|
36
|
-
if (!canUpdate || (props.column.required && !currentCellValue.value) || isUpdating.value)
|
|
37
|
-
return
|
|
31
|
+
if (!canUpdate || (props.column.required && !currentCellValue.value) || isUpdating.value) return
|
|
38
32
|
|
|
39
33
|
try {
|
|
40
34
|
isUpdating.value = true
|
|
41
35
|
|
|
42
36
|
const body = await parseRecordBody([props.column], {
|
|
43
|
-
[props.column.name]: currentCellValue.value
|
|
37
|
+
[props.column.name]: currentCellValue.value
|
|
44
38
|
})
|
|
45
39
|
|
|
46
40
|
await recordStore.updateRecord(props.recordId, body)
|
|
47
41
|
|
|
48
42
|
recordStore.selectNextCell()
|
|
49
|
-
}
|
|
50
|
-
finally {
|
|
43
|
+
} finally {
|
|
51
44
|
isUpdating.value = false
|
|
52
45
|
}
|
|
53
46
|
}
|
|
@@ -72,7 +65,7 @@ watch(
|
|
|
72
65
|
() => props.value,
|
|
73
66
|
(value) => {
|
|
74
67
|
currentCellValue.value = value
|
|
75
|
-
}
|
|
68
|
+
}
|
|
76
69
|
)
|
|
77
70
|
|
|
78
71
|
watch(
|
|
@@ -81,38 +74,35 @@ watch(
|
|
|
81
74
|
if (wasSelected && !isSelected) {
|
|
82
75
|
resetCell()
|
|
83
76
|
}
|
|
84
|
-
}
|
|
77
|
+
}
|
|
85
78
|
)
|
|
86
79
|
</script>
|
|
87
80
|
|
|
88
81
|
<template>
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
v-else
|
|
112
|
-
|
|
113
|
-
:column="column"
|
|
114
|
-
:record-id="recordId"
|
|
115
|
-
/>
|
|
82
|
+
<div class="px-2">
|
|
83
|
+
<record-input
|
|
84
|
+
v-if="isSelected && canUpdate && false"
|
|
85
|
+
v-model="currentCellValue"
|
|
86
|
+
hide-label
|
|
87
|
+
:column="column"
|
|
88
|
+
:is-loading="isUpdating"
|
|
89
|
+
:input-props="{
|
|
90
|
+
hideDetails: true,
|
|
91
|
+
variant: 'solo-filled',
|
|
92
|
+
label: null,
|
|
93
|
+
placeholder: null,
|
|
94
|
+
singleLine: true,
|
|
95
|
+
disabled: isUpdating,
|
|
96
|
+
rows: 1,
|
|
97
|
+
noResize: true
|
|
98
|
+
}"
|
|
99
|
+
@keydown.esc="resetCell"
|
|
100
|
+
@keydown.enter="handleEnter"
|
|
101
|
+
@update:model-value="handleChange"
|
|
102
|
+
/>
|
|
103
|
+
|
|
104
|
+
<record-value v-else :value="value" :column="column" :record-id="recordId" />
|
|
105
|
+
</div>
|
|
116
106
|
</template>
|
|
117
107
|
|
|
118
108
|
<style lang="scss" scoped></style>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { Column } from '@antcde/connect-ts/services/ColumnService'
|
|
3
|
+
import type { TableRecord } from '@antcde/connect-ts/services/TableService'
|
|
4
|
+
import { storeToRefs } from 'pinia'
|
|
5
|
+
import { computed, ref, watch } from 'vue'
|
|
6
|
+
import { useI18n } from 'vue-i18n'
|
|
7
|
+
import { parseRecordBody, validateEmail } from '../../composables/records'
|
|
8
|
+
|
|
9
|
+
import { useColumnStore } from '../../stores/columns'
|
|
10
|
+
import { useRecordStore } from '../../stores/records'
|
|
11
|
+
import RecordInput from '../Records/RecordInput.vue'
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
isDisplayed: boolean
|
|
15
|
+
record?: TableRecord | null
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const emit = defineEmits(['close'])
|
|
19
|
+
|
|
20
|
+
const { t } = useI18n()
|
|
21
|
+
|
|
22
|
+
const recordStore = useRecordStore()
|
|
23
|
+
const columnStore = useColumnStore()
|
|
24
|
+
|
|
25
|
+
const { isUpdating, isCreating } = storeToRefs(recordStore)
|
|
26
|
+
|
|
27
|
+
const { columns } = storeToRefs(columnStore)
|
|
28
|
+
|
|
29
|
+
const recordItem = ref<TableRecord>({
|
|
30
|
+
id: ''
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const isLoading = computed(() => isUpdating.value || isCreating.value)
|
|
34
|
+
const isValid = computed(() =>
|
|
35
|
+
columns.value.every((column) => validateColumnValue(column, recordItem.value[column.name]))
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
function validateColumnValue(column: Column, value: any) {
|
|
39
|
+
if (column.required && !value) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
if (column.type === 'email') {
|
|
43
|
+
return value ? validateEmail(value) : true
|
|
44
|
+
}
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function saveRecord() {
|
|
49
|
+
const body = await parseRecordBody(columns.value, recordItem.value)
|
|
50
|
+
try {
|
|
51
|
+
if (recordItem.value.id) {
|
|
52
|
+
await recordStore.updateRecord(recordItem.value.id, body)
|
|
53
|
+
} else {
|
|
54
|
+
await recordStore.createRecord(body)
|
|
55
|
+
}
|
|
56
|
+
close()
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function close() {
|
|
63
|
+
emit('close')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handleInputChange(column: Column, value: any) {
|
|
67
|
+
recordItem.value[column.name] = value
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
watch(
|
|
71
|
+
() => props.record,
|
|
72
|
+
(record) => (recordItem.value = record ? { ...record } : { id: '' }),
|
|
73
|
+
{ immediate: true, deep: true }
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const test = ref('')
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<v-navigation-drawer
|
|
81
|
+
:model-value="isDisplayed"
|
|
82
|
+
:width="800"
|
|
83
|
+
:elevation="1"
|
|
84
|
+
location="right"
|
|
85
|
+
:border="0"
|
|
86
|
+
temporary
|
|
87
|
+
persistent
|
|
88
|
+
scrim
|
|
89
|
+
@update:model-value="close"
|
|
90
|
+
>
|
|
91
|
+
<v-sheet class="d-flex flex-col h-full">
|
|
92
|
+
<v-toolbar
|
|
93
|
+
class="d-flex flex-row justify-between align-center pe-4"
|
|
94
|
+
color="grey-lighten-3"
|
|
95
|
+
variant="tonal"
|
|
96
|
+
density="compact"
|
|
97
|
+
>
|
|
98
|
+
<v-toolbar-title class="text-h6 font-semibold">
|
|
99
|
+
{{
|
|
100
|
+
t(
|
|
101
|
+
recordItem.id
|
|
102
|
+
? 'project.records.dialog.updateTitle'
|
|
103
|
+
: 'project.records.dialog.createTitle'
|
|
104
|
+
)
|
|
105
|
+
}}
|
|
106
|
+
</v-toolbar-title>
|
|
107
|
+
<v-spacer />
|
|
108
|
+
<v-btn icon @click="emit('close')">
|
|
109
|
+
<v-icon>mdi-close</v-icon>
|
|
110
|
+
</v-btn>
|
|
111
|
+
</v-toolbar>
|
|
112
|
+
<v-divider />
|
|
113
|
+
|
|
114
|
+
<v-card elevation="0" flat class="d-flex flex-col gap-1 h-full" v-if="isDisplayed">
|
|
115
|
+
<v-card-text class="d-flex flex-col gap-4 overflow-auto">
|
|
116
|
+
<record-input
|
|
117
|
+
v-for="column in columns"
|
|
118
|
+
:key="column.name"
|
|
119
|
+
v-model="recordItem[column.name]"
|
|
120
|
+
:column="column"
|
|
121
|
+
:hide-label="false"
|
|
122
|
+
/>
|
|
123
|
+
</v-card-text>
|
|
124
|
+
</v-card>
|
|
125
|
+
|
|
126
|
+
<v-divider />
|
|
127
|
+
|
|
128
|
+
<v-sheet class="d-flex flex-row gap-4 justify-end align-center px-8 py-2">
|
|
129
|
+
<v-btn :disabled="isLoading" variant="text" color="primary" @click="emit('close')">
|
|
130
|
+
{{ t('system.buttons.cancel') }}
|
|
131
|
+
</v-btn>
|
|
132
|
+
<v-btn
|
|
133
|
+
:disabled="isLoading || !isValid"
|
|
134
|
+
:loading="isLoading"
|
|
135
|
+
color="primary"
|
|
136
|
+
variant="flat"
|
|
137
|
+
@click="saveRecord"
|
|
138
|
+
>
|
|
139
|
+
{{ t('system.buttons.save') }}
|
|
140
|
+
</v-btn>
|
|
141
|
+
</v-sheet>
|
|
142
|
+
</v-sheet>
|
|
143
|
+
</v-navigation-drawer>
|
|
144
|
+
</template>
|
|
145
|
+
|
|
146
|
+
<style lang="scss" scoped></style>
|