@opengis/fastify-table 1.4.59 → 1.4.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.4.59",
3
+ "version": "1.4.61",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -59,4 +59,4 @@
59
59
  },
60
60
  "author": "Softpro",
61
61
  "license": "ISC"
62
- }
62
+ }
@@ -38,9 +38,10 @@ function formatDateISOString(date) {
38
38
 
39
39
  function getRangeValues(value = '', filterType = 'range') {
40
40
  if (['range'].includes(filterType)) {
41
- return value?.indexOf('_') !== -1
42
- ? value.split('_')
43
- : value.split('-');
41
+ if (value?.includes(',')) return value.split(',').map((el) => el || 'min');
42
+ if (value?.includes('_')) return value.split('_');
43
+
44
+ return value.split('-');
44
45
  }
45
46
 
46
47
  // date range, specific options: current day, week, month, year etc.
@@ -61,14 +62,14 @@ function getRangeValues(value = '', filterType = 'range') {
61
62
  }
62
63
 
63
64
  // date range, example: 01.01.2024-31.12.2024
64
- const [startDate, endDate] = value.split('-');
65
+ const [startDate, endDate = 'max'] = value?.includes(',') ? value.split(',').map((el) => el || 'min') : value.split('-');
65
66
  const min = startDate === 'min' ? startDate : formatDateISOString(startDate);
66
67
  const max = endDate === 'max' ? endDate : formatDateISOString(endDate);
67
68
  return [min, max];
68
69
  }
69
70
 
70
71
  function checkValid(value, fieldType, filterType, sql, extra) {
71
- const [min, max] = getRangeValues(value, filterType);
72
+ const [min, max = 'max'] = getRangeValues(value, filterType);
72
73
 
73
74
  if (['date', 'datepicker'].includes(filterType)) {
74
75
  const isvalid = (dateTypeList.includes(fieldType) || sql || extra) && (isValidDate(min) && (isValidDate(max) || value === 'cd'));
@@ -54,10 +54,10 @@ export default async function filterAPI(req, reply, iscalled) {
54
54
 
55
55
  filters?.forEach?.(el => Object.assign(el, { id: el.id || el.name, title: el.title || el.ua, extra: extraColumns.includes(el.id || el.name) }));
56
56
 
57
- await Promise.all(filters.filter((el) => el.data && el.id && el.type !== 'Autocomplete' && !el.sql).map(async (el) => {
58
- const cls = await getSelect(el.data, pg);
57
+ await Promise.all(filters.filter((el) => el.id && el.type !== 'Autocomplete' && !el.sql).map(async (el) => {
58
+ const cls = el.data ? await getSelect(el.data, pg) : null;
59
59
 
60
- if (!cls) return;
60
+ if (!cls && !el.type?.includes?.('Check')) return;
61
61
  const { dataTypeID } = columns.find((item) => item.name === el.id) || {};
62
62
 
63
63
  if (el.extra && Array.isArray(cls?.arr || cls)) {
@@ -87,7 +87,7 @@ export default async function filterAPI(req, reply, iscalled) {
87
87
  const clsData = await getSelectVal({ pg, values: ids, name: el.data });
88
88
 
89
89
  const options = countArr.rows.map(cel => {
90
- const data = cls?.arr?.find(c => c.id?.toString?.() === cel.id?.toString?.()) || { text: clsData[cel.id]?.text || clsData[cel.id] };
90
+ const data = cls?.arr?.find?.(c => c.id?.toString?.() === cel.id?.toString?.()) || { text: clsData?.[cel.id]?.text || clsData?.[cel.id] || cel.id };
91
91
  return { ...cel, ...data };
92
92
  });
93
93
  Object.assign(el, { options });