@opengis/admin 0.2.142 → 0.2.144

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.
@@ -1,18 +1,15 @@
1
1
  import { config, handlebarsSync, handlebars } from '@opengis/fastify-table/utils.js'
2
2
 
3
3
  async function format(d, key, data) {
4
+
4
5
  if (!key?.includes) return '';
5
6
  if (d === true) return 'Так';
6
7
  if (d === false) return 'Ні';
7
8
 
8
- if (key.startsWith('{{') && key.match(/\{\{([^\s]+)/)?.[1] in handlebarsSync.helpers) {
9
- return handlebarsSync.compile(key)(data);
10
- } else if (key.startsWith('{{')) {
11
- return handlebars.compile(key)(data);
9
+ if (key.includes('{{')) {
10
+ return await handlebars.compile(key)(data);
12
11
  }
13
12
 
14
- // if (config.local && config.debug) console.log('descriptionList:d', d, key, data);
15
- if (!d) return null;
16
13
  return d;
17
14
  }
18
15
  export default async function descriptionList(data, opt) {
@@ -38,10 +35,6 @@ export default async function descriptionList(data, opt) {
38
35
 
39
36
  const d1 = await format(data[key], key, data) || '-';
40
37
 
41
- if (config.local && config.debug && d1 === '-') {
42
- // console.log('descriptionList:for', name, nameHBS, key, data);
43
- }
44
-
45
38
  result.push(`<div class="grid grid-cols-1 gap-1 py-3 sm:grid-cols-3 sm:gap-4">
46
39
  <dt class="text-gray-900">${nameHBS || name}</dt>
47
40
  <dd class="text-gray-700 sm:col-span-2">${d1}</dd>
@@ -10,8 +10,8 @@ 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.startsWith('{{') && key.match(/\{\{([^\s]+)/)?.[1] in handlebarsSync.helpers) {
14
- return handlebarsSync.compile(key)(data);
13
+ if (key.startsWith('{{')) {
14
+ return handlebars.compile(key)(data);
15
15
  } else if (key.startsWith('{{') && key.includes(' ') && !(key.match(/\{\{([^\s]+)/)?.[1] in handlebars.helpers)) {
16
16
  return null;
17
17
  }
@@ -21,7 +21,7 @@ function format(d, key, data, hash) {
21
21
  export default async function tableList(data, opt) {
22
22
  const { hash } = opt;
23
23
  // no data
24
-
24
+ // const time = Date.now();
25
25
  if (hash.nodata && !data?.length) {
26
26
  const noDataText = typeof hash.nodata == 'string' ? hash.nodata : '<div class="bg-gray-200 text-center p-6 rounded-xl"><h3 class="text-lg font-semibold">Інформація відсутня</h3></div>';
27
27
  return noDataText
@@ -66,7 +66,7 @@ export default async function tableList(data, opt) {
66
66
  if (skip[name]) continue;
67
67
 
68
68
  const tokenData = key == 'actions' ? token : null;
69
- const d1 = ['{{format', '{{select', '{{badge', '{{#ifCond'].filter(el => key.includes(el)).length ? await handlebars.compile(key)({ ...row, token, hash }) || '-' : null
69
+ const d1 = key.includes('{{') ? await handlebars.compile(key)({ ...row, token, hash }) || '-' : null
70
70
  result.push(`<td class="whitespace-nowrap py-2 text-gray-900">
71
71
  ${d1 || format(tokenData || row[key], key, row, hash)}
72
72
  </td>`);
@@ -78,6 +78,6 @@ export default async function tableList(data, opt) {
78
78
  }
79
79
  result.push('</tbody>');
80
80
 
81
-
81
+ // console.log(Date.now() - time)
82
82
  return '<table class="min-w-full divide-y-2 divide-gray-200 bg-white min-w-full divide-y-2 divide-gray-200 bg-white "> ' + result.join('') + '</table>';
83
83
  }
@@ -1,6 +1,6 @@
1
-
2
-
3
- export default function button(token, title) {
4
- return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
5
- class="inline-flex items-center px-2 py-1 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white">${title || 'Додати'}</button>`;
1
+
2
+
3
+ export default function button(token, title) {
4
+ return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
5
+ class="inline-flex items-center px-2 py-1 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white">${title || 'Додати'}</button>`;
6
6
  }
@@ -1,21 +1,21 @@
1
- function onCheck(rule, data) {
2
- const val = data[rule[0]];
3
- // console.log(val, rule[1], rule[2])
4
- if (rule[1] === '==') return val === rule[2];
5
- if (rule[1] === '!=') return val !== rule[2];
6
- if (rule[1] === 'in' && rule[2].split) return rule[2].split(',').includes(val);
7
- if (rule[1] === 'in' && rule[2].includes) return rule[2].includes(val);
8
-
9
- if (rule[1] === 'not in' && rule[2].split) return !rule[2].split(',').includes(val);
10
- if (rule[1] === 'not in' && rule[2].includes) return !rule[2].includes(val);
11
-
12
- if (rule[1] === '>') return val > rule[2];
13
- if (rule[1] === '<') return val < rule[2];
14
- }
15
- export default function conditions(rules, data) {
16
- if (!rules?.length) return true;
17
- const result = Array.isArray(rules[0]) ? !rules.filter(el => !onCheck(el, data)).length : onCheck(rules, data)
18
- // console.log(rules, result)
19
- return result;
20
-
1
+ function onCheck(rule, data) {
2
+ const val = data[rule[0]];
3
+ // console.log(val, rule[1], rule[2])
4
+ if (rule[1] === '==') return val === rule[2];
5
+ if (rule[1] === '!=') return val !== rule[2];
6
+ if (rule[1] === 'in' && rule[2].split) return rule[2].split(',').includes(val);
7
+ if (rule[1] === 'in' && rule[2].includes) return rule[2].includes(val);
8
+
9
+ if (rule[1] === 'not in' && rule[2].split) return !rule[2].split(',').includes(val);
10
+ if (rule[1] === 'not in' && rule[2].includes) return !rule[2].includes(val);
11
+
12
+ if (rule[1] === '>') return val > rule[2];
13
+ if (rule[1] === '<') return val < rule[2];
14
+ }
15
+ export default function conditions(rules, data) {
16
+ if (!rules?.length) return true;
17
+ const result = Array.isArray(rules[0]) ? !rules.filter(el => !onCheck(el, data)).length : onCheck(rules, data)
18
+ // console.log(rules, result)
19
+ return result;
20
+
21
21
  }
@@ -84,7 +84,8 @@ export default async function cardPrint(req, reply) {
84
84
  const pt = await getTemplate('pt', template)
85
85
  || await readFile(path.join(dirname, '../../../templates/pt/card-print.pt.hbs'), 'utf8');
86
86
 
87
- const url = (req.protocol || 'https') + '://' + req.hostname + req.url.replace(req.routeOptions.url.split(':')[0], '/card/');
87
+ const trimPort = ['80', '443'].find(el => req.hostname.endsWith(el));
88
+ const url = (req.protocol || 'https') + '://' + req.hostname.replace(trimPort, '') + req.url.replace(req.routeOptions.url.split(':')[0], '/card/');
88
89
  const qrCode = `<img src="${await qr.toDataURL(url, { type: 'png', ec_level: 'M', size: 5, margin: 4 })}" alt="qrcode">`;
89
90
 
90
91
  const cardTemplates = await getTemplate('card', table);