@opengis/fastify-table 2.0.44 → 2.0.46
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/dist/server/plugins/table/funcs/getFilterSQL/util/formatValue.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getFilterSQL/util/formatValue.js +12 -3
- package/dist/server/plugins/table/funcs/getSelect.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelect.js +4 -7
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatValue.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/table/funcs/getFilterSQL/util/formatValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"formatValue.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/table/funcs/getFilterSQL/util/formatValue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAe/D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,EAAE,EACF,KAAK,EACL,MAAW,EACX,IAAI,EACJ,KAAK,EACL,UAAU,EACV,GAAO,EACP,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,OAmLA"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import applyHookSync from "../../../../hook/applyHookSync.js";
|
|
2
2
|
import getRangeQuery from "./getRangeQuery.js";
|
|
3
|
+
const selectFilterTypes = [
|
|
4
|
+
"check",
|
|
5
|
+
"autocomplete",
|
|
6
|
+
"tags",
|
|
7
|
+
"avatar",
|
|
8
|
+
"radio",
|
|
9
|
+
"select",
|
|
10
|
+
"button",
|
|
11
|
+
];
|
|
3
12
|
export default function formatValue({ pg, table, filter = {}, name, value, dataTypeID, uid = 1, optimize, }) {
|
|
4
13
|
const { extra, sql, select, strict, options /* default: defaultValue, */ } = filter;
|
|
5
14
|
const pk = pg?.pk && table ? pg.pk[table] : undefined;
|
|
@@ -33,7 +42,7 @@ export default function formatValue({ pg, table, filter = {}, name, value, dataT
|
|
|
33
42
|
!value ||
|
|
34
43
|
(!dataTypeID && !extra && !sql && !options) ||
|
|
35
44
|
extra?.input?.toLowerCase?.() === "datatable" ||
|
|
36
|
-
(!
|
|
45
|
+
(!selectFilterTypes.includes(filterType) &&
|
|
37
46
|
options?.find?.((el) => el?.sql))) {
|
|
38
47
|
return {};
|
|
39
48
|
}
|
|
@@ -105,11 +114,11 @@ export default function formatValue({ pg, table, filter = {}, name, value, dataT
|
|
|
105
114
|
return { op: "between", query };
|
|
106
115
|
}
|
|
107
116
|
/* select query - from admin.cls / filter options */
|
|
108
|
-
if (
|
|
117
|
+
if (selectFilterTypes.includes(filterType)) {
|
|
109
118
|
// multiple checks with predefined query
|
|
110
119
|
if (options?.find?.((el) => el?.sql)) {
|
|
111
120
|
const query = options
|
|
112
|
-
.filter((el) => value.split(",").includes(el.id))
|
|
121
|
+
.filter((el) => value.split(",").includes(el.id?.toString?.()))
|
|
113
122
|
.map((el) => el.sql || "false")
|
|
114
123
|
.join(" and ") || "false";
|
|
115
124
|
return { op: "=", query };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelect.ts"],"names":[],"mappings":"AAYA,wBAA8B,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAmB,
|
|
1
|
+
{"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelect.ts"],"names":[],"mappings":"AAYA,wBAA8B,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAmB,gBA6BvE"}
|
|
@@ -11,20 +11,17 @@ export default async function getSelect(name, pg = pgClients.client) {
|
|
|
11
11
|
if (loadCls[name] && !config.local)
|
|
12
12
|
return loadCls[name];
|
|
13
13
|
const clsDataGIT = await getTemplate(["cls", "select"], name);
|
|
14
|
-
const { type } =
|
|
14
|
+
const { type } = pg.pk?.["admin.user_cls"]
|
|
15
15
|
? await pg
|
|
16
16
|
.query("select type from admin.user_cls where parent is null and name=$1 union all select type from admin.cls where parent is null and name=$1 limit 1", [name])
|
|
17
17
|
.then((el) => el.rows?.[0] || {})
|
|
18
18
|
: {};
|
|
19
|
-
const
|
|
20
|
-
? sqls[type]
|
|
21
|
-
: undefined;
|
|
22
|
-
const clsDataDB = q
|
|
19
|
+
const clsDataDB = sqls[type || ""]
|
|
23
20
|
? await pg
|
|
24
|
-
.query(
|
|
21
|
+
.query(sqls[type || ""], [name])
|
|
25
22
|
.then((el) => el.rows?.find((item) => item?.data)?.data)
|
|
26
23
|
: undefined;
|
|
27
|
-
const clsData =
|
|
24
|
+
const clsData = clsDataDB ?? clsDataGIT;
|
|
28
25
|
if (!clsData)
|
|
29
26
|
return null;
|
|
30
27
|
// console.log(clsData);
|