@opengis/admin 0.2.78 → 0.2.79

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,6 @@
1
1
  {
2
2
  "name": "@opengis/admin",
3
- "version": "0.2.78",
3
+ "version": "0.2.79",
4
4
  "description": "This project Softpro Admin",
5
5
  "main": "dist/admin.js",
6
6
  "type": "module",
@@ -55,7 +55,7 @@ export default async function tableFilter(req) {
55
55
  } */
56
56
  if (el.type === 'Autocomplete') return;
57
57
  const options = countArr.rows.map(cel => {
58
- const data = cls.find(c => c.id === cel.id);
58
+ const data = cls.find(c => c.id.toString() === cel.id.toString());
59
59
  return { ...cel, ...data };
60
60
  });
61
61
  Object.assign(el, { options });
@@ -1,6 +1,7 @@
1
1
  import { getMeta, getToken, pgClients } from '@opengis/fastify-table/utils.js';
2
2
 
3
3
  const galleryExtList = ['png', 'svg', 'jpg', 'jpeg', 'gif', 'mp4', 'mov', 'avi'];
4
+ const username = `coalesce(u.sur_name,'')||coalesce(' '||u.user_name,'') ||coalesce(' '||u.father_name,'') as username`;
4
5
 
5
6
  /**
6
7
  * Дістає CRM для widget
@@ -16,17 +17,19 @@ export default async function widgetGet({
16
17
 
17
18
  const objectid = param ? JSON.parse(param)?.id : params.objectid;
18
19
 
19
- if (!objectid) return { error: 'id required', status: 400 };
20
+ if (!objectid) {
21
+ return { message: 'id required', status: 400 };
22
+ }
20
23
 
21
24
  const sqls = {
22
25
  comment: pg.pk['admin.users']
23
26
  ? `select communication_id, entity_id, body, subject, c.cdate, c.uid,
24
- coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, avatar
27
+ ${username}, u.login, avatar
25
28
  from crm.communications c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc`
26
29
  : 'select communication_id, entity_id, body, subject, cdate, uid from crm.communications where entity_id=$1 order by cdate desc',
27
30
 
28
31
  history: `SELECT change_id, entity_id, entity_type, change_type, change_date, a.change_user_id, a.uid, a.cdate, b.json_agg as changes,
29
- (coalesce(coalesce(u.sur_name,'')||coalesce(' '||u.user_name,'') ||coalesce(' '||u.father_name,''),u.login)) as username
32
+ ${username}, u.login
30
33
  FROM log.table_changes a
31
34
  left join admin.users u on a.change_user_id = u.uid
32
35
  left join lateral(
@@ -43,20 +46,20 @@ export default async function widgetGet({
43
46
  limit 100`,
44
47
 
45
48
  checklist: pg.pk['admin.users']
46
- ? `SELECT checklist_id, entity_id, subject, is_done, done_date, c.uid, c.cdate, coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username,
49
+ ? `SELECT checklist_id, entity_id, subject, is_done, done_date, c.uid, c.cdate, ${username}, u.login,
47
50
  avatar FROM crm.checklists c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc`
48
51
  : 'SELECT checklist_id, entity_id, subject, is_done, done_date, uid, cdate FROM crm.checklists where entity_id=$1 order by cdate desc',
49
52
 
50
53
  file: pg.pk['admin.users']
51
54
  ? `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, c.ismain,
52
- coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, isverified,
55
+ ${username}, u.login, isverified,
53
56
  avatar, c.uid as author, file_status FROM crm.files c left join admin.users u on u.uid=c.uid
54
57
  where entity_id=$1 and file_status<>3 order by cdate desc`
55
58
  : `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, uid, cdate, file_type, ismain,
56
59
  isverified, uid as author, file_status FROM crm.files c where entity_id=$1 and file_status<>3 order by cdate desc`,
57
60
  gallery: pg.pk['admin.users']
58
61
  ? `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, c.ismain,
59
- coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, isverified,
62
+ ${username}, u.login, isverified,
60
63
  avatar, c.uid as author, file_status FROM crm.files c left join admin.users u on u.uid=c.uid
61
64
  where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc`
62
65
  : `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, ismain,
@@ -64,22 +67,24 @@ export default async function widgetGet({
64
67
 
65
68
  };
66
69
  const sql = sqls[params.type];
70
+
67
71
  if (!sql) {
68
- return { error: 'param type not valid', status: 400 };
72
+ return { message: 'param type not valid', status: 400 };
69
73
  }
70
74
 
71
75
 
72
76
  /* data */
73
77
  const time = [Date.now()];
74
- const { rows } = await pg.query(sql, [objectid, params.type === 'gallery' ? galleryExtList : null].filter((el) => el));
78
+ const { rows = [] } = await pg.query(sql, [objectid, params.type === 'gallery' ? galleryExtList : null].filter((el) => el));
79
+ rows.forEach(row => Object.assign(row, { username: row.username?.trim?.() || row.login }));
75
80
  time.push(Date.now());
76
81
 
77
82
  /* Object info */
78
83
  const { tableName } = pg.pk['log.table_changes'] ? await pg.one('select entity_type as "tableName" from log.table_changes where entity_id=$1 limit 1', [objectid]) : {};
79
84
  const { pk } = await getMeta({ table: tableName });
80
85
 
81
- const q = tableName && pg.pk['admin.users'] ? `select coalesce(b.user_name,'')||coalesce(' '||b.sur_name,'') as author, a.cdate, a.editor_date from ${tableName} a
82
- left join admin.users b on a.uid=b.uid where a.${pk}=$1 limit 1` : undefined;
86
+ const q = tableName && pg.pk['admin.users'] ? `select ${username} as author, u.login, a.cdate, a.editor_date from ${tableName} a
87
+ left join admin.users u on a.uid=u.uid where a.${pk}=$1 limit 1` : undefined;
83
88
  const data = pk && q ? await pg.one(q, [objectid]) : {};
84
89
 
85
90
  if (query.debug && user?.user_type === 'admin') {