adminforth 2.27.0-next.9 → 2.27.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/commands/callTsProxy.js +10 -5
- package/commands/proxy.ts +18 -10
- package/dist/commands/proxy.js +14 -10
- package/dist/commands/proxy.js.map +1 -1
- package/dist/modules/configValidator.d.ts.map +1 -1
- package/dist/modules/configValidator.js +16 -9
- package/dist/modules/configValidator.js.map +1 -1
- package/dist/modules/restApi.d.ts.map +1 -1
- package/dist/modules/restApi.js +37 -2
- package/dist/modules/restApi.js.map +1 -1
- package/dist/modules/styles.js +1 -1
- package/dist/spa/src/App.vue +77 -76
- package/dist/spa/src/afcl/Button.vue +2 -3
- package/dist/spa/src/afcl/Dialog.vue +1 -1
- package/dist/spa/src/afcl/Input.vue +1 -1
- package/dist/spa/src/afcl/Select.vue +6 -2
- package/dist/spa/src/afcl/Spinner.vue +1 -1
- package/dist/spa/src/components/CallActionWrapper.vue +1 -1
- package/dist/spa/src/components/ColumnValueInput.vue +16 -3
- package/dist/spa/src/components/ColumnValueInputWrapper.vue +2 -2
- package/dist/spa/src/components/CustomRangePicker.vue +10 -14
- package/dist/spa/src/components/Filters.vue +95 -63
- package/dist/spa/src/components/GroupsTable.vue +2 -2
- package/dist/spa/src/components/MenuLink.vue +2 -2
- package/dist/spa/src/components/ResourceListTable.vue +13 -7
- package/dist/spa/src/components/ShowTable.vue +1 -1
- package/dist/spa/src/components/Sidebar.vue +2 -2
- package/dist/spa/src/components/ThreeDotsMenu.vue +12 -4
- package/dist/spa/src/spa_types/core.ts +32 -0
- package/dist/spa/src/stores/filters.ts +16 -12
- package/dist/spa/src/types/Back.ts +19 -3
- package/dist/spa/src/types/Common.ts +7 -2
- package/dist/spa/src/utils/utils.ts +35 -3
- package/dist/spa/src/views/ListView.vue +22 -32
- package/dist/spa/src/views/ShowView.vue +66 -24
- package/dist/types/Back.d.ts +19 -14
- package/dist/types/Back.d.ts.map +1 -1
- package/dist/types/Back.js.map +1 -1
- package/dist/types/Common.d.ts +9 -2
- package/dist/types/Common.d.ts.map +1 -1
- package/dist/types/Common.js.map +1 -1
- package/package.json +5 -3
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
ref="input"
|
|
21
21
|
:key="`select-${column.name}-${source}-${column.foreignResource?.name || column.foreignResource?.table || ''}`"
|
|
22
22
|
class="w-full min-w-24"
|
|
23
|
-
:options="columnOptions[column.name] || []"
|
|
23
|
+
:options="formatSelectOptions(columnOptions[column.name] || [], column)"
|
|
24
24
|
:searchDisabled="!column.foreignResource.searchableFields"
|
|
25
25
|
@scroll-near-end="loadMoreOptions && loadMoreOptions(column.name)"
|
|
26
26
|
@search="(searchTerm) => {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
:modelValue="value"
|
|
34
34
|
:readonly="(column.editReadonly && source === 'edit') || readonly"
|
|
35
35
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
36
|
+
disableTogleOfSelectedItem
|
|
36
37
|
>
|
|
37
38
|
<template #extra-item v-if="columnLoadingState && columnLoadingState[column.name]?.loading">
|
|
38
39
|
<div class="text-center text-gray-400 dark:text-gray-300 py-2 flex items-center justify-center gap-2">
|
|
@@ -45,11 +46,12 @@
|
|
|
45
46
|
v-else-if="column.enum"
|
|
46
47
|
ref="input"
|
|
47
48
|
class="w-full min-w-24"
|
|
48
|
-
:options="column.enum"
|
|
49
|
+
:options="formatSelectOptions(column.enum, column)"
|
|
49
50
|
teleportToBody
|
|
50
51
|
:modelValue="value"
|
|
51
52
|
:readonly="(column.editReadonly && source === 'edit') || readonly"
|
|
52
53
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
54
|
+
disableTogleOfSelectedItem
|
|
53
55
|
/>
|
|
54
56
|
<Select
|
|
55
57
|
v-else-if="(type || column.type) === 'boolean'"
|
|
@@ -60,6 +62,7 @@
|
|
|
60
62
|
:modelValue="value"
|
|
61
63
|
:readonly="(column.editReadonly && source === 'edit') || readonly"
|
|
62
64
|
@update:modelValue="$emit('update:modelValue', $event)"
|
|
65
|
+
disableTogleOfSelectedItem
|
|
63
66
|
/>
|
|
64
67
|
<Input
|
|
65
68
|
v-else-if="['integer'].includes(type || column.type)"
|
|
@@ -188,7 +191,7 @@
|
|
|
188
191
|
type?: string,
|
|
189
192
|
value: any,
|
|
190
193
|
currentValues: any,
|
|
191
|
-
mode:
|
|
194
|
+
mode: 'create' | 'edit',
|
|
192
195
|
columnOptions: any,
|
|
193
196
|
unmasked: any,
|
|
194
197
|
deletable?: boolean,
|
|
@@ -218,6 +221,16 @@ const input = ref<HTMLInputElement | null>(null);
|
|
|
218
221
|
return options;
|
|
219
222
|
};
|
|
220
223
|
|
|
224
|
+
const formatSelectOptions = (options: any, column: any) => {
|
|
225
|
+
const optionsToReturn = options;
|
|
226
|
+
if (!column.required[props.mode] && !column.isArray?.enabled) {
|
|
227
|
+
if (!optionsToReturn.some((option: any) => option.value === null)) {
|
|
228
|
+
optionsToReturn.push({ label: t('Unset'), value: null });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return optionsToReturn;
|
|
232
|
+
};
|
|
233
|
+
|
|
221
234
|
function onFocusHandler(event:FocusEvent, column:any, source:string, ) {
|
|
222
235
|
const focusedInput = event.target as HTMLInputElement;
|
|
223
236
|
if(!focusedInput) return;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
@update:inValidity="$emit('update:inValidity', { name: column.name, value: $event })"
|
|
54
54
|
@update:emptiness="$emit('update:emptiness', { name: column.name, value: $event })"
|
|
55
55
|
/>
|
|
56
|
-
<div v-if="columnsWithErrors[column.name] && validatingMode && !isValidating" class="af-invalid-field-message mt-1 text-xs text-lightInputErrorColor dark:text-darkInputErrorColor">{{ columnsWithErrors[column.name] }}</div>
|
|
56
|
+
<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>
|
|
57
57
|
<Spinner v-if="shouldWeShowSpinner" class="w-4 mt-1"/>
|
|
58
58
|
<div v-if="column.editingNote && column.editingNote[mode]" class="mt-1 text-xs text-lightFormFieldTextColor dark:text-darkFormFieldTextColor">{{ column.editingNote[mode] }}</div>
|
|
59
59
|
</template>
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
source: 'create' | 'edit',
|
|
69
69
|
column: any,
|
|
70
70
|
currentValues: any,
|
|
71
|
-
mode:
|
|
71
|
+
mode: 'create' | 'edit',
|
|
72
72
|
columnOptions: any,
|
|
73
73
|
unmasked: any,
|
|
74
74
|
setCurrentValue: Function,
|
|
@@ -35,16 +35,12 @@ import {computed, onMounted, ref, watch} from "vue";
|
|
|
35
35
|
import debounce from 'debounce'
|
|
36
36
|
import RangePicker from './RangePicker.vue';
|
|
37
37
|
|
|
38
|
-
const props = defineProps
|
|
39
|
-
valueStart:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
min: {},
|
|
46
|
-
max: {},
|
|
47
|
-
});
|
|
38
|
+
const props = defineProps<{
|
|
39
|
+
valueStart: number | null,
|
|
40
|
+
valueEnd: number | null,
|
|
41
|
+
min: number,
|
|
42
|
+
max: number,
|
|
43
|
+
}>()
|
|
48
44
|
|
|
49
45
|
const emit = defineEmits(['update:valueStart', 'update:valueEnd']);
|
|
50
46
|
|
|
@@ -52,8 +48,8 @@ const minFormatted = computed(() => Math.floor(<number>props.min));
|
|
|
52
48
|
const maxFormatted = computed(() => Math.ceil(<number>props.max));
|
|
53
49
|
|
|
54
50
|
|
|
55
|
-
const start = ref<
|
|
56
|
-
const end = ref<
|
|
51
|
+
const start = ref<number | null>(props.valueStart);
|
|
52
|
+
const end = ref<number | null>(props.valueEnd);
|
|
57
53
|
|
|
58
54
|
const sliderValue = ref<[number, number]>([minFormatted.value, maxFormatted.value]);
|
|
59
55
|
|
|
@@ -71,8 +67,8 @@ watch([start, end], () => {
|
|
|
71
67
|
|
|
72
68
|
const updateFromSlider =
|
|
73
69
|
debounce((value: [number, number]) => {
|
|
74
|
-
start.value = value[0] === minFormatted.value ?
|
|
75
|
-
end.value = value[1] === maxFormatted.value ?
|
|
70
|
+
start.value = value[0] === minFormatted.value ? null : value[0];
|
|
71
|
+
end.value = value[1] === maxFormatted.value ? null : value[1];
|
|
76
72
|
}, 500);
|
|
77
73
|
|
|
78
74
|
onMounted(() => {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
<div class="py-4 ">
|
|
21
21
|
<ul class="space-y-3 font-medium text-sm">
|
|
22
|
-
<li v-for="c in columnsWithFilter" :key="c">
|
|
22
|
+
<li v-for="c in columnsWithFilter" :key="c.name">
|
|
23
23
|
<div class="flex flex-col">
|
|
24
24
|
<div class="flex justify-between items-center">
|
|
25
25
|
<p class="dark:text-gray-400 my-1">{{ c.label }}</p>
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
<component
|
|
40
40
|
v-if="c.components?.filter"
|
|
41
|
-
:is="getCustomComponent(c.components.filter)"
|
|
42
|
-
:meta="c
|
|
41
|
+
:is="getCustomComponent(formatComponent(c.components.filter))"
|
|
42
|
+
:meta="formatComponent(c.components.filter)?.meta"
|
|
43
43
|
:column="c"
|
|
44
44
|
class="w-full"
|
|
45
|
-
@update:modelValue="(filtersArray) => {
|
|
45
|
+
@update:modelValue="(filtersArray:FilterParams[] ) => {
|
|
46
46
|
filtersStore.filters = filtersStore.filters.filter(f => f.field !== c.name);
|
|
47
47
|
|
|
48
48
|
for (const f of filtersArray) {
|
|
49
|
-
filtersStore.filters.push({ field: c.name
|
|
49
|
+
filtersStore.filters.push({ ...f, field: c.name });
|
|
50
50
|
}
|
|
51
51
|
console.log('filtersStore.filters', filtersStore.filters);
|
|
52
52
|
emits('update:filters', [...filtersStore.filters]);
|
|
@@ -55,18 +55,18 @@
|
|
|
55
55
|
/>
|
|
56
56
|
<Select
|
|
57
57
|
v-else-if="c.foreignResource"
|
|
58
|
-
:multiple="c
|
|
58
|
+
:multiple="c?.filterOptions?.multiselect"
|
|
59
59
|
class="w-full"
|
|
60
60
|
:options="columnOptions[c.name] || []"
|
|
61
61
|
:searchDisabled="!c.foreignResource.searchableFields"
|
|
62
62
|
@scroll-near-end="loadMoreOptions(c.name)"
|
|
63
63
|
@search="(searchTerm) => {
|
|
64
|
-
if (c.foreignResource
|
|
64
|
+
if (c.foreignResource?.searchableFields && onSearchInput[c.name]) {
|
|
65
65
|
onSearchInput[c.name](searchTerm);
|
|
66
66
|
}
|
|
67
67
|
}"
|
|
68
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions
|
|
69
|
-
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions
|
|
68
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ, value: c.filterOptions?.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
69
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ))?.value || (c.filterOptions?.multiselect ? [] : '')"
|
|
70
70
|
>
|
|
71
71
|
<template #extra-item v-if="columnLoadingState[c.name]?.loading">
|
|
72
72
|
<div class="text-center text-gray-400 dark:text-gray-300 py-2 flex items-center justify-center gap-2">
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
</template>
|
|
77
77
|
</Select>
|
|
78
78
|
<Select
|
|
79
|
-
:multiple="c.filterOptions
|
|
79
|
+
:multiple="c.filterOptions?.multiselect"
|
|
80
80
|
class="w-full"
|
|
81
81
|
v-else-if="c.type === 'boolean'"
|
|
82
82
|
:options="[
|
|
@@ -85,63 +85,63 @@
|
|
|
85
85
|
// if field is not required, undefined might be there, and user might want to filter by it
|
|
86
86
|
...(c.required ? [] : [ { label: $t('Unset'), value: undefined } ])
|
|
87
87
|
]"
|
|
88
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions
|
|
89
|
-
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions
|
|
90
|
-
? filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions
|
|
91
|
-
: (c.filterOptions
|
|
88
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ, value: c.filterOptions?.multiselect ? ($event.length ? $event : undefined) : $event })"
|
|
89
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ))?.value !== undefined
|
|
90
|
+
? filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ))?.value
|
|
91
|
+
: (c.filterOptions?.multiselect ? [] : '')"
|
|
92
92
|
/>
|
|
93
93
|
|
|
94
94
|
<Select
|
|
95
|
-
:multiple="c.filterOptions
|
|
95
|
+
:multiple="c.filterOptions?.multiselect"
|
|
96
96
|
class="w-full"
|
|
97
97
|
v-else-if="c.enum"
|
|
98
98
|
:options="c.enum"
|
|
99
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions
|
|
100
|
-
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions
|
|
99
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ, value: c.filterOptions?.multiselect ? ($event.length ? $event : undefined) : $event || undefined })"
|
|
100
|
+
:modelValue="filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions?.multiselect ? AFFO.IN : AFFO.EQ))?.value || (c.filterOptions?.multiselect ? [] : '')"
|
|
101
101
|
/>
|
|
102
102
|
|
|
103
103
|
<Input
|
|
104
|
-
v-else-if="['string', 'text', 'json', 'richtext', 'unknown'].includes(c.type)"
|
|
104
|
+
v-else-if="['string', 'text', 'json', 'richtext', 'unknown'].includes(c.type ?? '')"
|
|
105
105
|
type="text"
|
|
106
106
|
full-width
|
|
107
107
|
:placeholder="$t('Search')"
|
|
108
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.substringSearch ?
|
|
109
|
-
:modelValue="getFilterItem({ column: c, operator: c.filterOptions?.substringSearch ?
|
|
108
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: c.filterOptions?.substringSearch ? AFFO.ILIKE : AFFO.EQ, value: $event || undefined })"
|
|
109
|
+
:modelValue="(getFilterItem({ column: c, operator: c.filterOptions?.substringSearch ? AFFO.ILIKE : AFFO.EQ }) as string | number)"
|
|
110
110
|
/>
|
|
111
111
|
|
|
112
112
|
<CustomDateRangePicker
|
|
113
|
-
v-else-if="['datetime', 'date', 'time'].includes(c.type)"
|
|
113
|
+
v-else-if="['datetime', 'date', 'time'].includes(c.type ?? '')"
|
|
114
114
|
:column="c"
|
|
115
|
-
:valueStart="filtersStore.filters.find(f => f.field === c.name && f.operator ===
|
|
116
|
-
@update:valueStart="onFilterInput[c.name]({ column: c, operator:
|
|
117
|
-
:valueEnd="filtersStore.filters.find(f => f.field === c.name && f.operator ===
|
|
118
|
-
@update:valueEnd="onFilterInput[c.name]({ column: c, operator:
|
|
115
|
+
:valueStart="filtersStore.filters.find(f => f.field === c.name && f.operator === AFFO.GTE)?.value || undefined"
|
|
116
|
+
@update:valueStart="onFilterInput[c.name]({ column: c, operator: AFFO.GTE, value: $event || undefined })"
|
|
117
|
+
:valueEnd="filtersStore.filters.find(f => f.field === c.name && f.operator === AFFO.LTE)?.value || undefined"
|
|
118
|
+
@update:valueEnd="onFilterInput[c.name]({ column: c, operator: AFFO.LTE, value: $event || undefined })"
|
|
119
119
|
/>
|
|
120
120
|
|
|
121
121
|
<CustomRangePicker
|
|
122
|
-
v-else-if="['integer', 'decimal', 'float'].includes(c.type) && c.allowMinMaxQuery"
|
|
122
|
+
v-else-if="['integer', 'decimal', 'float'].includes(c.type ?? '') && c.allowMinMaxQuery"
|
|
123
123
|
:min="getFilterMinValue(c.name)"
|
|
124
124
|
:max="getFilterMaxValue(c.name)"
|
|
125
|
-
:valueStart="getFilterItem({ column: c, operator:
|
|
126
|
-
@update:valueStart="
|
|
127
|
-
:valueEnd="getFilterItem({ column: c, operator:
|
|
128
|
-
@update:valueEnd="
|
|
125
|
+
:valueStart="(getFilterItem({ column: c, operator: AFFO.GTE }) as number)"
|
|
126
|
+
@update:valueStart="(val) => rangeChangeHandler((val !== '' && val !== null) ? (c.type === 'decimal' ? String(val) : val) : undefined, c, AFFO.GTE)"
|
|
127
|
+
:valueEnd="(getFilterItem({ column: c, operator: AFFO.LTE }) as number)"
|
|
128
|
+
@update:valueEnd="(val) => rangeChangeHandler((val !== '' && val !== null) ? (c.type === 'decimal' ? String(val) : val) : undefined, c, AFFO.LTE)"
|
|
129
129
|
/>
|
|
130
130
|
|
|
131
|
-
<div v-else-if="['integer', 'decimal', 'float'].includes(c.type)" class="flex gap-2">
|
|
131
|
+
<div v-else-if="['integer', 'decimal', 'float'].includes(c.type ?? '')" class="flex gap-2">
|
|
132
132
|
<Input
|
|
133
133
|
type="number"
|
|
134
134
|
aria-describedby="helper-text-explanation"
|
|
135
135
|
:placeholder="$t('From')"
|
|
136
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator:
|
|
137
|
-
:modelValue="getFilterItem({ column: c, operator:
|
|
136
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: AFFO.GTE, value: ($event !== '' && $event !== null) ? (c.type === 'decimal' ? String($event) : $event) : undefined })"
|
|
137
|
+
:modelValue="(getFilterItem({ column: c, operator: AFFO.GTE }) as number)"
|
|
138
138
|
/>
|
|
139
139
|
<Input
|
|
140
140
|
type="number"
|
|
141
141
|
aria-describedby="helper-text-explanation"
|
|
142
142
|
:placeholder="$t('To')"
|
|
143
|
-
@update:modelValue="onFilterInput[c.name]({ column: c, operator:
|
|
144
|
-
:modelValue="getFilterItem({ column: c, operator:
|
|
143
|
+
@update:modelValue="onFilterInput[c.name]({ column: c, operator: AFFO.LTE, value: ($event !== '' && $event !== null) ? (c.type === 'decimal' ? String($event) : $event) : undefined })"
|
|
144
|
+
:modelValue="(getFilterItem({ column: c, operator: AFFO.LTE }) as number)"
|
|
145
145
|
/>
|
|
146
146
|
</div>
|
|
147
147
|
</div>
|
|
@@ -164,14 +164,13 @@
|
|
|
164
164
|
</div>
|
|
165
165
|
</template>
|
|
166
166
|
|
|
167
|
-
<script setup>
|
|
167
|
+
<script setup lang="ts">
|
|
168
168
|
import { watch, computed, ref, reactive } from 'vue';
|
|
169
169
|
import { useI18n } from 'vue-i18n';
|
|
170
170
|
import CustomDateRangePicker from '@/components/CustomDateRangePicker.vue';
|
|
171
|
-
import {
|
|
171
|
+
import { loadMoreForeignOptions, searchForeignOptions, createSearchInputHandlers, formatComponent } from '@/utils';
|
|
172
172
|
import { useRouter } from 'vue-router';
|
|
173
173
|
import CustomRangePicker from "@/components/CustomRangePicker.vue";
|
|
174
|
-
import { useFiltersStore } from '@/stores/filters';
|
|
175
174
|
import { getCustomComponent } from '@/utils';
|
|
176
175
|
import Input from '@/afcl/Input.vue';
|
|
177
176
|
import Select from '@/afcl/Select.vue';
|
|
@@ -179,27 +178,39 @@ import Spinner from '@/afcl/Spinner.vue';
|
|
|
179
178
|
import debounce from 'debounce';
|
|
180
179
|
import { Tooltip } from '@/afcl';
|
|
181
180
|
import { IconCloseOutline } from '@iconify-prerendered/vue-flowbite';
|
|
181
|
+
import type { AdminforthFilterStore, AdminforthFilterStoreUnwrapped } from '@/spa_types/core';
|
|
182
|
+
import type { AdminForthResourceColumnCommon, FilterParams, ColumnMinMaxValue } from '@/types/Common';
|
|
183
|
+
import { AdminForthFilterOperators } from '@/types/Common';
|
|
184
|
+
|
|
182
185
|
|
|
183
|
-
const filtersStore = useFiltersStore();
|
|
184
186
|
const { t } = useI18n();
|
|
185
187
|
|
|
188
|
+
const AFFO = AdminForthFilterOperators;
|
|
186
189
|
|
|
187
190
|
// props: columns
|
|
188
191
|
// add support for v-model:filers
|
|
189
|
-
const props = defineProps(['columns', 'filters', 'show', 'columnsMinMax']);
|
|
192
|
+
// const props = defineProps(['columns', 'filters', 'show', 'columnsMinMax']);
|
|
193
|
+
const props = defineProps<{
|
|
194
|
+
columns: AdminForthResourceColumnCommon[],
|
|
195
|
+
filters?: AdminforthFilterStore['filters'],
|
|
196
|
+
show: Boolean,
|
|
197
|
+
columnsMinMax: ColumnMinMaxValue,
|
|
198
|
+
filtersStore: AdminforthFilterStoreUnwrapped
|
|
199
|
+
}>();
|
|
200
|
+
|
|
190
201
|
const emits = defineEmits(['update:filters', 'hide']);
|
|
191
202
|
|
|
192
203
|
const router = useRouter();
|
|
193
204
|
|
|
194
205
|
|
|
195
206
|
const columnsWithFilter = computed(
|
|
196
|
-
() => props.columns?.filter(column => column.showIn
|
|
207
|
+
() => props.columns?.filter(column => column.showIn?.filter) || []
|
|
197
208
|
);
|
|
198
209
|
|
|
199
|
-
const columnOptions = ref({});
|
|
200
|
-
const columnLoadingState = reactive({});
|
|
201
|
-
const columnOffsets = reactive({});
|
|
202
|
-
const columnEmptyResultsCount = reactive({});
|
|
210
|
+
const columnOptions = ref<{[key: string]: Record<string, any>[]}>({});
|
|
211
|
+
const columnLoadingState = reactive<Record<string, { loading: boolean; hasMore: boolean }>>({});
|
|
212
|
+
const columnOffsets = reactive<Record<string, number>>({});
|
|
213
|
+
const columnEmptyResultsCount = reactive<Record<string, number>>({});
|
|
203
214
|
|
|
204
215
|
watch(() => props.columns, async (newColumns) => {
|
|
205
216
|
if (!newColumns) return;
|
|
@@ -219,12 +230,12 @@ watch(() => props.columns, async (newColumns) => {
|
|
|
219
230
|
}, { immediate: true });
|
|
220
231
|
|
|
221
232
|
// Function to load more options for a specific column
|
|
222
|
-
async function loadMoreOptions(columnName, searchTerm = '') {
|
|
233
|
+
async function loadMoreOptions(columnName: string, searchTerm = '') {
|
|
223
234
|
return loadMoreForeignOptions({
|
|
224
235
|
columnName,
|
|
225
236
|
searchTerm,
|
|
226
237
|
columns: props.columns,
|
|
227
|
-
resourceId: router.currentRoute.value.params.resourceId,
|
|
238
|
+
resourceId: router.currentRoute.value.params.resourceId as string,
|
|
228
239
|
columnOptions,
|
|
229
240
|
columnLoadingState,
|
|
230
241
|
columnOffsets,
|
|
@@ -232,12 +243,12 @@ async function loadMoreOptions(columnName, searchTerm = '') {
|
|
|
232
243
|
});
|
|
233
244
|
}
|
|
234
245
|
|
|
235
|
-
async function searchOptions(columnName, searchTerm) {
|
|
246
|
+
async function searchOptions(columnName: string, searchTerm: string) {
|
|
236
247
|
return searchForeignOptions({
|
|
237
248
|
columnName,
|
|
238
249
|
searchTerm,
|
|
239
250
|
columns: props.columns,
|
|
240
|
-
resourceId: router.currentRoute.value.params.resourceId,
|
|
251
|
+
resourceId: router.currentRoute.value.params.resourceId as string,
|
|
241
252
|
columnOptions,
|
|
242
253
|
columnLoadingState,
|
|
243
254
|
columnOffsets,
|
|
@@ -263,9 +274,9 @@ watch(() => props.show, (show) => {
|
|
|
263
274
|
// }
|
|
264
275
|
|
|
265
276
|
const onFilterInput = computed(() => {
|
|
266
|
-
if (!props.columns) return {}
|
|
277
|
+
if (!props.columns) return {} as Record<string, any>;
|
|
267
278
|
|
|
268
|
-
return props.columns.reduce((acc, c) => {
|
|
279
|
+
return props.columns.reduce<Record<string, ReturnType<typeof debounce>>>((acc, c) => {
|
|
269
280
|
return {
|
|
270
281
|
...acc,
|
|
271
282
|
[c.name]: debounce(({ column, operator, value }) => {
|
|
@@ -275,6 +286,27 @@ const onFilterInput = computed(() => {
|
|
|
275
286
|
}, {});
|
|
276
287
|
});
|
|
277
288
|
|
|
289
|
+
// rangeState is used for cutom range picker, because if we change two values very quickly
|
|
290
|
+
// in filters writes only the last one, because of debounce
|
|
291
|
+
const rangeState = reactive<Record<string, { gte: number | null; lte: number | null }>>({});
|
|
292
|
+
|
|
293
|
+
const updateRange = (column: AdminForthResourceColumnCommon) => {
|
|
294
|
+
debounce(() => {
|
|
295
|
+
const { gte, lte } = rangeState[column.name];
|
|
296
|
+
|
|
297
|
+
setFilterItem({ column, operator: AFFO.GTE, value: gte });
|
|
298
|
+
setFilterItem({ column, operator: AFFO.LTE, value: lte });
|
|
299
|
+
}, column?.filterOptions?.debounceTimeMs || 10)();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function rangeChangeHandler(value: number | null, column: AdminForthResourceColumnCommon, operator: 'gte' | 'lte') {
|
|
303
|
+
if (!rangeState[column.name]) {
|
|
304
|
+
rangeState[column.name] = { gte: null, lte: null };
|
|
305
|
+
}
|
|
306
|
+
rangeState[column.name][operator] = value;
|
|
307
|
+
updateRange(column);
|
|
308
|
+
}
|
|
309
|
+
|
|
278
310
|
const onSearchInput = computed(() => {
|
|
279
311
|
return createSearchInputHandlers(
|
|
280
312
|
props.columns,
|
|
@@ -283,40 +315,40 @@ const onSearchInput = computed(() => {
|
|
|
283
315
|
);
|
|
284
316
|
});
|
|
285
317
|
|
|
286
|
-
function setFilterItem({ column, operator, value }) {
|
|
318
|
+
function setFilterItem({ column, operator, value }: { column: AdminForthResourceColumnCommon; operator: AdminForthFilterOperators; value: any }) {
|
|
287
319
|
|
|
288
|
-
const index = filtersStore.filters.findIndex(f => f.field === column.name && f.operator === operator);
|
|
320
|
+
const index = props.filtersStore.filters.findIndex(f => f.field === column.name && f.operator === operator);
|
|
289
321
|
if (value === undefined || value === '' || value === null) {
|
|
290
322
|
if (index !== -1) {
|
|
291
|
-
filtersStore.filters.splice(index, 1);
|
|
323
|
+
props.filtersStore.filters.splice(index, 1);
|
|
292
324
|
}
|
|
293
325
|
} else {
|
|
294
326
|
if (index === -1) {
|
|
295
|
-
filtersStore.setFilter({ field: column.name, value, operator });
|
|
327
|
+
props.filtersStore.setFilter({ field: column.name, value, operator });
|
|
296
328
|
} else {
|
|
297
|
-
filtersStore.setFilters([...filtersStore.filters.slice(0, index), { field: column.name, value, operator }, ...filtersStore.filters.slice(index + 1)])
|
|
329
|
+
props.filtersStore.setFilters([...props.filtersStore.filters.slice(0, index), { field: column.name, value, operator }, ...props.filtersStore.filters.slice(index + 1)])
|
|
298
330
|
}
|
|
299
331
|
}
|
|
300
|
-
emits('update:filters', [...filtersStore.filters]);
|
|
332
|
+
emits('update:filters', [...props.filtersStore.filters]);
|
|
301
333
|
}
|
|
302
334
|
|
|
303
|
-
function getFilterItem({ column, operator }) {
|
|
304
|
-
const filterValue = filtersStore.filters.find(f => f.field === column.name && f.operator === operator)?.value;
|
|
335
|
+
function getFilterItem({ column, operator }: { column: AdminForthResourceColumnCommon; operator: AdminForthFilterOperators }) {
|
|
336
|
+
const filterValue = props.filtersStore.filters.find(f => f.field === column.name && f.operator === operator)?.value;
|
|
305
337
|
return filterValue !== undefined ? filterValue : '';
|
|
306
338
|
}
|
|
307
339
|
|
|
308
340
|
async function clear() {
|
|
309
|
-
filtersStore.filters = [...filtersStore.filters.filter(f => filtersStore.shouldFilterBeHidden(f.field))];
|
|
310
|
-
emits('update:filters', [...filtersStore.filters]);
|
|
341
|
+
props.filtersStore.filters = [...props.filtersStore.filters.filter(f => props.filtersStore.shouldFilterBeHidden(f.field))];
|
|
342
|
+
emits('update:filters', [...props.filtersStore.filters]);
|
|
311
343
|
}
|
|
312
344
|
|
|
313
|
-
function getFilterMinValue(columnName) {
|
|
345
|
+
function getFilterMinValue(columnName: string) {
|
|
314
346
|
if(props.columnsMinMax && props.columnsMinMax[columnName]) {
|
|
315
347
|
return props.columnsMinMax[columnName]?.min
|
|
316
348
|
}
|
|
317
349
|
}
|
|
318
350
|
|
|
319
|
-
function getFilterMaxValue(columnName) {
|
|
351
|
+
function getFilterMaxValue(columnName: string) {
|
|
320
352
|
if(props.columnsMinMax && props.columnsMinMax[columnName]) {
|
|
321
353
|
return props.columnsMinMax[columnName]?.max
|
|
322
354
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="rounded-lg shadow-resourseFormShadow dark:shadow-darkResourseFormShadow dark:shadow-2xl">
|
|
2
|
+
<div class="rounded-lg shadow-resourseFormShadow dark:shadow-darkResourseFormShadow dark:shadow-2xl border dark:border-darkFormBorder">
|
|
3
3
|
<div v-if="group.groupName && !group.noTitle" class="text-md font-semibold px-6 py-3 flex flex-1 items-center dark:border-darkFormBorder text-lightListTableHeadingText bg-lightFormHeading dark:bg-darkFormHeading dark:text-darkListTableHeadingText rounded-t-lg">
|
|
4
4
|
{{ group.groupName }}
|
|
5
5
|
</div>
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
const props = defineProps<{
|
|
81
81
|
source: 'create' | 'edit',
|
|
82
82
|
group: any,
|
|
83
|
-
mode:
|
|
83
|
+
mode: 'create' | 'edit',
|
|
84
84
|
validatingMode: boolean,
|
|
85
85
|
currentValues: any,
|
|
86
86
|
unmasked: any,
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
>
|
|
36
36
|
{{ item.label }}
|
|
37
37
|
</div>
|
|
38
|
-
<span class="absolute flex items-center justify-center right-1 top-1/2 -translate-y-1/2" v-if="item.badge && showExpandedBadge">
|
|
38
|
+
<span class="absolute flex items-center justify-center right-1 top-1/2 -translate-y-1/2" v-if="(item.badge || item.badge === 0) && showExpandedBadge ">
|
|
39
39
|
<Tooltip v-if="item.badgeTooltip">
|
|
40
40
|
<div class="af-badge inline-flex items-center justify-center h-3 py-2.5 px-1 ms-3 text-xs font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
41
41
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent min-w-[1.5rem] max-w-[3rem]">{{ item.badge }}</div>
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent min-w-[1.5rem] max-w-[3rem]">{{ item.badge }}</div>
|
|
49
49
|
</template>
|
|
50
50
|
</span>
|
|
51
|
-
<div v-if="item.badge && isSidebarIconOnly && !isSidebarHovering" class="af-badge absolute right-0.5 bottom-1 -translate-y-1/2 inline-flex items-center justify-center h-2 w-2 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
51
|
+
<div v-if="(item.badge || item.badge === 0) && isSidebarIconOnly && !isSidebarHovering" class="af-badge absolute right-0.5 bottom-1 -translate-y-1/2 inline-flex items-center justify-center h-2 w-2 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
52
52
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
|
|
53
53
|
</div>
|
|
54
54
|
</RouterLink>
|
|
@@ -211,12 +211,18 @@
|
|
|
211
211
|
<button
|
|
212
212
|
type="button"
|
|
213
213
|
class="border border-gray-300 dark:border-gray-700 dark:border-opacity-0 border-opacity-0 hover:border-opacity-100 dark:hover:border-opacity-100 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer"
|
|
214
|
+
:disabled="!!actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]"
|
|
214
215
|
>
|
|
215
216
|
<component
|
|
216
|
-
v-if="action.icon"
|
|
217
|
+
v-if="action.icon && !actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]"
|
|
217
218
|
:is="getIcon(action.icon)"
|
|
218
219
|
class="w-6 h-6 text-lightPrimary dark:text-darkPrimary"
|
|
219
220
|
/>
|
|
221
|
+
<Spinner
|
|
222
|
+
v-if="actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]"
|
|
223
|
+
class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
|
|
224
|
+
/>
|
|
225
|
+
<span v-if="actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]" class="sr-only">Loading...</span>
|
|
220
226
|
</button>
|
|
221
227
|
</component>
|
|
222
228
|
|
|
@@ -356,7 +362,7 @@ import {
|
|
|
356
362
|
IconInboxOutline
|
|
357
363
|
} from '@iconify-prerendered/vue-flowbite';
|
|
358
364
|
import router from '@/router';
|
|
359
|
-
import { Tooltip } from '@/afcl';
|
|
365
|
+
import { Tooltip, Spinner } from '@/afcl';
|
|
360
366
|
import type { AdminForthResourceCommon, AdminForthResourceColumnCommon, AdminForthComponentDeclarationFull, AdminForthComponentDeclaration } from '@/types/Common';
|
|
361
367
|
import { useAdminforth } from '@/adminforth';
|
|
362
368
|
import Checkbox from '@/afcl/Checkbox.vue';
|
|
@@ -613,7 +619,7 @@ async function startCustomAction(actionId: string | number, row: any, extraData:
|
|
|
613
619
|
recordId: row._primaryKeyValue,
|
|
614
620
|
extra: extraData,
|
|
615
621
|
setLoadingState: (loading: boolean) => {
|
|
616
|
-
actionLoadingStates.value[actionId] = loading;
|
|
622
|
+
actionLoadingStates.value[`${actionId}_${row._primaryKeyValue}`] = loading;
|
|
617
623
|
},
|
|
618
624
|
onSuccess: async (data: any) => {
|
|
619
625
|
emits('update:records', true);
|
|
@@ -638,10 +644,10 @@ function validatePageInput() {
|
|
|
638
644
|
pageInput.value = validPage.toString();
|
|
639
645
|
}
|
|
640
646
|
/*
|
|
641
|
-
*___________________________________________________________________
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
647
|
+
* ___________________________________________________________________
|
|
648
|
+
*| |
|
|
649
|
+
*| Virtual Scroll Implementation |
|
|
650
|
+
*|___________________________________________________________________|
|
|
645
651
|
*/
|
|
646
652
|
// Add throttle utility
|
|
647
653
|
const throttle = (fn: Function, delay: number) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow"
|
|
2
|
+
<div class="overflow-x-auto shadow-resourseFormShadow dark:shadow-darkResourseFormShadow border dark:border-gray-700"
|
|
3
3
|
:class="{'rounded-default' : isRounded}"
|
|
4
4
|
>
|
|
5
5
|
<div v-if="groupName && !noTitle" class="text-md font-semibold px-6 py-3 flex flex-1 items-center text-lightShowTableHeadingText bg-lightShowTableHeadingBackground dark:bg-darkShowTableHeadingBackground dark:text-darkShowTableHeadingText rounded-t-lg">
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
>
|
|
72
72
|
<component v-if="item.icon" :is="getIcon(item.icon)" class="w-5 h-5 text-lightSidebarIcons group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
|
|
73
73
|
<span class="overflow-hidden flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">{{ item.label }}
|
|
74
|
-
<span v-if="item.badge" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
74
|
+
<span v-if="item.badge || item.badge === 0" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
75
75
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
|
|
76
76
|
<Tooltip v-if="item.badgeTooltip">
|
|
77
77
|
{{ item.badge }}
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
} : {}"
|
|
130
130
|
>{{ item.label }}
|
|
131
131
|
|
|
132
|
-
<span v-if="item.badge" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
132
|
+
<span v-if="item.badge || item.badge === 0" class="inline-flex items-center justify-center w-3 h-3 p-3 ms-3 text-sm font-medium rounded-full bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
133
133
|
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent">
|
|
134
134
|
<Tooltip v-if="item.badgeTooltip">
|
|
135
135
|
{{ item.badge }}
|
|
@@ -51,12 +51,16 @@
|
|
|
51
51
|
@callAction="(payload? : Object) => handleActionClick(action, payload)"
|
|
52
52
|
>
|
|
53
53
|
<a @click.prevent class="block">
|
|
54
|
-
<div class="flex items-center gap-2">
|
|
54
|
+
<div class="flex items-center gap-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover">
|
|
55
55
|
<component
|
|
56
|
-
v-if="action.icon"
|
|
56
|
+
v-if="action.icon && !actionLoadingStates[action.id!]"
|
|
57
57
|
:is="getIcon(action.icon)"
|
|
58
58
|
class="w-4 h-4 text-lightPrimary dark:text-darkPrimary"
|
|
59
59
|
/>
|
|
60
|
+
<Spinner
|
|
61
|
+
v-if="actionLoadingStates[action.id!]"
|
|
62
|
+
class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
|
|
63
|
+
/>
|
|
60
64
|
{{ action.name }}
|
|
61
65
|
</div>
|
|
62
66
|
</a>
|
|
@@ -91,12 +95,12 @@
|
|
|
91
95
|
import { getCustomComponent, getIcon, formatComponent, executeCustomAction } from '@/utils';
|
|
92
96
|
import { useCoreStore } from '@/stores/core';
|
|
93
97
|
import { useAdminforth } from '@/adminforth';
|
|
94
|
-
import { callAdminForthApi } from '@/utils';
|
|
95
98
|
import { useRoute, useRouter } from 'vue-router';
|
|
96
99
|
import CallActionWrapper from '@/components/CallActionWrapper.vue'
|
|
97
100
|
import { ref, type ComponentPublicInstance, onMounted, onUnmounted } from 'vue';
|
|
98
101
|
import type { AdminForthActionFront, AdminForthBulkActionFront, AdminForthComponentDeclarationFull } from '@/types/Common';
|
|
99
102
|
import type { AdminForthActionInput } from '@/types/Back';
|
|
103
|
+
import { Spinner } from '@/afcl';
|
|
100
104
|
|
|
101
105
|
const { list, alert} = useAdminforth();
|
|
102
106
|
const route = useRoute();
|
|
@@ -104,6 +108,7 @@ const coreStore = useCoreStore();
|
|
|
104
108
|
const router = useRouter();
|
|
105
109
|
const threeDotsDropdownItemsRefs = ref<Array<ComponentPublicInstance | null>>([]);
|
|
106
110
|
const showDropdown = ref(false);
|
|
111
|
+
const actionLoadingStates = ref<Record<string, boolean>>({});
|
|
107
112
|
const dropdownRef = ref<HTMLElement | null>(null);
|
|
108
113
|
const buttonTriggerRef = ref<HTMLElement | null>(null);
|
|
109
114
|
|
|
@@ -135,6 +140,9 @@ async function handleActionClick(action: AdminForthActionInput, payload: any) {
|
|
|
135
140
|
resourceId: route.params.resourceId as string,
|
|
136
141
|
recordId: route.params.primaryKey as string,
|
|
137
142
|
extra: payload || {},
|
|
143
|
+
setLoadingState: (loading: boolean) => {
|
|
144
|
+
actionLoadingStates.value[action.id!] = loading;
|
|
145
|
+
},
|
|
138
146
|
onSuccess: async (data: any) => {
|
|
139
147
|
await coreStore.fetchRecord({
|
|
140
148
|
resourceId: route.params.resourceId as string,
|
|
@@ -195,7 +203,7 @@ onUnmounted(() => {
|
|
|
195
203
|
</script>
|
|
196
204
|
|
|
197
205
|
<style lang="scss" scoped>
|
|
198
|
-
.wrapper
|
|
206
|
+
.wrapper {
|
|
199
207
|
@apply px-4 py-2
|
|
200
208
|
hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover
|
|
201
209
|
dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover
|