adminforth 2.27.0-test.1 → 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.
Files changed (37) hide show
  1. package/commands/callTsProxy.js +3 -3
  2. package/dist/dataConnectors/baseConnector.d.ts.map +1 -1
  3. package/dist/dataConnectors/baseConnector.js +1 -8
  4. package/dist/dataConnectors/baseConnector.js.map +1 -1
  5. package/dist/dataConnectors/clickhouse.js +1 -1
  6. package/dist/dataConnectors/clickhouse.js.map +1 -1
  7. package/dist/dataConnectors/mysql.js +1 -1
  8. package/dist/dataConnectors/mysql.js.map +1 -1
  9. package/dist/dataConnectors/sqlite.d.ts.map +1 -1
  10. package/dist/dataConnectors/sqlite.js +0 -2
  11. package/dist/dataConnectors/sqlite.js.map +1 -1
  12. package/dist/spa/src/App.vue +77 -76
  13. package/dist/spa/src/afcl/Button.vue +2 -3
  14. package/dist/spa/src/afcl/Dialog.vue +1 -1
  15. package/dist/spa/src/afcl/Input.vue +1 -1
  16. package/dist/spa/src/afcl/Select.vue +1 -1
  17. package/dist/spa/src/afcl/Spinner.vue +1 -1
  18. package/dist/spa/src/components/ColumnValueInputWrapper.vue +1 -1
  19. package/dist/spa/src/components/CustomRangePicker.vue +10 -14
  20. package/dist/spa/src/components/Filters.vue +79 -68
  21. package/dist/spa/src/components/MenuLink.vue +2 -2
  22. package/dist/spa/src/components/ResourceListTable.vue +8 -15
  23. package/dist/spa/src/components/Sidebar.vue +2 -2
  24. package/dist/spa/src/components/ThreeDotsMenu.vue +6 -15
  25. package/dist/spa/src/spa_types/core.ts +32 -0
  26. package/dist/spa/src/stores/filters.ts +16 -12
  27. package/dist/spa/src/types/Back.ts +3 -2
  28. package/dist/spa/src/types/Common.ts +5 -1
  29. package/dist/spa/src/views/ListView.vue +13 -30
  30. package/dist/spa/src/views/ShowView.vue +10 -18
  31. package/dist/spa/tsconfig.app.json +0 -1
  32. package/dist/types/Back.d.ts +3 -13
  33. package/dist/types/Back.d.ts.map +1 -1
  34. package/dist/types/Back.js.map +1 -1
  35. package/dist/types/Common.d.ts +7 -1
  36. package/dist/types/Common.d.ts.map +1 -1
  37. package/package.json +3 -2
