@opengis/admin 0.2.103 → 0.2.104
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
@@ -10,8 +10,10 @@ function format(d, key, data, hash) {
|
|
10
10
|
if (key === 'actions') {
|
11
11
|
return `<div class="flex items-center gap-2">${(hash.form ? buttonEdit(d, 'Редагувати') : '') + buttonDel(d)}</div>`
|
12
12
|
}
|
13
|
-
if (key.
|
13
|
+
if (key.startsWith('{{') && key.match(/\{\{([^\s]+)/)?.[1] in handlebarsSync.helpers) {
|
14
14
|
return handlebarsSync.compile(key)(data);
|
15
|
+
} else if (key.startsWith('{{') && key.includes(' ') && !(key.match(/\{\{([^\s]+)/)?.[1] in handlebars.helpers)) {
|
16
|
+
return null;
|
15
17
|
}
|
16
18
|
if (!d) return '-';
|
17
19
|
return d;
|
@@ -6,6 +6,11 @@ import { getAccess, handlebars, setOpt, setToken, getTemplate, handlebarsSync, a
|
|
6
6
|
import getTableData from "./tableData.js";
|
7
7
|
import conditions from './utils/conditions.js';
|
8
8
|
|
9
|
+
const components = {
|
10
|
+
'vs-widget-file': `select 'vs-widget-file' as component, count(*) from crm.files where entity_id=$1 and file_status<>3`,
|
11
|
+
'vs-widget-comments': `select 'vs-widget-comments' as component, count(*) from crm.communications where entity_id=$1`
|
12
|
+
};
|
13
|
+
|
9
14
|
export default async function getCardData(req) {
|
10
15
|
|
11
16
|
const {
|
@@ -43,7 +48,13 @@ export default async function getCardData(req) {
|
|
43
48
|
const data = await Promise.all(filtered.map(el => pg.query(el.count).then(el => el.rows[0] || {})))
|
44
49
|
filtered.forEach((el, i) => {
|
45
50
|
Object.assign(el, data[i] || {}, data[i].count ? {} : { count: undefined })
|
46
|
-
})
|
51
|
+
});
|
52
|
+
const q = el.items.map((el) => el.component ? components[el.component] : null).filter(el => el).join(' union all ');
|
53
|
+
const counts = q && id
|
54
|
+
? await pg.query(q, [id])
|
55
|
+
.then(e => e.rows.reduce((acc, curr) => Object.assign(acc, { [curr.component]: curr.count }), {}))
|
56
|
+
: {};
|
57
|
+
el.items?.filter?.(item => item.component)?.forEach(item => Object.assign(item, { count: counts?.[item.component] }));
|
47
58
|
})
|
48
59
|
|
49
60
|
|