adminforth 4.7.4 → 4.8.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/servers/express.d.ts.map +1 -1
- package/dist/servers/express.js +5 -41
- package/dist/servers/express.js.map +1 -1
- package/dist/servers/startingPages.d.ts +4 -0
- package/dist/servers/startingPages.d.ts.map +1 -0
- package/dist/servers/startingPages.js +127 -0
- package/dist/servers/startingPages.js.map +1 -0
- package/dist/spa/package.json +1 -0
- 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/TimeField.vue +52 -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/Sidebar.vue +1 -2
- 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/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="afcl-time-field relative">
|
|
3
|
+
<input
|
|
4
|
+
ref="inputEl"
|
|
5
|
+
v-model="model"
|
|
6
|
+
type="time"
|
|
7
|
+
:step="step"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
class="afcl-time-field-input relative w-full ps-8 pe-2.5"
|
|
10
|
+
:class="[PICKER_TEXT_CLASSES, PICKER_BOX_CLASSES, inputClass]"
|
|
11
|
+
/>
|
|
12
|
+
<!-- after the input, which is positioned for the picker indicator and would cover the icon -->
|
|
13
|
+
<IconClock :class="PICKER_ICON_CLASSES" aria-hidden="true" />
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { ref } from 'vue';
|
|
19
|
+
import { IconClock } from '@iconify-prerendered/vue-lucide';
|
|
20
|
+
import { PICKER_BOX_CLASSES, PICKER_ICON_CLASSES, PICKER_TEXT_CLASSES } from './pickerStyles';
|
|
21
|
+
|
|
22
|
+
defineProps<{
|
|
23
|
+
// 1 shows seconds
|
|
24
|
+
step?: number,
|
|
25
|
+
disabled?: boolean,
|
|
26
|
+
inputClass?: string,
|
|
27
|
+
}>();
|
|
28
|
+
|
|
29
|
+
// "HH:mm" or "HH:mm:ss", empty when no time is set
|
|
30
|
+
const model = defineModel<string>({ required: true });
|
|
31
|
+
|
|
32
|
+
const inputEl = ref<HTMLInputElement>();
|
|
33
|
+
|
|
34
|
+
defineExpose({
|
|
35
|
+
focus: () => inputEl.value!.focus(),
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
/* the clock icon on the left opens the time picker of Chromium: its own indicator lies over the icon, invisible */
|
|
41
|
+
.afcl-time-field-input::-webkit-calendar-picker-indicator {
|
|
42
|
+
position: absolute;
|
|
43
|
+
inset-inline-start: 0;
|
|
44
|
+
top: 0;
|
|
45
|
+
width: 2rem;
|
|
46
|
+
height: 100%;
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
opacity: 0;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// the fields of DatePicker and of the date range filter: date, time and the box around both halves of a range.
|
|
2
|
+
// focus-within instead of focus, so the same box works on an input and on a wrapper of inputs
|
|
3
|
+
|
|
4
|
+
export const PICKER_BOX_CLASSES = `
|
|
5
|
+
h-[34px] rounded-default border shadow-customLight transition-colors focus-within:ring-[3px]
|
|
6
|
+
bg-lightDatePickerButtonBackground border-lightDatePickerButtonBorder hover:border-lightInputBorderHover
|
|
7
|
+
focus-within:ring-lightInputFocusRing focus-within:border-lightInputFocusBorder
|
|
8
|
+
dark:bg-darkDatePickerButtonBackground dark:border-darkDatePickerButtonBorder dark:hover:border-darkInputBorderHover
|
|
9
|
+
dark:focus-within:ring-darkInputFocusRing dark:focus-within:border-darkInputFocusBorder
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
// the box keeps the focus look while the keyboard is inside its calendar
|
|
13
|
+
export const PICKER_BOX_OPEN_CLASSES = `
|
|
14
|
+
ring-[3px] ring-lightInputFocusRing border-lightInputFocusBorder dark:ring-darkInputFocusRing dark:border-darkInputFocusBorder
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const PICKER_TEXT_CLASSES = `
|
|
18
|
+
text-sm leading-5 tabular-nums focus:outline-none disabled:cursor-not-allowed
|
|
19
|
+
text-lightDatePickerButtonText placeholder-lightDatePickerPlaceHolder
|
|
20
|
+
dark:text-darkDatePickerButtonText dark:placeholder-darkDatePickerPlaceHolder
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const PICKER_ICON_CLASSES = `
|
|
24
|
+
absolute inset-y-0 start-2.5 my-auto w-4 h-4 pointer-events-none text-lightDatePickerIcon dark:text-darkDatePickerIcon
|
|
25
|
+
`;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { inject, type InjectionKey } from 'vue';
|
|
2
2
|
|
|
3
3
|
// AFCL also renders inside a shadow root (the live examples of the docs): popups, modals and tooltips go to an
|
|
4
|
-
// element of that root instead of body, or they lose the styles of the root
|
|
5
|
-
// DatePicker places its calendar relative to it
|
|
4
|
+
// element of that root instead of body, or they lose the styles of the root
|
|
6
5
|
|
|
7
6
|
export const AFCL_TELEPORT_TARGET: InjectionKey<string | HTMLElement> = Symbol('afclTeleportTarget');
|
|
8
7
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
v-else-if="column.foreignResource"
|
|
20
20
|
ref="input"
|
|
21
21
|
:key="`select-${column.name}-${source}-${column.foreignResource?.name || column.foreignResource?.table || ''}`"
|
|
22
|
-
class="w-full min-w-24"
|
|
22
|
+
class="w-full min-w-24 max-w-xs"
|
|
23
23
|
:options="formatSelectOptions(columnOptions[column.name] || [], column)"
|
|
24
24
|
:searchDisabled="!column.foreignResource.searchableFields"
|
|
25
25
|
@scroll-near-end="loadMoreOptions && loadMoreOptions(column.name)"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
<Select
|
|
46
46
|
v-else-if="column.enum"
|
|
47
47
|
ref="input"
|
|
48
|
-
class="w-full min-w-24"
|
|
48
|
+
class="w-full min-w-24 max-w-xs"
|
|
49
49
|
:options="formatSelectOptions(column.enum, column)"
|
|
50
50
|
teleportToBody
|
|
51
51
|
:modelValue="value"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
<Select
|
|
57
57
|
v-else-if="(type || column.type) === 'boolean'"
|
|
58
58
|
ref="input"
|
|
59
|
-
class="w-full min-w-24"
|
|
59
|
+
class="w-full min-w-24 max-w-xs"
|
|
60
60
|
:options="getBooleanOptions(column)"
|
|
61
61
|
teleportToBody
|
|
62
62
|
:modelValue="value"
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
<DatePicker
|
|
84
84
|
v-else-if="['datetime', 'date', 'time'].includes(type || column.type)"
|
|
85
85
|
ref="input"
|
|
86
|
-
:
|
|
87
|
-
:
|
|
86
|
+
:type="type || column.type"
|
|
87
|
+
:modelValue="value"
|
|
88
88
|
auto-hide
|
|
89
|
-
@update:
|
|
89
|
+
@update:modelValue="$emit('update:modelValue', $event)"
|
|
90
90
|
:readonly="(column.editReadonly && source === 'edit') || readonly"
|
|
91
91
|
/>
|
|
92
92
|
<Input
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
/>
|
|
121
121
|
<Textarea
|
|
122
122
|
v-else-if="['text', 'richtext'].includes(type || column.type)"
|
|
123
|
+
class="max-w-2xl"
|
|
123
124
|
:placeholder="$t('Text')"
|
|
124
125
|
:modelValue="value"
|
|
125
126
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
/>
|
|
128
129
|
<Textarea
|
|
129
130
|
v-else-if="['json'].includes(type || column.type)"
|
|
131
|
+
class="max-w-2xl"
|
|
130
132
|
:placeholder="$t('Text')"
|
|
131
133
|
:modelValue="value"
|
|
132
134
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
@@ -135,7 +137,7 @@
|
|
|
135
137
|
v-else
|
|
136
138
|
ref="input"
|
|
137
139
|
:type="!column.masked || unmasked[column.name] ? 'text' : 'password'"
|
|
138
|
-
class="w-full"
|
|
140
|
+
class="w-full max-w-xl"
|
|
139
141
|
:fullWidth="true"
|
|
140
142
|
:placeholder="$t('Text')"
|
|
141
143
|
:prefix="column.inputPrefix"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
/>
|
|
57
57
|
<div v-if="columnsWithErrors && columnsWithErrors[column.name] && validatingMode && !isValidating" class="af-invalid-field-message mt-1 text-xs text-lightInputErrorColor dark:text-darkInputErrorColor">{{ columnsWithErrors[column.name] }}</div>
|
|
58
58
|
<Spinner v-if="shouldWeShowSpinner" class="w-4 mt-1"/>
|
|
59
|
-
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-
|
|
59
|
+
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-lightInputIconColor dark:text-darkInputIconColor">{{ column.editingNote[mode] }}</div>
|
|
60
60
|
</template>
|
|
61
61
|
|
|
62
62
|
<script setup lang="ts">
|
|
@@ -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>
|