@@ -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?.components?.list?.meta"
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, ...f });
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.filterOptions.multiselect"
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.searchableFields && onSearchInput[c.name]) {
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.multiselect ? 'in' : '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 ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
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.multiselect"
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.multiselect ? 'in' : '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 ? 'in' : 'eq'))?.value !== undefined
90
- ? filtersStore.filters.find(f => f.field === c.name && f.operator === (c.filterOptions.multiselect ? 'in' : 'eq'))?.value
91
- : (c.filterOptions.multiselect ? [] : '')"
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.multiselect"
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.multiselect ? 'in' : '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 ? 'in' : 'eq'))?.value || (c.filterOptions.multiselect ? [] : '')"
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 ? 'ilike' : 'eq', value: $event || undefined })"
109
- :modelValue="getFilterItem({ column: c, operator: c.filterOptions?.substringSearch ? 'ilike' : 'eq' })"
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 === 'gte')?.value || undefined"
116
- @update:valueStart="onFilterInput[c.name]({ column: c, operator: 'gte', value: $event || undefined })"
117
- :valueEnd="filtersStore.filters.find(f => f.field === c.name && f.operator === 'lte')?.value || undefined"
118
- @update:valueEnd="onFilterInput[c.name]({ column: c, operator: 'lte', value: $event || undefined })"
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: 'gte' })"
126
- @update:valueStart="(val) => rangeChangeHandler((val !== '' && val !== null) ? (c.type === 'decimal' ? String(val) : val) : undefined, c, 'gte')"
127
- :valueEnd="getFilterItem({ column: c, operator: 'lte' })"
128
- @update:valueEnd="(val) => rangeChangeHandler((val !== '' && val !== null) ? (c.type === 'decimal' ? String(val) : val) : undefined, c, 'lte')"
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: 'gte', value: ($event !== '' && $event !== null) ? (c.type === 'decimal' ? String($event) : $event) : undefined })"
137
- :modelValue="getFilterItem({ column: c, operator: 'gte' })"
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: 'lte', value: ($event !== '' && $event !== null) ? (c.type === 'decimal' ? String($event) : $event) : undefined })"
144
- :modelValue="getFilterItem({ column: c, operator: 'lte' })"
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 { callAdminForthApi, loadMoreForeignOptions, searchForeignOptions, createSearchInputHandlers } from '@/utils';
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.filter) || []
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 }) => {
@@ -277,18 +288,18 @@ const onFilterInput = computed(() => {
277
288
 
278
289
  // rangeState is used for cutom range picker, because if we change two values very quickly
279
290
  // in filters writes only the last one, because of debounce
280
- const rangeState = reactive({});
291
+ const rangeState = reactive<Record<string, { gte: number | null; lte: number | null }>>({});
281
292
 
282
- const updateRange = (column) => {
293
+ const updateRange = (column: AdminForthResourceColumnCommon) => {
283
294
  debounce(() => {
284
295
  const { gte, lte } = rangeState[column.name];
285
296
 
286
- setFilterItem({ column, operator: 'gte', value: gte });
287
- setFilterItem({ column, operator: 'lte', value: lte });
297
+ setFilterItem({ column, operator: AFFO.GTE, value: gte });
298
+ setFilterItem({ column, operator: AFFO.LTE, value: lte });
288
299
  }, column?.filterOptions?.debounceTimeMs || 10)();
289
300
  }
290
301
 
291
- function rangeChangeHandler(value, column, operator) {
302
+ function rangeChangeHandler(value: number | null, column: AdminForthResourceColumnCommon, operator: 'gte' | 'lte') {
292
303
  if (!rangeState[column.name]) {
293
304
  rangeState[column.name] = { gte: null, lte: null };
294
305
  }
@@ -304,40 +315,40 @@ const onSearchInput = computed(() => {
304
315
  );
305
316
  });
306
317
 
307
- function setFilterItem({ column, operator, value }) {
318
+ function setFilterItem({ column, operator, value }: { column: AdminForthResourceColumnCommon; operator: AdminForthFilterOperators; value: any }) {
308
319
 
309
- 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);
310
321
  if (value === undefined || value === '' || value === null) {
311
322
  if (index !== -1) {
312
- filtersStore.filters.splice(index, 1);
323
+ props.filtersStore.filters.splice(index, 1);
313
324
  }
314
325
  } else {
315
326
  if (index === -1) {
316
- filtersStore.setFilter({ field: column.name, value, operator });
327
+ props.filtersStore.setFilter({ field: column.name, value, operator });
317
328
  } else {
318
- 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)])
319
330
  }
320
331
  }
321
- emits('update:filters', [...filtersStore.filters]);
332
+ emits('update:filters', [...props.filtersStore.filters]);
322
333
  }
323
334
 
324
- function getFilterItem({ column, operator }) {
325
- 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;
326
337
  return filterValue !== undefined ? filterValue : '';
327
338
  }
328
339
 
329
340
  async function clear() {
330
- filtersStore.filters = [...filtersStore.filters.filter(f => filtersStore.shouldFilterBeHidden(f.field))];
331
- 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]);
332
343
  }
333
344
 
