@opengis/cms 0.0.50 → 0.0.51

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.
Files changed (20) hide show
  1. package/dist/{ArticlesPage-Cuit_90w.js → ArticlesPage-BcR1hbds.js} +3 -3
  2. package/dist/{BuilderPage-B79YHrmr.js → BuilderPage-CK_osM89.js} +51 -51
  3. package/dist/{CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-B6irHMzL.js → CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-CnOe9ORD.js} +19 -19
  4. package/dist/{EditCollectionPage-B4p_iA6h.js → EditCollectionPage-DtgvKGm-.js} +2 -2
  5. package/dist/{MenuAddPage-CmU4kAUM.js → MenuAddPage-Bf48Z-ah.js} +1 -1
  6. package/dist/{MenuItemPage-UV8JlJvT.js → MenuItemPage-BSwUW8tv.js} +59 -59
  7. package/dist/{MenuPage-c4TPJgIN.js → MenuPage-tJZtK46W.js} +1 -1
  8. package/dist/MonacoEditor.vue_vue_type_script_setup_true_lang-B1DrxmQX.js +84 -0
  9. package/dist/{UniversalTable.vue_vue_type_script_setup_true_lang-DR4PQwqR.js → UniversalTable.vue_vue_type_script_setup_true_lang-CJGTsd1V.js} +80 -80
  10. package/dist/{UniversalTablePagination.vue_vue_type_script_setup_true_lang-C8P9DCeX.js → UniversalTablePagination.vue_vue_type_script_setup_true_lang-GYZd_gkA.js} +46 -46
  11. package/dist/{contentForm-S5mXr5B7.js → contentForm-NcG15_5z.js} +1 -1
  12. package/dist/index.js +5 -5
  13. package/package.json +68 -68
  14. package/server/functions/getSearchData.js +1 -1
  15. package/server/routes/cms/controllers/getPermissions.js +15 -15
  16. package/server/routes/cms/controllers/searchContent.js +10 -3
  17. package/server/routes/cms/controllers/setPermissions.js +49 -49
  18. package/server/routes/cms/utils/additionalData.js +1 -1
  19. package/server/templates/select/core.user_mentioned.sql +1 -1
  20. package/dist/MonacoEditor.vue_vue_type_script_setup_true_lang-C8cip9Ci.js +0 -84
@@ -1,4 +1,6 @@
1
- import { config, pgClients, getFilterSQL } from '@opengis/fastify-table/utils.js';
1
+ import { pgClients, getFilterSQL } from '@opengis/fastify-table/utils.js';
2
+
3
+ import additionalData from '../utils/additionalData.js';
2
4
 
