@opengis/fastify-table 1.2.90 → 1.2.91
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
|
@@ -3,7 +3,7 @@ import getRangeQuery from "./getRangeQuery.js";
|
|
|
3
3
|
export default function formatValue({
|
|
4
4
|
pg, table, filter = {}, name, value, dataTypeID, uid = 1, optimize,
|
|
5
5
|
}) {
|
|
6
|
-
const { extra, sql, select, strict } = filter;
|
|
6
|
+
const { extra, sql, select, strict, options } = filter;
|
|
7
7
|
const pk = pg?.pk && table ? pg.pk[table] : undefined;
|
|
8
8
|
|
|
9
9
|
const filterType = filter.type?.toLowerCase() || 'text';
|
|
@@ -11,7 +11,8 @@ export default function formatValue({
|
|
|
11
11
|
|
|
12
12
|
if (!name
|
|
13
13
|
|| !value
|
|
14
|
-
|| !dataTypeID && !extra && !sql
|
|
14
|
+
|| (!dataTypeID && !extra && !sql && !options)
|
|
15
|
+
|| extra?.input?.toLowerCase?.() === 'datatable') {
|
|
15
16
|
return {};
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -87,6 +88,12 @@ export default function formatValue({
|
|
|
87
88
|
|
|
88
89
|
/* select query - from admin.cls / filter options */
|
|
89
90
|
if (['check', 'autocomplete', 'text', 'tags', 'avatar', 'radio'].includes(filterType)) {
|
|
91
|
+
// multiple checks with predefined query
|
|
92
|
+
if (filterType === 'check' && options?.length) {
|
|
93
|
+
const opt = options.find(el => el.id === value) || { sql: 'true' };
|
|
94
|
+
return { op: '=', query: opt?.sql };
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
// with sql subquery
|
|
91
98
|
if (sql) {
|
|
92
99
|
return { op: '=', query: querysql };
|
|
@@ -103,17 +110,5 @@ export default function formatValue({
|
|
|
103
110
|
return { op: '=', query };
|
|
104
111
|
}
|
|
105
112
|
|
|
106
|
-
// sql column
|
|
107
|
-
if (optimize && optimize.name !== optimize.pk && false) {
|
|
108
|
-
const val = filterType === 'text' ? `ilike '%${value}%'` : `= any('{${value}}')`;
|
|
109
|
-
return {
|
|
110
|
-
op: '~',
|
|
111
|
-
query: fieldType?.includes('[]')
|
|
112
|
-
? `${optimize.pk} && (select array_agg(${optimize.pk}) from ${optimize.table} where ${name} ${val} )`
|
|
113
|
-
: `${optimize.pk} in (select ${optimize.pk} from ${optimize.table} where ${name} ${val} )`,
|
|
114
|
-
extra,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
113
|
return {};
|
|
119
114
|
}
|