@opengis/fastify-table 1.2.0 → 1.2.1
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,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
config, getTemplate, getFilterSQL, getMeta, metaFormat, getAccess, setToken, gisIRColumn, applyHook,
|
|
3
|
-
handlebars,
|
|
2
|
+
config, getTemplate, getFilterSQL, getMeta, metaFormat, getAccess, setToken, gisIRColumn, applyHook, handlebars, getSelect,
|
|
4
3
|
} from '../../../../utils.js';
|
|
5
4
|
|
|
6
5
|
const maxLimit = 100;
|
|
@@ -135,8 +134,21 @@ export default async function dataAPI(req) {
|
|
|
135
134
|
const agg = Object.keys(counts).filter(el => !['total', 'filtered'].includes(el)).reduce((acc, el) => ({ ...acc, [el]: counts[el] }), {});
|
|
136
135
|
|
|
137
136
|
await metaFormat({ rows, table: hookData?.table || params.table });
|
|
137
|
+
|
|
138
|
+
const status = [];
|
|
139
|
+
if (loadTable.meta?.status) {
|
|
140
|
+
const statusColumn = loadTable.meta?.cls?.[loadTable.meta?.status]
|
|
141
|
+
? { name: loadTable.meta?.status, data: loadTable.meta?.cls?.[loadTable.meta?.status] }
|
|
142
|
+
: loadTable.columns.find(col => col.name === loadTable.meta?.status) || {};
|
|
143
|
+
|
|
144
|
+
const statusCls = statusColumn.data || statusColumn.option;
|
|
145
|
+
const statusClsData = statusCls ? await getSelect(statusCls, pg) : {};
|
|
146
|
+
statusClsData?.arr
|
|
147
|
+
?.forEach(el => status.push({ ...el, count: rows.filter(row => el.id === row[statusColumn.name]).length }));
|
|
148
|
+
}
|
|
149
|
+
|
|
138
150
|
const res = {
|
|
139
|
-
time: Date.now() - time, public: ispublic, card: loadTable.card, actions, total, filtered, count: rows.length, pk, form, agg, rows, meta, columns, filters,
|
|
151
|
+
time: Date.now() - time, public: ispublic, card: loadTable.card, actions, total, filtered, count: rows.length, pk, form, agg, status, rows, meta, columns, filters,
|
|
140
152
|
};
|
|
141
153
|
|
|
142
154
|
// console.log({ add: loadTable.table, form: loadTable.form });
|