adminforth 4.7.5 → 4.9.0
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/modules/styles.js +4 -4
- package/dist/spa/package-lock.json +1 -52
- package/dist/spa/package.json +2 -2
- package/dist/spa/pnpm-lock.yaml +0 -44
- package/dist/spa/src/afcl/Calendar.vue +211 -0
- package/dist/spa/src/afcl/DateField.vue +257 -0
- package/dist/spa/src/afcl/DatePicker.vue +103 -245
- package/dist/spa/src/afcl/JsonViewer.vue +165 -18
- package/dist/spa/src/afcl/JsonViewerNode.vue +102 -0
- package/dist/spa/src/afcl/TimeField.vue +52 -0
- package/dist/spa/src/afcl/jsonFormat.ts +85 -0
- package/dist/spa/src/afcl/pickerStyles.ts +25 -0
- package/dist/spa/src/afcl/shadowRoot.ts +1 -2
- package/dist/spa/src/components/ColumnValueInput.vue +9 -7
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +1 -1
- package/dist/spa/src/components/CustomDateRangePicker.vue +47 -165
- package/dist/spa/src/components/Filters.vue +7 -4
- package/dist/spa/src/components/GroupsTable.vue +23 -43
- package/dist/spa/src/components/ShowTable.vue +21 -31
- package/dist/spa/src/components/ValueRenderer.vue +8 -27
- package/dist/spa/src/types/Common.ts +6 -5
- package/dist/spa/src/utils/dateUtils.ts +33 -21
- package/dist/spa/src/views/CreateEditSkeleton.vue +6 -17
- package/dist/spa/src/views/ShowView.vue +14 -24
- package/dist/spa/tailwind.config.js +1 -1
- package/dist/types/Common.d.ts +4 -3
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,75 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
<input ref="datepickerStartEl" type="text"
|
|
10
|
-
class="bg-lightDatePickerButtonBackground border border-lightDatePickerButtonBorder text-lightDatePickerButtonText placeholder-lightDatePickerPlaceHolder text-sm rounded-default shadow-customLight focus:outline-none focus:ring-[3px] focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder block w-full px-2.5 py-1.5 leading-5 dark:bg-darkDatePickerButtonBackground dark:border-darkDatePickerButtonBorder dark:placeholder-darkDatePickerPlaceHolder dark:text-darkDatePickerButtonText dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
|
|
11
|
-
:placeholder="$t('From')">
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
<div class="relative">
|
|
15
|
-
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
16
|
-
<IconCalendar class="w-4 h-4 text-lightDatePickerIcon dark:text-darkDatePickerIcon"/>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<input ref="datepickerEndEl" type="text"
|
|
20
|
-
class="bg-lightDatePickerButtonBackground border border-lightDatePickerButtonBorder text-lightDatePickerButtonText placeholder-lightDatePickerPlaceHolder text-sm rounded-default shadow-customLight focus:outline-none focus:ring-[3px] focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder block w-full px-2.5 py-1.5 leading-5 dark:bg-darkDatePickerButtonBackground dark:border-darkDatePickerButtonBorder dark:placeholder-darkDatePickerPlaceHolder dark:text-darkDatePickerButtonText dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
|
|
21
|
-
:placeholder="$t('To')">
|
|
22
|
-
</div>
|
|
2
|
+
<div class="af-date-range-picker flex flex-col gap-2">
|
|
3
|
+
<div v-if="column.type !== 'time'" class="flex items-center" :class="PICKER_BOX_CLASSES">
|
|
4
|
+
<DateField v-model="startDate" bare class="flex-1 min-w-0 h-full" :placeholder="$t('From')" />
|
|
5
|
+
<IconArrowRight class="w-3.5 h-3.5 shrink-0 text-lightDatePickerIcon dark:text-darkDatePickerIcon rtl:rotate-180" aria-hidden="true" />
|
|
6
|
+
<DateField v-model="endDate" bare class="flex-1 min-w-0 h-full" :placeholder="$t('To')" />
|
|
23
7
|
</div>
|
|
24
8
|
|
|
25
|
-
<div>
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
<div class="relative">
|
|
29
|
-
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
30
|
-
<IconClock class="w-4 h-4 text-lightDatePickerIcon dark:text-darkDatePickerIcon bg-lightDatePickerButtonBackground dark:bg-darkDatePickerButtonBackground"/>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
<input v-model="startTime" type="time" id="start-time"
|
|
34
|
-
class="bg-lightDatePickerButtonBackground border border-lightDatePickerButtonBorder text-lightDatePickerButtonText placeholder-lightDatePickerPlaceHolder text-sm rounded-default shadow-customLight focus:outline-none focus:ring-[3px] focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder block w-full px-2.5 py-1.5 leading-5 dark:bg-darkDatePickerButtonBackground dark:border-darkDatePickerButtonBorder dark:placeholder-darkDatePickerPlaceHolder dark:text-darkDatePickerButtonText dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
|
|
35
|
-
value="00:00" required/>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div>
|
|
40
|
-
<div class="relative">
|
|
41
|
-
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
42
|
-
<IconClock class="w-4 h-4 text-lightDatePickerIcon dark:text-darkDatePickerIcon bg-lightDatePickerButtonBackground dark:bg-darkDatePickerButtonBackground"/>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
<input v-model="endTime" type="time" id="end-time"
|
|
46
|
-
class="bg-lightDatePickerButtonBackground border border-lightDatePickerButtonBorder text-lightDatePickerButtonText placeholder-lightDatePickerPlaceHolder text-sm rounded-default shadow-customLight focus:outline-none focus:ring-[3px] focus:ring-lightInputFocusRing focus:border-lightInputFocusBorder block w-full px-2.5 py-1.5 leading-5 dark:bg-darkDatePickerButtonBackground dark:border-darkDatePickerButtonBorder dark:placeholder-darkDatePickerPlaceHolder dark:text-darkDatePickerButtonText dark:focus:ring-darkInputFocusRing dark:focus:border-darkInputFocusBorder"
|
|
47
|
-
value="00:00" required/>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<button type="button"
|
|
53
|
-
class="text-lightPrimary dark:text-darkPrimary text-[13px] font-medium hover:underline p-0 inline-flex items-center gap-0.5 mb-2"
|
|
54
|
-
:class="{hidden: column.type !== 'datetime'}"
|
|
55
|
-
@click="toggleTimeInputs">{{ showTimeInputs ? $t('Hide time') : $t('Show time') }}
|
|
56
|
-
<IconChevronDown class="w-4 h-4" :class="{'rotate-180': showTimeInputs}"/>
|
|
57
|
-
</button>
|
|
9
|
+
<div v-if="showTimeInputs" class="grid grid-cols-2 gap-2">
|
|
10
|
+
<TimeField v-model="startTime" />
|
|
11
|
+
<TimeField v-model="endTime" />
|
|
58
12
|
</div>
|
|
13
|
+
|
|
14
|
+
<button type="button"
|
|
15
|
+
v-if="column.type === 'datetime'"
|
|
16
|
+
class="self-start inline-flex items-center gap-0.5 p-0 rounded-sm text-[13px] font-medium hover:underline focus:outline-none focus-visible:ring-[3px] focus-visible:ring-lightFocusRing dark:focus-visible:ring-darkFocusRing text-lightDatePickerExpandText dark:text-darkDatePickerExpandText"
|
|
17
|
+
@click="showTimeInputs = !showTimeInputs">{{ showTimeInputs ? $t('Hide time') : $t('Show time') }}
|
|
18
|
+
<IconChevronDown class="w-4 h-4" :class="{'rotate-180': showTimeInputs}" aria-hidden="true"/>
|
|
19
|
+
</button>
|
|
59
20
|
</div>
|
|
60
21
|
</template>
|
|
61
22
|
<script setup>
|
|
62
|
-
import {ref, computed,
|
|
23
|
+
import {ref, computed, watch} from 'vue';
|
|
63
24
|
import dayjs from 'dayjs';
|
|
64
|
-
import utc from 'dayjs/plugin/utc';
|
|
65
|
-
|
|
66
|
-
import {useCoreStore} from '@/stores/core';
|
|
67
|
-
import {FLEXIBLE_DATEPICKER_FORMAT} from '@/utils';
|
|
68
25
|
|
|
69
|
-
import {
|
|
26
|
+
import {PICKER_DAY_FORMAT} from '@/utils';
|
|
27
|
+
import DateField from '@/afcl/DateField.vue';
|
|
28
|
+
import TimeField from '@/afcl/TimeField.vue';
|
|
29
|
+
import {PICKER_BOX_CLASSES} from '@/afcl/pickerStyles';
|
|
70
30
|
|
|
71
|
-
|
|
72
|
-
dayjs.extend(utc)
|
|
31
|
+
import { IconArrowRight, IconChevronDown } from '@iconify-prerendered/vue-lucide';
|
|
73
32
|
|
|
74
33
|
const props = defineProps({
|
|
75
34
|
valueStart: {
|
|
@@ -85,20 +44,18 @@ const props = defineProps({
|
|
|
85
44
|
|
|
86
45
|
const emit = defineEmits(['update:valueStart', 'update:valueEnd']);
|
|
87
46
|
|
|
88
|
-
|
|
89
|
-
const
|
|
47
|
+
// a range from the start of a day to its end needs no time, the time fields stay hidden for it
|
|
48
|
+
const DAY_START = '00:00:00';
|
|
49
|
+
const DAY_END = '23:59:59';
|
|
90
50
|
|
|
91
51
|
const showTimeInputs = ref(props.column?.type === 'time');
|
|
92
52
|
|
|
93
|
-
const startDate = ref(
|
|
94
|
-
const endDate = ref(
|
|
53
|
+
const startDate = ref(null);
|
|
54
|
+
const endDate = ref(null);
|
|
95
55
|
|
|
96
56
|
const startTime = ref('');
|
|
97
57
|
const endTime = ref('');
|
|
98
58
|
|
|
99
|
-
const datepickerStartObject = ref('')
|
|
100
|
-
const datepickerEndObject = ref('')
|
|
101
|
-
|
|
102
59
|
const start = computed(() => {
|
|
103
60
|
if (props.column?.type === 'time') {
|
|
104
61
|
return formatTime(startTime.value);
|
|
@@ -136,59 +93,36 @@ const end = computed(() => {
|
|
|
136
93
|
return date.format('YYYY-MM-DD');
|
|
137
94
|
}
|
|
138
95
|
|
|
139
|
-
|
|
140
|
-
date = addTimeToDate(formatTime(endTime.value), date)
|
|
141
|
-
} else {
|
|
142
|
-
date = addTimeToDate('23:59:59', date)
|
|
143
|
-
}
|
|
96
|
+
date = addTimeToDate(endTime.value ? formatTime(endTime.value) : DAY_END, date);
|
|
144
97
|
|
|
145
98
|
return date.utc().toISOString();
|
|
146
99
|
})
|
|
147
100
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} else if (props.column.type === 'time') {
|
|
153
|
-
startTime.value = props.valueStart;
|
|
154
|
-
} else {
|
|
155
|
-
const date = dayjs(props.valueStart);
|
|
156
|
-
datepickerStartEl.value.value = date.format('DD MMM YYYY');
|
|
157
|
-
if (date.format('HH:mm') !== '00:00') {
|
|
158
|
-
startTime.value = date.format('HH:mm');
|
|
159
|
-
showTimeInputs.value = true;
|
|
160
|
-
} else {
|
|
161
|
-
startTime.value = '';
|
|
162
|
-
}
|
|
163
|
-
startDate.value = date.toString();
|
|
164
|
-
}
|
|
101
|
+
// the time of a datetime bound for the time field, empty when the bound is the start or the end of its day
|
|
102
|
+
function boundTime(date, dayEdge) {
|
|
103
|
+
return props.column.type === 'datetime' && date.format('HH:mm:ss') !== dayEdge ? date.format('HH:mm') : '';
|
|
104
|
+
}
|
|
165
105
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
106
|
+
// shows a bound of the range from its prop. Each bound follows only its own prop: the other one may still wait
|
|
107
|
+
// in the debounce of the filters, resetting it here would drop it
|
|
108
|
+
function showBound(value, dayEdge, date, time) {
|
|
109
|
+
if (!value) {
|
|
110
|
+
date.value = null;
|
|
111
|
+
time.value = '';
|
|
170
112
|
} else if (props.column.type === 'time') {
|
|
171
|
-
|
|
113
|
+
time.value = value;
|
|
172
114
|
} else {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
endTime.value = '';
|
|
180
|
-
}
|
|
181
|
-
endDate.value = date.toString();
|
|
115
|
+
const parsed = dayjs(value);
|
|
116
|
+
date.value = parsed.format(PICKER_DAY_FORMAT);
|
|
117
|
+
time.value = boundTime(parsed, dayEdge);
|
|
118
|
+
}
|
|
119
|
+
if (time.value) {
|
|
120
|
+
showTimeInputs.value = true;
|
|
182
121
|
}
|
|
183
122
|
}
|
|
184
123
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
watch(() => [props.valueStart, props.valueEnd], (value) => {
|
|
189
|
-
updateFromProps();
|
|
190
|
-
});
|
|
191
|
-
})
|
|
124
|
+
watch(() => props.valueStart, (value) => showBound(value, DAY_START, startDate, startTime), { immediate: true });
|
|
125
|
+
watch(() => props.valueEnd, (value) => showBound(value, DAY_END, endDate, endTime), { immediate: true });
|
|
192
126
|
|
|
193
127
|
watch(start, () => {
|
|
194
128
|
emit('update:valueStart', start.value)
|
|
@@ -198,45 +132,6 @@ watch(end, () => {
|
|
|
198
132
|
emit('update:valueEnd', end.value)
|
|
199
133
|
})
|
|
200
134
|
|
|
201
|
-
async function initDatepickers() {
|
|
202
|
-
const { default: Datepicker } = await import(
|
|
203
|
-
'flowbite-datepicker/Datepicker'
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
if (!datepickerStartEl.value || !datepickerEndEl.value) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const LS_LANG_KEY = `afLanguage`;
|
|
211
|
-
const options = {format: FLEXIBLE_DATEPICKER_FORMAT, language: localStorage.getItem(LS_LANG_KEY)};
|
|
212
|
-
datepickerStartObject.value = new Datepicker(datepickerStartEl.value, options);
|
|
213
|
-
datepickerEndObject.value = new Datepicker(datepickerEndEl.value, options);
|
|
214
|
-
addChangeDateListener();
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function addChangeDateListener() {
|
|
218
|
-
datepickerStartEl.value.addEventListener('changeDate', setStartDate)
|
|
219
|
-
datepickerEndEl.value.addEventListener('changeDate', setEndDate)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function removeChangeDateListener() {
|
|
223
|
-
datepickerStartEl.value.removeEventListener('changeDate', setStartDate);
|
|
224
|
-
datepickerEndEl.value.removeEventListener('changeDate', setEndDate);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function destroyDatepickerElement() {
|
|
228
|
-
datepickerStartObject.value?.destroy?.();
|
|
229
|
-
datepickerEndObject.value?.destroy?.();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function setStartDate(event) {
|
|
233
|
-
startDate.value = event.detail.date
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function setEndDate(event) {
|
|
237
|
-
endDate.value = event.detail.date
|
|
238
|
-
}
|
|
239
|
-
|
|
240
135
|
function formatTime(time) {
|
|
241
136
|
return time.split(':').map(Number).length === 2 ? time + ':00' : time;
|
|
242
137
|
}
|
|
@@ -245,17 +140,4 @@ function addTimeToDate(time, date) {
|
|
|
245
140
|
const [hours, minutes, seconds] = time.split(':').map(Number)
|
|
246
141
|
return date.hour(hours).minute(minutes).second(seconds)
|
|
247
142
|
}
|
|
248
|
-
|
|
249
|
-
const toggleTimeInputs = () => {
|
|
250
|
-
showTimeInputs.value = !showTimeInputs.value
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
onMounted(() => {
|
|
254
|
-
initDatepickers();
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
onBeforeUnmount(() => {
|
|
258
|
-
removeChangeDateListener();
|
|
259
|
-
destroyDatepickerElement();
|
|
260
|
-
})
|
|
261
|
-
</script>
|
|
143
|
+
</script>
|
|
@@ -277,12 +277,15 @@ watch(() => props.show, (show) => {
|
|
|
277
277
|
const onFilterInput = computed(() => {
|
|
278
278
|
if (!props.columns) return {} as Record<string, any>;
|
|
279
279
|
|
|
280
|
-
return props.columns.reduce<Record<string,
|
|
280
|
+
return props.columns.reduce<Record<string, (item: Parameters<typeof setFilterItem>[0]) => void>>((acc, c) => {
|
|
281
|
+
// a debounce per operator: both ends of a date range set within the debounce time must not drop the first one
|
|
282
|
+
const byOperator: Partial<Record<AdminForthFilterOperators, ReturnType<typeof debounce>>> = {};
|
|
281
283
|
return {
|
|
282
284
|
...acc,
|
|
283
|
-
[c.name]:
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
[c.name]: (item: Parameters<typeof setFilterItem>[0]) => {
|
|
286
|
+
byOperator[item.operator] ??= debounce(setFilterItem, c.filterOptions?.debounceTimeMs || 10);
|
|
287
|
+
byOperator[item.operator]!(item);
|
|
288
|
+
},
|
|
286
289
|
};
|
|
287
290
|
}, {});
|
|
288
291
|
});
|
|
@@ -1,49 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="rounded-lg shadow-resourseFormShadow dark:shadow-darkResourseFormShadow border border-lightFormBorder bg-lightForm dark:bg-darkForm dark:border-darkFormBorder">
|
|
3
|
-
<div v-if="group.groupName && !group.noTitle" class="
|
|
3
|
+
<div v-if="group.groupName && !group.noTitle" class="px-5 pt-4 pb-1 text-sm font-semibold text-lightFormFieldTextColor dark:text-darkFormFieldTextColor">
|
|
4
4
|
{{ group.groupName }}
|
|
5
5
|
</div>
|
|
6
6
|
<table class="w-full text-sm text-left rtl:text-right text-lightFormFieldTextColor dark:text-darkFormFieldTextColor">
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<th scope="col" :class="{'rounded-tr-lg': !group.groupName}" class="px-5 py-2.5 font-medium hidden md:table-cell">
|
|
13
|
-
{{ $t('Value') }}
|
|
14
|
-
</th>
|
|
15
|
-
</tr>
|
|
16
|
-
</thead>
|
|
17
|
-
<tbody>
|
|
7
|
+
<colgroup>
|
|
8
|
+
<col class="md:w-56">
|
|
9
|
+
<col>
|
|
10
|
+
</colgroup>
|
|
11
|
+
<tbody v-if="currentValues !== null" class="divide-y divide-lightShowTableBodyBorder dark:divide-darkShowTableBodyBorder">
|
|
18
12
|
<tr
|
|
19
|
-
v-for="
|
|
13
|
+
v-for="column in group.columns"
|
|
20
14
|
:key="column.name"
|
|
21
|
-
|
|
22
|
-
class="bg-lightForm dark:bg-darkForm border-lightFormBorder dark:border-darkFormBorder block md:table-row"
|
|
23
|
-
:class="{ 'border-b': i !== group.columns.length - 1}"
|
|
15
|
+
class="block md:table-row"
|
|
24
16
|
>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<Tooltip v-if="column.required[mode]">
|
|
17
|
+
<!-- top-aligned: the label sits on the first line of a tall value, md:pt-5 centers it on a 34px input -->
|
|
18
|
+
<td class="px-5 pt-3 md:pt-5 pb-0 md:pb-3 block md:table-cell align-top">
|
|
19
|
+
<span class="flex items-center gap-1 text-[13px] leading-[18px] font-medium">
|
|
20
|
+
{{ column.label }}
|
|
21
|
+
<Tooltip v-if="column.required[mode]">
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
<IconAsterisk v-if="column.required[mode]" class="w-3 h-3"
|
|
24
|
+
:class="(columnsWithErrors[column.name] && validatingMode && !isValidating) ? 'text-lightInputErrorColor dark:text-darkInputErrorColor' : 'text-lightRequiredIconColor dark:text-darkRequiredIconColor'"
|
|
25
|
+
/>
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</div>
|
|
27
|
+
<template #tooltip>
|
|
28
|
+
{{ $t('Required field') }}
|
|
29
|
+
</template>
|
|
30
|
+
</Tooltip>
|
|
31
|
+
</span>
|
|
42
32
|
</td>
|
|
43
|
-
<td
|
|
44
|
-
class="px-5 py-3 whitespace-pre-wrap relative block md:table-cell"
|
|
45
|
-
:class="{'rounded-br-lg': i === group.columns.length - 1}"
|
|
46
|
-
>
|
|
33
|
+
<td class="px-5 pt-1.5 pb-3 md:pt-3 whitespace-pre-wrap relative block md:table-cell">
|
|
47
34
|
<ColumnValueInputWrapper
|
|
48
35
|
:source="source"
|
|
49
36
|
:column="column"
|
|
@@ -70,10 +57,9 @@
|
|
|
70
57
|
<script setup lang="ts">
|
|
71
58
|
import { IconAsterisk } from '@iconify-prerendered/vue-lucide';
|
|
72
59
|
import { Tooltip } from '@/afcl';
|
|
73
|
-
import { ref,
|
|
60
|
+
import { ref, watch, nextTick, type Ref } from 'vue';
|
|
74
61
|
import { useI18n } from 'vue-i18n';
|
|
75
62
|
import ColumnValueInputWrapper from "@/components/ColumnValueInputWrapper.vue";
|
|
76
|
-
import type { AdminForthResourceColumnInputCommon } from '@/types/Common';
|
|
77
63
|
|
|
78
64
|
const { t } = useI18n();
|
|
79
65
|
|
|
@@ -94,12 +80,6 @@
|
|
|
94
80
|
|
|
95
81
|
const customComponentsInValidity: Ref<Record<string, boolean>> = ref({});
|
|
96
82
|
const customComponentsEmptiness: Ref<Record<string, boolean>> = ref({});
|
|
97
|
-
const allColumnsHaveCustomComponent = computed(() => {
|
|
98
|
-
return props.group.columns.every((column: AdminForthResourceColumnInputCommon) => {
|
|
99
|
-
const componentKey = `${props.source}Row` as keyof typeof column.components;
|
|
100
|
-
return column.components?.[componentKey];
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
83
|
|
|
104
84
|
const emit = defineEmits(['update:customComponentsInValidity', 'update:customComponentsEmptiness']);
|
|
105
85
|
|
|
@@ -1,43 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="overflow-x-auto overscroll-x-contain shadow-resourseFormShadow dark:shadow-darkResourseFormShadow border border-lightFormBorder dark:border-darkFormBorder"
|
|
2
|
+
<div class="overflow-x-auto overscroll-x-contain shadow-resourseFormShadow dark:shadow-darkResourseFormShadow border border-lightFormBorder dark:border-darkFormBorder bg-lightShowTablesBodyBackground dark:bg-darkShowTablesBodyBackground"
|
|
3
3
|
:class="{'rounded-lg' : isRounded}"
|
|
4
4
|
>
|
|
5
|
-
<div v-if="groupName && !noTitle"
|
|
5
|
+
<div v-if="groupName && !noTitle" class="px-5 pt-4 pb-1 text-sm font-semibold text-lightShowTableHeadingText dark:text-darkShowTableHeadingText">
|
|
6
6
|
{{ groupName }}
|
|
7
7
|
</div>
|
|
8
8
|
<table class="w-full text-sm text-left rtl:text-right text-lightShowTableBodyText dark:text-darkShowTableBodyText table-fixed">
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<th scope="col" class="px-5 py-2.5 text-xs font-medium hidden md:table-cell">
|
|
15
|
-
{{ $t('Value') }}
|
|
16
|
-
</th>
|
|
17
|
-
</tr>
|
|
18
|
-
</thead>
|
|
19
|
-
<tbody>
|
|
9
|
+
<colgroup>
|
|
10
|
+
<col class="md:w-56">
|
|
11
|
+
<col>
|
|
12
|
+
</colgroup>
|
|
13
|
+
<tbody class="divide-y divide-lightShowTableBodyBorder dark:divide-darkShowTableBodyBorder">
|
|
20
14
|
<tr
|
|
21
|
-
v-for="column in
|
|
15
|
+
v-for="column in visibleColumns"
|
|
22
16
|
:key="column.name"
|
|
23
|
-
class="
|
|
24
|
-
dark:bg-darkShowTablesBodyBackground dark:border-darkShowTableBodyBorder block md:table-row"
|
|
17
|
+
class="block md:table-row"
|
|
25
18
|
>
|
|
26
19
|
<component
|
|
27
|
-
v-if="column.components?.showRow
|
|
20
|
+
v-if="column.components?.showRow"
|
|
28
21
|
:is="getCustomComponent(column.components.showRow)"
|
|
29
22
|
:meta="column.components.showRow.meta"
|
|
30
23
|
:column="column"
|
|
31
24
|
:resource="coreStore.resource"
|
|
32
25
|
:record="coreStore.record"
|
|
33
26
|
/>
|
|
34
|
-
<template v-else
|
|
35
|
-
<td class="px-5
|
|
36
|
-
|
|
37
|
-
{{ column.label }}
|
|
38
|
-
</div>
|
|
27
|
+
<template v-else>
|
|
28
|
+
<td class="px-5 pt-2.5 pb-0 md:pb-2.5 block md:table-cell align-top text-[13px] text-lightInputIconColor dark:text-darkInputIconColor">
|
|
29
|
+
{{ column.label }}
|
|
39
30
|
</td>
|
|
40
|
-
<td class="px-5
|
|
31
|
+
<td class="px-5 pt-1 pb-2.5 md:pt-2.5 block md:table-cell whitespace-pre-wrap" :data-af-column="column.name">
|
|
41
32
|
<component
|
|
42
33
|
v-if="column?.components?.show"
|
|
43
34
|
:is="getCustomComponent(column?.components?.show)"
|
|
@@ -58,14 +49,14 @@
|
|
|
58
49
|
</table>
|
|
59
50
|
</div>
|
|
60
51
|
</template>
|
|
61
|
-
|
|
52
|
+
|
|
62
53
|
<script setup lang="ts">
|
|
63
54
|
import ValueRenderer from '@/components/ValueRenderer.vue';
|
|
64
55
|
import { getCustomComponent, checkShowIf } from '@/utils';
|
|
65
56
|
import { useCoreStore } from '@/stores/core';
|
|
66
57
|
import { computed } from 'vue';
|
|
67
58
|
import type { AdminForthResourceFrontend, AdminForthResourceColumnInputCommon } from '@/types/Common';
|
|
68
|
-
const props = withDefaults(defineProps<{
|
|
59
|
+
const props = withDefaults(defineProps<{
|
|
69
60
|
columns: Array<{
|
|
70
61
|
name: string;
|
|
71
62
|
label?: string;
|
|
@@ -89,11 +80,10 @@
|
|
|
89
80
|
}>(), {
|
|
90
81
|
isRounded: true
|
|
91
82
|
});
|
|
92
|
-
|
|
83
|
+
|
|
93
84
|
const coreStore = useCoreStore();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
85
|
+
// hidden columns render no row, so the dividers between rows never double up
|
|
86
|
+
const visibleColumns = computed(() => {
|
|
87
|
+
return props.columns.filter(column => checkShowIf(column, props.record, props.resource?.columns || []));
|
|
98
88
|
});
|
|
99
|
-
</script>
|
|
89
|
+
</script>
|
|
@@ -103,9 +103,12 @@
|
|
|
103
103
|
<span v-else-if="column.type === 'decimal'">
|
|
104
104
|
{{ checkEmptyValues(record[column.name] && parseFloat(record[column.name]), route.meta.type as "show" | "list") }}
|
|
105
105
|
</span>
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
<JsonViewer
|
|
107
|
+
v-else-if="column.type === 'json' && record[column.name] !== null && record[column.name] !== undefined"
|
|
108
|
+
:value="record[column.name]"
|
|
109
|
+
:expandDepth="column.extra?.jsonCollapsedLevel"
|
|
110
|
+
:inline="route.meta.type === 'list'"
|
|
111
|
+
/>
|
|
109
112
|
<span v-else>
|
|
110
113
|
{{ checkEmptyValues(record[column.name], route.meta.type as "show" | "list") }}
|
|
111
114
|
</span>
|
|
@@ -117,20 +120,17 @@
|
|
|
117
120
|
|
|
118
121
|
import {checkEmptyValues, formatDate, formatDateTime, formatTime} from '@/utils';
|
|
119
122
|
import { useRoute, useRouter } from 'vue-router';
|
|
120
|
-
import
|
|
121
|
-
import { computed, defineAsyncComponent } from 'vue';
|
|
123
|
+
import { computed } from 'vue';
|
|
122
124
|
import { IconCheck } from '@iconify-prerendered/vue-lucide';
|
|
123
125
|
import type { AdminForthResourceColumnCommon } from '@/types/Common';
|
|
124
|
-
|
|
126
|
+
import { JsonViewer } from '@/afcl';
|
|
125
127
|
|
|
126
|
-
import { useCoreStore } from '@/stores/core';
|
|
127
128
|
import type { any } from 'zod';
|
|
128
129
|
|
|
129
130
|
const BADGE_CLASSES = 'inline-flex items-center whitespace-nowrap me-2 px-2 h-5 rounded-full border text-xs font-medium';
|
|
130
131
|
const TRUE_BADGE_CLASSES = 'bg-lightSuccessSoft text-lightSuccess border-lightSuccessBorder dark:bg-darkSuccessSoft dark:text-darkSuccess dark:border-darkSuccessBorder';
|
|
131
132
|
const FALSE_BADGE_CLASSES = 'bg-lightSecondaryDarken text-lightInputIconColor border-transparent dark:bg-darkSecondaryLighten dark:text-darkInputIconColor';
|
|
132
133
|
|
|
133
|
-
const coreStore = useCoreStore();
|
|
134
134
|
const route = useRoute();
|
|
135
135
|
|
|
136
136
|
const props = defineProps<{
|
|
@@ -180,22 +180,3 @@ function getArrayItemDisplayValue(value: any, column: AdminForthResourceColumnCo
|
|
|
180
180
|
|
|
181
181
|
}
|
|
182
182
|
</style>
|
|
183
|
-
|
|
184
|
-
<style lang="scss" >
|
|
185
|
-
|
|
186
|
-
.jv-container .jv-code {
|
|
187
|
-
padding: 10px 10px;
|
|
188
|
-
white-space: pre-wrap;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.jv-container .jv-button[class] {
|
|
192
|
-
@apply text-lightPrimary;
|
|
193
|
-
@apply dark:text-darkPrimary;
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.jv-container.jv-dark {
|
|
198
|
-
background: transparent;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
</style>
|
|
@@ -794,11 +794,12 @@ export interface AdminForthResourceColumnInputCommon {
|
|
|
794
794
|
extra?: {
|
|
795
795
|
|
|
796
796
|
/**
|
|
797
|
-
* How many levels of JSON
|
|
798
|
-
* `0` means - root
|
|
799
|
-
* `1` means -
|
|
800
|
-
*
|
|
801
|
-
*
|
|
797
|
+
* How many levels of JSON are open on the show page and in the popover of a list cell, deeper nodes start folded.
|
|
798
|
+
* `0` means - the root is folded into one line, a click opens it
|
|
799
|
+
* `1` means - the keys of the root are shown, their values are folded into one line each
|
|
800
|
+
* A node which fits in one line (up to 60 characters) is always shown whole.
|
|
801
|
+
*
|
|
802
|
+
* Default is 1.
|
|
802
803
|
*/
|
|
803
804
|
jsonCollapsedLevel?: number
|
|
804
805
|
}
|