@opengis/fastify-table 1.3.36 → 1.3.38
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
|
@@ -15,15 +15,17 @@ function getQuery({
|
|
|
15
15
|
|
|
16
16
|
const mainOperators = ['=', '~', '>', '<'];
|
|
17
17
|
|
|
18
|
-
const filterQueryArray = filterStr
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const filterQueryArray = decodeURIComponent(filterStr?.replace?.(/%/g, '%25')?.replace?.(/%/g, '\\%')?.replace?.(/(^,)|(,$)/g, ''))?.replace?.(/'/g, "''")?.split?.(/[;|]/) || [];
|
|
19
|
+
// default filter value form checkboxes, autocomplete or sql-defined only
|
|
20
|
+
const filterDefaultQueryArray = filterList?.filter?.(el => el.name && !filterStr?.includes?.(`${el.name}=`) && el.default && (el.options || el.sql))?.map?.((el) => `${el.name}=${el.default}`) || [];
|
|
21
|
+
|
|
22
|
+
// concat default + request filters
|
|
23
|
+
const arr = filterQueryArray.concat(filterDefaultQueryArray).filter(el => el);
|
|
22
24
|
|
|
23
25
|
const resultList = [];
|
|
24
26
|
|
|
25
|
-
for (let i = 0; i <
|
|
26
|
-
const item =
|
|
27
|
+
for (let i = 0; i < arr.length; i += 1) {
|
|
28
|
+
const item = arr[i];
|
|
27
29
|
const splitby = mainOperators?.find((el) => item.indexOf(el) !== -1) || '=';
|
|
28
30
|
const [name] = item.split(splitby);
|
|
29
31
|
|
|
@@ -37,7 +39,7 @@ function getQuery({
|
|
|
37
39
|
const { strict, extra } = filter;
|
|
38
40
|
|
|
39
41
|
// find all value
|
|
40
|
-
const value =
|
|
42
|
+
const value = arr.filter((el) => el.split(splitby)?.[0] === name).map((el) => el.substring(name.length + 1)).join(',');
|
|
41
43
|
|
|
42
44
|
const optimize = fields?.find((el) => el.name === name) ? null : tableSQL.find((el) => el.name === name);
|
|
43
45
|
|
|
@@ -7,12 +7,12 @@ import getSelectVal from './getSelectVal.js';
|
|
|
7
7
|
import pgClients from '../../../pg/pgClients.js';
|
|
8
8
|
|
|
9
9
|
export default async function metaFormat({
|
|
10
|
-
rows: original, table, cls, sufix = true, reassign = true,
|
|
10
|
+
rows: original, table, cls, htmls, sufix = true, reassign = true,
|
|
11
11
|
}, pg = pgClients.client) {
|
|
12
12
|
const loadTable = table ? await getTemplate('table', table) : {};
|
|
13
13
|
const selectCols = Object.keys(cls || {}).map(key => ({ name: key, data: cls[key] })).concat(loadTable?.columns?.filter((e) => e.data) || []);
|
|
14
14
|
const metaCls = Object.keys(loadTable?.meta?.cls || {}).map((el) => ({ name: el, data: loadTable?.meta?.cls[el] }));
|
|
15
|
-
const htmlCols = loadTable?.columns?.filter?.((e) => e.name && e.format === 'html' && e.html) || [];
|
|
15
|
+
const htmlCols = Object.keys(htmls || {}).map(key => ({ name: key, html: htmls[key] })).concat(loadTable?.columns?.filter?.((e) => e.name && e.format === 'html' && e.html) || []);
|
|
16
16
|
if (!original?.length || !selectCols?.length && !metaCls?.length && !htmlCols?.length) return original;
|
|
17
17
|
|
|
18
18
|
const rows = reassign ? original : JSON.parse(JSON.stringify(original));
|