3
5
  const filterList = [
4
6
  {
@@ -55,11 +57,12 @@ export default async function searchContent({
55
57
  const limit = Math.min(query.limit || 16, maxLimit);
56
58
  const offset = (page - 1) * limit;
57
59
 
58
- const { q } = filter ? await getFilterSQL({
60
+ const { q } = filter || search ? await getFilterSQL({
59
61
  pg,
60
62
  table: 'site.contents',
61
63
  filter,
62
64
  search,
65
+ searchColumn: 'a.slug,a.title',
63
66
  query: `status='published'`,
64
67
  filterList,
65
68
  }) : { q: `status='published'` };
@@ -121,10 +124,12 @@ export default async function searchContent({
121
124
  }[!!asc];
122
125
 
123
126
  const { optimizedSQL = `SELECT * FROM data."${table}" where status='published' ORDER BY ${order}` } =
124
- filter ? await getFilterSQL({
127
+ filter || search ? await getFilterSQL({
125
128
  pg,
126
129
  table: `data."${table}"`,
127
130
  filter,
131
+ search,
132
+ searchColumn: 'slug,title',
128
133
  query: `status='published'`,
129
134
  filterList: collectionFilters,
130
135
  order: 'published_at DESC NULLS LAST'
@@ -141,6 +146,8 @@ export default async function searchContent({
141
146
  return { rows: [], /*total: total // totals[`data.${table}`] || totals[`data."${table}"`] || 0*/ };
142
147
  });
143
148
 
149
+ // await additionalData(pg, items, locale);
150
+
144
151
  return {
145
152
  rows: items.map(el => ({
146
153
  ...row,
@@ -1,50 +1,50 @@
1
- import { logger, pgClients, dataInsert } from '@opengis/fastify-table/utils.js';
2
-
3
- export default async function setPermissions(req, reply) {
4
- const { pg = pgClients.client, params = {}, user = {}, body = {} } = req;
5
-
6
- if (!user?.uid) {
7
- return reply.status(401).send('unauthorized');
8
- }
9
-
10
- if (!params.id) {
11
- return reply.status(400).send('not enough params: id');
12
- }
13
-
14
- const client = await pg.connect()
15
- const result = {};
16
- try {
17
- await client.query('BEGIN');
18
-
19
- const { rowCount = 0 } = await client.query(
20
- `delete from site.permissions where user_id=$1`,
21
- [params.id].filter(Boolean),
22
- );
23
-
24
- Object.assign(result, { deleted: rowCount });
25
-
26
- if (Array.isArray(body.permissions) && body.permissions?.length) {
27
- body.permissions.forEach((el) => {
28
- Object.assign(el, { user_id: el.user_id || params.id });
29
- });
30
-
31
- await Promise.all(body.permissions.map(async (el) => dataInsert({
32
- pg: client,
33
- table: 'site.permissions',
34
- data: el,
35
- uid: user.uid,
36
- })));
37
-
38
- Object.assign(result, { inserted: body.permissions.length });
39
- }
40
-
41
- await client.query('COMMIT');
42
- return reply.status(200).send(result);
43
- } catch (err) {
44
- await client.query('ROLLBACK');
45
- logger.file('cms/permissions', { error: err.toString(), stack: err.stack });
46
- return reply.status(500).send('set permissions error');
47
- } finally {
48
- client.release();
49
- }
1
+ import { logger, pgClients, dataInsert } from '@opengis/fastify-table/utils.js';
2
+
3
+ export default async function setPermissions(req, reply) {
4
+ const { pg = pgClients.client, params = {}, user = {}, body = {} } = req;
5
+
6
+ if (!user?.uid) {
7
+ return reply.status(401).send('unauthorized');
8
+ }
9
+
10
+ if (!params.id) {
11
+ return reply.status(400).send('not enough params: id');
12
+ }
13
+
14
+ const client = await pg.connect()
15
+ const result = {};
16
+ try {
17
+ await client.query('BEGIN');
18
+
19
+ const { rowCount = 0 } = await client.query(
20
+ `delete from site.permissions where user_id=$1`,
21
+ [params.id].filter(Boolean),
22
+ );
23
+
24
+ Object.assign(result, { deleted: rowCount });
25
+
26
+ if (Array.isArray(body.permissions) && body.permissions?.length) {
27
+ body.permissions.forEach((el) => {
28
+ Object.assign(el, { user_id: el.user_id || params.id });
29
+ });
30
+
31
+ await Promise.all(body.permissions.map(async (el) => dataInsert({
32
+ pg: client,
33
+ table: 'site.permissions',
34
+ data: el,
35
+ uid: user.uid,
36
+ })));
37
+
38
+ Object.assign(result, { inserted: body.permissions.length });
39
+ }
40
+
41
+ await client.query('COMMIT');
42
+ return reply.status(200).send(result);
43
+ } catch (err) {
44
+ await client.query('ROLLBACK');
45
+ logger.file('cms/permissions', { error: err.toString(), stack: err.stack });
46
+ return reply.status(500).send('set permissions error');
47
+ } finally {
48
+ client.release();
49
+ }
50
50
  }
@@ -22,7 +22,7 @@ export default async function additionalData(pg, rows, locale, fields = '*') {
22
22
  const localization = localizations.find(el => el.object_id === row.id);
23
23
  const localizationKeys = Object.keys(localization?.json_object_agg || {}).filter(key => row[key.split(':').shift()]);
24
24
  const localizationObj1 = Object.entries(localization?.json_object_agg || {}).filter(([key]) => rows.length > 1 ? true : localizationKeys.includes(key)).reduce((acc, curr) => ({ ...acc, [curr[0]]: typeof curr[1] === 'string' && curr[1].startsWith('[') && curr[1].endsWith(']') ? JSON.parse(curr[1]) : curr[1] }), {});
25
- const localizationObj = fields?.length ? Object.fromEntries(Object.entries(localizationObj1).filter(([key]) => fields.split(',').includes(key.split(':').shift()))) : localizationObj1;
25
+ const localizationObj = fields?.length && fields !== '*' ? Object.fromEntries(Object.entries(localizationObj1).filter(([key]) => fields.split(',').includes(key.split(':').shift()))) : localizationObj1;
26
26
  if (locale && locale !== 'uk') {
27
27
  Object.assign(row, Object.keys(localizationObj).reduce((acc, curr) => ({ ...acc, [curr.replace(`:${locale}`, '')]: localizationObj[curr] }), {}));
28
28
  } else if (!locale) {
@@ -1,2 +1,2 @@
1
- select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
1
+ select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
2
2
  where enabled order by coalesce(sur_name,'')||coalesce(' '||user_name,'')
@@ -1,84 +0,0 @@
1
- import { defineComponent as s, mergeModels as m, useModel as c, ref as f, onMounted as h, watch as d, onBeforeUnmount as p, openBlock as g, createElementBlock as v, normalizeStyle as w } from "vue";
2
- async function M() {
3
- if (window.monaco)
4
- return window.monaco;
5
- const i = "https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min";
6
- return window.require || (window.require = { paths: { vs: `${i}/vs` } }, await new Promise((t, l) => {
7
- const n = document.createElement("script");
8
- n.src = `${i}/vs/loader.min.js`, n.onload = () => t(), n.onerror = l, document.head.appendChild(n);
9
- })), new Promise((t) => {
10
- window.require(["vs/editor/editor.main"], () => t(window.monaco));
11
- });
12
- }
13
- const C = /* @__PURE__ */ s({
14
- __name: "MonacoEditor",
15
- props: /* @__PURE__ */ m({
16
- language: { default: "javascript" },
17
- theme: { default: "vs-dark" },
18
- width: { default: "100%" },
19
- height: { default: "100%" },
20
- options: { default: () => ({
21
- minimap: { enabled: !1 }
22
- }) }
23
- }, {
24
- modelValue: {
25
- required: !0
26
- },
27
- modelModifiers: {}
28
- }),
29
- emits: ["update:modelValue"],
30
- setup(i) {
31
- const t = i, l = c(i, "modelValue"), n = f(null);
32
- let o = null, r = null;
33
- return h(async () => {
34
- var e;
35
- if (n.value)
36
- try {
37
- r = await M();
38
- const a = ((e = l.value) == null ? void 0 : e.replace(/\\n/g, `
39
- `)) || "";
40
- o = r.editor.create(n.value, {
41
- value: a,
42
- language: t.language,
43
- theme: t.theme,
44
- automaticLayout: !0,
45
- ...t.options
46
- }), o.onDidChangeModelContent(() => {
47
- const u = (o == null ? void 0 : o.getValue()) || "";
48
- l.value = u;
49
- });
50
- } catch (a) {
51
- console.error("Failed to load Monaco Editor:", a);
52
- }
53
- }), d(
54
- () => l.value,
55
- (e) => {
56
- if (o) {
57
- const a = (e == null ? void 0 : e.replace(/\\n/g, `
58
- `)) || "";
59
- a !== o.getValue() && o.setValue(a);
60
- }
61
- },
62
- { immediate: !0 }
63
- ), d(
64
- () => t.language,
65
- (e) => {
66
- o && e && r && r.editor.setModelLanguage(o.getModel(), e);
67
- }
68
- ), d(
69
- () => t.theme,
70
- (e) => {
71
- o && e && r && r.editor.setTheme(e);
72
- }
73
- ), p(() => {
74
- o && (o.dispose(), o = null);
75
- }), (e, a) => (g(), v("div", {
76
- ref_key: "editorContainer",
77
- ref: n,
78
- style: w({ width: e.width, height: e.height })
79
- }, null, 4));
80
- }
81
- });
82
- export {
83
- C as _
84
- };