334
- function getFilterMinValue(columnName) {
345
+ function getFilterMinValue(columnName: string) {
335
346
  if(props.columnsMinMax && props.columnsMinMax[columnName]) {
336
347
  return props.columnsMinMax[columnName]?.min
337
348
  }
338
349
  }
339
350
 
340
- function getFilterMaxValue(columnName) {
351
+ function getFilterMaxValue(columnName: string) {
341
352
  if(props.columnsMinMax && props.columnsMinMax[columnName]) {
342
353
  return props.columnsMinMax[columnName]?.max
343
354
  }
@@ -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>
@@ -218,17 +218,10 @@
218
218
  :is="getIcon(action.icon)"
219
219
  class="w-6 h-6 text-lightPrimary dark:text-darkPrimary"
220
220
  />
221
- <svg
221
+ <Spinner
222
222
  v-if="actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]"
223
- aria-hidden="true"
224
- class="w-6 h-6 p-1 animate-spin text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
225
- viewBox="0 0 100 101"
226
- fill="none"
227
- xmlns="http://www.w3.org/2000/svg"
228
- >
229
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
230
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
231
- </svg>
223
+ class="w-5 h-5 text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
224
+ />
232
225
  <span v-if="actionLoadingStates[`${action.id}_${row._primaryKeyValue}`]" class="sr-only">Loading...</span>
233
226
  </button>
234
227
  </component>
@@ -369,7 +362,7 @@ import {
369
362
  IconInboxOutline
370
363
  } from '@iconify-prerendered/vue-flowbite';
371
364
  import router from '@/router';
372
- import { Tooltip } from '@/afcl';
365
+ import { Tooltip, Spinner } from '@/afcl';
373
366
  import type { AdminForthResourceCommon, AdminForthResourceColumnCommon, AdminForthComponentDeclarationFull, AdminForthComponentDeclaration } from '@/types/Common';
374
367
  import { useAdminforth } from '@/adminforth';
375
368
  import Checkbox from '@/afcl/Checkbox.vue';
@@ -651,10 +644,10 @@ function validatePageInput() {
651
644
  pageInput.value = validPage.toString();
652
645
  }
653
646
  /*
654
- *___________________________________________________________________
655
- * |
656
- * Virtual Scroll Implementation |
657
- *___________________________________________________________________|
647
+ * ___________________________________________________________________
648
+ *| |
649
+ *| Virtual Scroll Implementation |
650
+ *|___________________________________________________________________|
658
651
  */
659
652
  // Add throttle utility
660
653
  const throttle = (fn: Function, delay: number) => {
@@ -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,25 +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 px-4 py-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover">
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
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
- <div v-if="actionLoadingStates[action.id!]">
61
- <svg
62
- aria-hidden="true"
63
- class="w-4 h-4 animate-spin text-gray-200 dark:text-gray-500 fill-gray-500 dark:fill-gray-300"
64
- viewBox="0 0 100 101"
65
- fill="none"
66
- xmlns="http://www.w3.org/2000/svg"
67
- >
68
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
69
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
70
- </svg>
71
- <span class="sr-only">Loading...</span>
72
- </div>
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
+ />
73
64
  {{ action.name }}
74
65
  </div>
75
66
  </a>
@@ -104,12 +95,12 @@
104
95
  import { getCustomComponent, getIcon, formatComponent, executeCustomAction } from '@/utils';
105
96
  import { useCoreStore } from '@/stores/core';
106
97
  import { useAdminforth } from '@/adminforth';
107
- import { callAdminForthApi } from '@/utils';
108
98
  import { useRoute, useRouter } from 'vue-router';
109
99
  import CallActionWrapper from '@/components/CallActionWrapper.vue'
110
100
  import { ref, type ComponentPublicInstance, onMounted, onUnmounted } from 'vue';
111
101
  import type { AdminForthActionFront, AdminForthBulkActionFront, AdminForthComponentDeclarationFull } from '@/types/Common';
112
102
  import type { AdminForthActionInput } from '@/types/Back';
103
+ import { Spinner } from '@/afcl';
113
104
 
114
105
  const { list, alert} = useAdminforth();
115
106
  const route = useRoute();
@@ -1,4 +1,6 @@
1
1
  import type { AdminForthResource, AdminForthResourceColumn } from '../types/Back.js';
2
+ import type { FilterParams } from '@/types/Common';
3
+ import type { Ref, ComputedRef } from 'vue';
2
4
 
3
5
  export type resourceById = {
4
6
  [key: string]: AdminForthResource;
@@ -61,3 +63,33 @@ export type AllowedActions = {
61
63
  delete: boolean,
62
64
  }
63
65
 
66
+
67
+ export type sortType = {
68
+ field: string,
69
+ direction: 'ask' | 'desc'
70
+ } | null;
71
+
72
+ export type AdminforthFilterStore = {
73
+ filters: Ref<FilterParams[]>,
74
+
75
+ setSort: (sort: sortType) => void,
76
+ getSort: () => sortType,
77
+
78
+ setFilter: (filters: FilterParams) => void,
79
+ setFilters: (filters: FilterParams[]) => void,
80
+
81
+ getFilters: () => FilterParams[],
82
+
83
+ clearFilter: (fieldName: string) => void,
84
+ clearFilters: () => void,
85
+
86
+ shouldFilterBeHidden: (fieldName: string) => boolean,
87
+
88
+ visibleFiltersCount: ComputedRef<number>,
89
+ }
90
+
91
+ export interface AdminforthFilterStoreUnwrapped extends Omit<AdminforthFilterStore, 'filters' | 'visibleFiltersCount'> {
92
+ filters: FilterParams[],
93
+ visibleFiltersCount: number,
94
+ }
95
+
@@ -1,40 +1,42 @@
1
1
  import { ref, computed, type Ref } from 'vue';
2
2
  import { defineStore } from 'pinia';
3
3
  import { useCoreStore } from './core';
4
+ import type { FilterParams } from '@/types/Common';
5
+ import type { AdminforthFilterStore, sortType } from '../spa_types/core';
4
6
 
5
7
  export const useFiltersStore = defineStore('filters', () => {
6
- const filters: Ref<any[]> = ref([]);
7
- const sort: Ref<any> = ref({});
8
+ const filters: Ref<FilterParams[]> = ref([]);
9
+ const sort: Ref<sortType> = ref(null);
8
10
  const coreStore = useCoreStore();
9
11
 
10
- const setSort = (s: any) => {
12
+ const setSort = (s: sortType): void => {
11
13
  sort.value = s;
12
14
  }
13
- const getSort = () => {
15
+ const getSort = (): sortType => {
14
16
  return sort.value;
15
17
  }
16
- const setFilter = (filter: any) => {
18
+ const setFilter = (filter: FilterParams) => {
17
19
  const index = filters.value.findIndex(f => f.field === filter.field);
18
- if (filters.value[index] && filters.value[index].operator === filter.value.operator) {
20
+ if (filters.value[index] && filters.value[index].operator === filter.operator) {
19
21
  filters.value[index] = filter;
20
22
  return;
21
23
  }
22
24
  filters.value.push(filter);
23
25
  }
24
- const setFilters = (f: any) => {
26
+ const setFilters = (f: FilterParams[]) => {
25
27
  filters.value = f;
26
28
  }
27
- const getFilters = () => {
29
+ const getFilters = (): FilterParams[] => {
28
30
  return filters.value;
29
31
  }
30
- const clearFilter = (fieldName: string) => {
32
+ const clearFilter = (fieldName: string): void => {
31
33
  filters.value = filters.value.filter(f => f.field !== fieldName);
32
34
  }
33
- const clearFilters = () => {
35
+ const clearFilters = (): void => {
34
36
  filters.value = [];
35
37
  }
36
38
 
37
- const shouldFilterBeHidden = (fieldName: string) => {
39
+ const shouldFilterBeHidden = (fieldName: string): boolean => {
38
40
  if (coreStore.resource?.columns) {
39
41
  const column = coreStore.resource.columns.find((col: any) => col.name === fieldName);
40
42
  if (column?.showIn?.filter !== true) {
@@ -48,7 +50,7 @@ export const useFiltersStore = defineStore('filters', () => {
48
50
  return filters.value.filter(f => !shouldFilterBeHidden(f.field)).length;
49
51
  });
50
52
 
51
- return {
53
+ const store = {
52
54
  setFilter,
53
55
  getFilters,
54
56
  clearFilters,
@@ -60,4 +62,6 @@ export const useFiltersStore = defineStore('filters', () => {
60
62
  shouldFilterBeHidden,
61
63
  clearFilter
62
64
  }
65
+
66
+ return store as AdminforthFilterStore;
63
67
  })
@@ -13,6 +13,7 @@ import { ActionCheckSource, AdminForthFilterOperators, AdminForthSortDirections,
13
13
  type AdminForthConfigMenuItem,
14
14
  type AnnouncementBadgeResponse,
15
15
  type AdminForthResourceColumnInputCommon,
16
+ type ColumnMinMaxValue,
16
17
  } from './Common.js';
17
18
 
18
19
  export interface ICodeInjector {
@@ -256,7 +257,7 @@ export interface IAdminForthDataSourceConnector {
256
257
  *
257
258
  * Internally should call {@link IAdminForthDataSourceConnector.getFieldValue} for both min and max values.
258
259
  */
259
- getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
260
+ getMinMaxForColumnsWithOriginalTypes({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
260
261
 
261
262
 
262
263
  /**
@@ -309,7 +310,7 @@ export interface IAdminForthDataSourceConnectorBase extends IAdminForthDataSourc
309
310
  newValues: any,
310
311
  }): Promise<{ok: boolean, error?: string}>;
311
312
 
312
- getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<{ [key: string]: { min: any, max: any } }>;
313
+ getMinMaxForColumns({ resource, columns }: { resource: AdminForthResource, columns: AdminForthResourceColumn[] }): Promise<ColumnMinMaxValue>;
313
314
 
314
315
  deleteMany?({resource, recordIds}:{resource: AdminForthResource, recordIds: any[]}): Promise<number>;
315
316
  }
@@ -1164,7 +1164,7 @@ export interface AdminForthConfigMenuItem {
1164
1164
  * Optional callback which will be called before rendering the menu for each item.
1165
1165
  * Result of callback if not null will be used as a small badge near the menu item.
1166
1166
  */
1167
- badge?: string | ((user: AdminUser) => Promise<string>),
1167
+ badge?: string | number | ((user: AdminUser) => Promise<string> | string | Promise<number> | number),
1168
1168
 
1169
1169
  /**
1170
1170
  * Tooltip shown on hover for badge
@@ -1257,4 +1257,8 @@ export interface GetBaseConfigResponse {
1257
1257
  config: AdminForthConfigForFrontend,
1258
1258
  adminUser: AdminUser,
1259
1259
  version: string,
1260
+ }
1261
+
1262
+ export interface ColumnMinMaxValue {
1263
+ [key: string]: { min: any, max: any }
1260
1264
  }