@opengis/fastify-table 1.2.82 → 1.2.83
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,5 +1,5 @@
|
|
|
1
1
|
import getTemplate from '../../..//table/funcs/getTemplate.js';
|
|
2
|
-
import
|
|
2
|
+
import metaFormat from '../../../table/funcs/metaFormat/index.js';
|
|
3
3
|
|
|
4
4
|
const defaultTitles = {
|
|
5
5
|
editor_date: 'Дата оновлення',
|
|
@@ -82,11 +82,9 @@ export default async function logChanges({
|
|
|
82
82
|
.filter(el => schema[el]?.data)
|
|
83
83
|
.reduce((acc, curr) => Object.assign(acc, { [curr]: schema[curr].data }), {});
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
await metaFormat({ rows: [data], cls, sufix: false });
|
|
87
|
-
}
|
|
85
|
+
const data1 = data ? await metaFormat({ rows: [data], cls, sufix: false, reassign: false }) : null;
|
|
88
86
|
|
|
89
|
-
const newObj = Object.fromEntries(Object.entries(
|
|
87
|
+
const newObj = Object.fromEntries(Object.entries(data1 || {}).map(el => ([[titles[el[0]] || defaultTitles[el[0]] || el[0]], el[1]])));
|
|
90
88
|
const changesData = Object.keys(newObj || {}).map(el => ({
|
|
91
89
|
change_id: changeId,
|
|
92
90
|
entity_key: el,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
import { handlebars } from '@opengis/fastify-hb/utils.js';
|
|
2
4
|
|
|
3
5
|
import getTemplate from '../getTemplate.js';
|
|
@@ -5,13 +7,15 @@ import getSelectVal from './getSelectVal.js';
|
|
|
5
7
|
import pgClients from '../../../pg/pgClients.js';
|
|
6
8
|
|
|
7
9
|
export default async function metaFormat({
|
|
8
|
-
rows, table, cls, sufix = true,
|
|
10
|
+
rows: original, table, cls, sufix = true, reassign = true,
|
|
9
11
|
}, pg = pgClients.client) {
|
|
10
12
|
const loadTable = table ? await getTemplate('table', table) : {};
|
|
11
13
|
const selectCols = Object.keys(cls || {}).map(key => ({ name: key, data: cls[key] })).concat(loadTable?.columns?.filter((e) => e.data) || []);
|
|
12
14
|
const metaCls = Object.keys(loadTable?.meta?.cls || {}).map((el) => ({ name: el, data: loadTable?.meta?.cls[el] }));
|
|
13
15
|
const htmlCols = loadTable?.columns?.filter?.((e) => e.name && e.format === 'html' && e.html) || [];
|
|
14
|
-
if (!selectCols?.length && !metaCls?.length && !htmlCols?.length) return
|
|
16
|
+
if (!original?.length || !selectCols?.length && !metaCls?.length && !htmlCols?.length) return original;
|
|
17
|
+
|
|
18
|
+
const rows = reassign ? original : JSON.parse(JSON.stringify(original));
|
|
15
19
|
|
|
16
20
|
await Promise.all(htmlCols.map(async (attr) => {
|
|
17
21
|
await Promise.all(rows.filter(row => row?.[attr.name])?.map(async (row) => {
|