@opengis/fastify-table 1.4.74 → 1.4.77
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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handlebarsSync } from '../../../../helpers/index.js';
|
|
2
2
|
|
|
3
3
|
import getTemplate from '../getTemplate.js';
|
|
4
4
|
import getSelectVal from './getSelectVal.js';
|
|
@@ -10,19 +10,20 @@ export default async function metaFormat({
|
|
|
10
10
|
const loadTable = table ? await getTemplate('table', table) : {};
|
|
11
11
|
const selectCols = Object.keys(cls || {}).map(key => ({ name: key, data: cls[key] })).concat(loadTable?.columns?.filter((e) => e.data) || []);
|
|
12
12
|
const metaCls = Object.keys(loadTable?.meta?.cls || {}).map((el) => ({ name: el, data: loadTable?.meta?.cls[el] }));
|
|
13
|
-
const htmlCols = Object.keys(htmls || {}).map(key => ({ name: key, html: htmls[key] })).concat(loadTable?.columns?.filter?.((e) => e.name && e.format
|
|
13
|
+
const htmlCols = Object.keys(htmls || {}).map(key => ({ name: key, html: htmls[key] })).concat(loadTable?.columns?.filter?.((e) => e.name && e.html && e.format && ['html', 'slot'].includes(e.format)) || []);
|
|
14
14
|
if (!original?.length || (!selectCols?.length && !metaCls?.length && !htmlCols?.length)) return original;
|
|
15
15
|
|
|
16
16
|
const rows = reassign ? original : JSON.parse(JSON.stringify(original));
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
// html && slot (vue component) format
|
|
19
|
+
htmlCols.forEach((attr) => {
|
|
20
|
+
rows.filter(Boolean).forEach((row) => {
|
|
21
|
+
const html = handlebarsSync.compile(attr.html)(row);
|
|
22
|
+
Object.assign(row, { [attr.name]: html?.replaceAll?.(/<[^>]*>/g, '')?.replace?.(/\n/g, '')?.trim?.() });
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
25
|
|
|
26
|
+
// cls & select format
|
|
26
27
|
await Promise.all(selectCols.concat(metaCls)?.map(async (attr) => {
|
|
27
28
|
const values = [...new Set(rows?.map((el) => el[attr.name]).flat())].filter((el) => (typeof el === 'boolean' ? true : el));
|
|
28
29
|
if (!values.length) return null;
|
|
@@ -67,7 +67,7 @@ export default async function getForm({
|
|
|
67
67
|
// form in form addToken
|
|
68
68
|
formatSchema(schema, user, loadTemplate?.obj);
|
|
69
69
|
|
|
70
|
-
const id = edit
|
|
70
|
+
const id = edit || tokenData?.id;
|
|
71
71
|
const isAllowedByTemplate = id ? actions.includes('edit') : actions.includes('add');
|
|
72
72
|
|
|
73
73
|
if (
|