@opengis/admin 0.3.68 → 0.3.70
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/README.md +97 -97
- package/config.js +4 -4
- package/dist/add-page-DrW4HvNl.js +126 -0
- package/dist/{admin-interface-JvPo2fRp.js → admin-interface-IFxDrzbG.js} +13 -13
- package/dist/{admin-view-CpOQOjcg.js → admin-view-Biw3y3VC.js} +6 -6
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +103 -103
- package/dist/assets/logo.svg +41 -41
- package/dist/{card-view-BlzCY3qY.js → card-view-DhbJ0PJ0.js} +3 -3
- package/dist/edit-page-B3y18L5i.js +154 -0
- package/dist/{import-file-CsGJ_fsB.js → import-file-C9RmOGhX.js} +18301 -18180
- package/dist/{profile-page-CXJaftia.js → profile-page-Bn9naG_j.js} +4 -4
- package/dist/style.css +1 -1
- package/module/settings/card/admin.accounts.table/index.yml +7 -7
- package/module/settings/card/admin.accounts.table/rules.hbs +18 -18
- package/module/settings/card/admin.accounts.table/users.hbs +13 -13
- package/module/settings/card/admin.routes.table/groups.hbs +11 -11
- package/module/settings/card/admin.routes.table/users.hbs +16 -16
- package/module/settings/cls/core.actions.json +17 -17
- package/module/settings/cls/core.scope.json +13 -13
- package/module/settings/cls/properties.site_status.json +13 -13
- package/module/settings/cls/properties.widget_status.json +13 -13
- package/module/settings/cls/yes_no.json +11 -11
- package/module/settings/form/admin.accounts.form.json +13 -13
- package/module/settings/form/admin.properties.form.json +15 -15
- package/module/settings/form/admin.roles.form.json +21 -21
- package/module/settings/form/admin.user_properties.form.json +15 -15
- package/module/settings/form/admin.user_roles_card.form.json +13 -13
- package/module/settings/interface/admin.properties.json +4 -4
- package/module/settings/interface/admin.roles.json +4 -4
- package/module/settings/interface/admin.routes.json +4 -4
- package/module/settings/interface/admin.users.json +4 -4
- package/module/settings/select/core.routes.sql +1 -1
- package/module/settings/select/core.user_mentioned.sql +1 -1
- package/module/settings/select/core.user_uid.sql +1 -1
- package/module/settings/table/admin.properties.table.json +39 -39
- package/module/settings/table/admin.user_properties.table.json +34 -34
- package/package.json +3 -3
- package/server/helpers/core/badge.js +16 -16
- package/server/helpers/core/buttonHelper.js +21 -21
- package/server/helpers/core/coalesce.js +7 -7
- package/server/helpers/core/select.js +48 -48
- package/server/helpers/core/token.js +18 -18
- package/server/helpers/list/buttonHelper.js +21 -21
- package/server/helpers/list/descriptionList.js +23 -7
- package/server/helpers/list/utils/button.js +5 -5
- package/server/helpers/temp/contentList.js +58 -58
- package/server/helpers/temp/ifCond.js +101 -101
- package/server/helpers/utils/button.js +5 -5
- package/server/helpers/utils/mdToHTML.js +17 -17
- package/server/plugins/access/index.mjs +6 -6
- package/server/plugins/adminHook.js +81 -81
- package/server/plugins/cron.js +10 -10
- package/server/plugins/docs.js +28 -28
- package/server/routes/access/controllers/access.group.js +29 -29
- package/server/routes/access/controllers/access.group.post.js +54 -54
- package/server/routes/access/index.mjs +11 -11
- package/server/routes/access/schema.mjs +67 -67
- package/server/routes/calendar/controllers/calendar.data.js +125 -125
- package/server/routes/calendar/index.mjs +7 -7
- package/server/routes/calendar/schema.js +21 -21
- package/server/routes/data/controllers/cardTabData.js +49 -49
- package/server/routes/data/controllers/funcs/getFilterSQL/index.js +92 -92
- package/server/routes/data/controllers/funcs/getFilterSQL/util/formatValue.js +170 -170
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getFilterQuery.js +64 -64
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/server/routes/data/controllers/tableDataId.js +27 -27
- package/server/routes/data/controllers/tokenInfo.js +9 -9
- package/server/routes/data/controllers/utils/assignTokens.js +30 -30
- package/server/routes/data/controllers/utils/conditions.js +20 -20
- package/server/routes/data/controllers/utils/getColumns.js +8 -8
- package/server/routes/data/index.mjs +20 -20
- package/server/routes/data/schema.js +54 -54
- package/server/routes/notifications/controllers/readNotifications.js +18 -18
- package/server/routes/notifications/controllers/testEmail.js +35 -35
- package/server/routes/notifications/controllers/userNotifications.js +53 -53
- package/server/routes/notifications/hook/onWidgetSet.js +56 -56
- package/server/routes/notifications/index.mjs +26 -26
- package/server/routes/notifications/schema.js +16 -16
- package/server/routes/print/controllers/cardPrint.js +135 -135
- package/server/routes/properties/schema.js +10 -10
- package/server/routes/report/controllers/data.js +76 -76
- package/server/routes/report/controllers/list.js +18 -18
- package/server/routes/report/index.mjs +7 -7
- package/server/routes/report/utils/formatValue.js +179 -179
- package/server/routes/root.mjs +3 -3
- package/server/routes/templates/controllers/getTemplate.js +44 -44
- package/server/routes/templates/schema.js +8 -8
- package/server/routes/user/controllers/user.cls.id.js +14 -14
- package/server/routes/user/controllers/user.cls.js +72 -72
- package/server/routes/user/controllers/user.info.js +17 -17
- package/server/routes/user/schema.js +14 -14
- package/server/routes/util/controllers/code.generator.js +89 -89
- package/server/routes/widget/controllers/widget.del.js +80 -80
- package/server/routes/widget/controllers/widget.set.js +101 -101
- package/server/routes/widget/hook/onWidgetSet.js +12 -12
- package/server/routes/widget/index.mjs +20 -20
- package/server/routes/widget/schema.js +12 -12
- package/server/templates/cls/itree.recrzone_category.json +73 -73
- package/server/templates/cls/test.json +9 -9
- package/server/templates/form/admin.user_cls.data.form.json +49 -49
- package/server/templates/form/admin.user_group_rel.form.json +21 -21
- package/server/templates/form/form-user-pass.json +10 -10
- package/server/templates/form/form-user_group.json +39 -39
- package/server/templates/form/form-users.json +156 -156
- package/server/templates/form/user_group_access.form.json +22 -22
- package/server/templates/select/account_id.json +2 -2
- package/server/templates/table/gis.dataset.table.json +43 -43
- package/server/templates/table/management.user_group.table.json +112 -112
- package/server/templates/table/management.users.table.json +126 -126
- package/server/utils/addNotification.js +21 -21
- package/server/utils/sendNotification.js +89 -89
- package/dist/add-page-D-YC5hH-.js +0 -127
- package/dist/edit-page-B7kSIfdN.js +0 -145
@@ -1,89 +1,89 @@
|
|
1
|
-
import { handlebars, pgClients, getTemplate, getRedis, logger } from '@opengis/fastify-table/utils.js';
|
2
|
-
|
3
|
-
import sendEmail from './sendEmail.js';
|
4
|
-
|
5
|
-
// eslint-disable-next-line max-len, no-control-regex
|
6
|
-
const emailReg = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g;
|
7
|
-
|
8
|
-
const rclient = getRedis();
|
9
|
-
|
10
|
-
async function generateNotificationContent({
|
11
|
-
pg, table, template, id, message, data: data1,
|
12
|
-
}) {
|
13
|
-
if (template) {
|
14
|
-
const data = table && id ? await pg.one(`select * from ${table} where ${pg.pk[table]}=$1`, [id]) : data1;
|
15
|
-
// console.log(data);
|
16
|
-
const body = await getTemplate('pt', template);
|
17
|
-
// console.log(body);
|
18
|
-
const html = handlebars.compile(body || template || 'template not found')(data || {});
|
19
|
-
// console.log(html);
|
20
|
-
return html;
|
21
|
-
}
|
22
|
-
return message;
|
23
|
-
}
|
24
|
-
|
25
|
-
// to do: refactor fastify-file to remove funcs completely
|
26
|
-
export default async function notification({
|
27
|
-
pg = pgClients.client,
|
28
|
-
provider = ['email'],
|
29
|
-
from,
|
30
|
-
to,
|
31
|
-
template,
|
32
|
-
table,
|
33
|
-
message,
|
34
|
-
title,
|
35
|
-
file,
|
36
|
-
data,
|
37
|
-
id,
|
38
|
-
nocache,
|
39
|
-
}) {
|
40
|
-
if (pg?.readonly) {
|
41
|
-
return null;
|
42
|
-
}
|
43
|
-
|
44
|
-
const keyTo = `${pg.options?.database}:mail:${provider[0]}:${to || ''}${id || ''}${table || ''}${title || ''}`;
|
45
|
-
const uniqueTo = await rclient.setnx(keyTo, 1);
|
46
|
-
|
47
|
-
if (!uniqueTo && !nocache) {
|
48
|
-
logger.file('notification/sent', { keyTo, send: uniqueTo, nocache });
|
49
|
-
return `already sent: ${keyTo}`;
|
50
|
-
}
|
51
|
-
await rclient.expire(keyTo, 1000 * 600);
|
52
|
-
|
53
|
-
if (!to.length) {
|
54
|
-
return null;
|
55
|
-
}
|
56
|
-
|
57
|
-
if (!(Array.isArray(provider) && provider.length)) {
|
58
|
-
return 'notification provider - must be array and not empty';
|
59
|
-
}
|
60
|
-
|
61
|
-
const html = await generateNotificationContent({
|
62
|
-
pg, table, template, id, message, data,
|
63
|
-
});
|
64
|
-
|
65
|
-
if (provider.includes('email')) {
|
66
|
-
const files = Array.isArray(file) ? file : [file];
|
67
|
-
const attachments = files?.length && false ? await Promise.all(files?.filter((el) => el).map(async (el) => {
|
68
|
-
/* const content = await downloadFile(el, { buffer: true }); // ?
|
69
|
-
return {
|
70
|
-
filename: el.split('/').pop(),
|
71
|
-
encoding: 'base64',
|
72
|
-
content,
|
73
|
-
}; */
|
74
|
-
})) : [];
|
75
|
-
|
76
|
-
const toEmail = Array.isArray(to) ? to.map((emails) => emails.match(emailReg)?.join(',')) : to;
|
77
|
-
|
78
|
-
const result = await sendEmail({
|
79
|
-
attachments,
|
80
|
-
html,
|
81
|
-
subject: title,
|
82
|
-
from,
|
83
|
-
to: toEmail,
|
84
|
-
});
|
85
|
-
|
86
|
-
return result;
|
87
|
-
}
|
88
|
-
return null;
|
89
|
-
}
|
1
|
+
import { handlebars, pgClients, getTemplate, getRedis, logger } from '@opengis/fastify-table/utils.js';
|
2
|
+
|
3
|
+
import sendEmail from './sendEmail.js';
|
4
|
+
|
5
|
+
// eslint-disable-next-line max-len, no-control-regex
|
6
|
+
const emailReg = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g;
|
7
|
+
|
8
|
+
const rclient = getRedis();
|
9
|
+
|
10
|
+
async function generateNotificationContent({
|
11
|
+
pg, table, template, id, message, data: data1,
|
12
|
+
}) {
|
13
|
+
if (template) {
|
14
|
+
const data = table && id ? await pg.one(`select * from ${table} where ${pg.pk[table]}=$1`, [id]) : data1;
|
15
|
+
// console.log(data);
|
16
|
+
const body = await getTemplate('pt', template);
|
17
|
+
// console.log(body);
|
18
|
+
const html = handlebars.compile(body || template || 'template not found')(data || {});
|
19
|
+
// console.log(html);
|
20
|
+
return html;
|
21
|
+
}
|
22
|
+
return message;
|
23
|
+
}
|
24
|
+
|
25
|
+
// to do: refactor fastify-file to remove funcs completely
|
26
|
+
export default async function notification({
|
27
|
+
pg = pgClients.client,
|
28
|
+
provider = ['email'],
|
29
|
+
from,
|
30
|
+
to,
|
31
|
+
template,
|
32
|
+
table,
|
33
|
+
message,
|
34
|
+
title,
|
35
|
+
file,
|
36
|
+
data,
|
37
|
+
id,
|
38
|
+
nocache,
|
39
|
+
}) {
|
40
|
+
if (pg?.readonly) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
|
44
|
+
const keyTo = `${pg.options?.database}:mail:${provider[0]}:${to || ''}${id || ''}${table || ''}${title || ''}`;
|
45
|
+
const uniqueTo = await rclient.setnx(keyTo, 1);
|
46
|
+
|
47
|
+
if (!uniqueTo && !nocache) {
|
48
|
+
logger.file('notification/sent', { keyTo, send: uniqueTo, nocache });
|
49
|
+
return `already sent: ${keyTo}`;
|
50
|
+
}
|
51
|
+
await rclient.expire(keyTo, 1000 * 600);
|
52
|
+
|
53
|
+
if (!to.length) {
|
54
|
+
return null;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (!(Array.isArray(provider) && provider.length)) {
|
58
|
+
return 'notification provider - must be array and not empty';
|
59
|
+
}
|
60
|
+
|
61
|
+
const html = await generateNotificationContent({
|
62
|
+
pg, table, template, id, message, data,
|
63
|
+
});
|
64
|
+
|
65
|
+
if (provider.includes('email')) {
|
66
|
+
const files = Array.isArray(file) ? file : [file];
|
67
|
+
const attachments = files?.length && false ? await Promise.all(files?.filter((el) => el).map(async (el) => {
|
68
|
+
/* const content = await downloadFile(el, { buffer: true }); // ?
|
69
|
+
return {
|
70
|
+
filename: el.split('/').pop(),
|
71
|
+
encoding: 'base64',
|
72
|
+
content,
|
73
|
+
}; */
|
74
|
+
})) : [];
|
75
|
+
|
76
|
+
const toEmail = Array.isArray(to) ? to.map((emails) => emails.match(emailReg)?.join(',')) : to;
|
77
|
+
|
78
|
+
const result = await sendEmail({
|
79
|
+
attachments,
|
80
|
+
html,
|
81
|
+
subject: title,
|
82
|
+
from,
|
83
|
+
to: toEmail,
|
84
|
+
});
|
85
|
+
|
86
|
+
return result;
|
87
|
+
}
|
88
|
+
return null;
|
89
|
+
}
|
@@ -1,127 +0,0 @@
|
|
1
|
-
import { _ as p, s as d, u as g, f as m } from "./import-file-CsGJ_fsB.js";
|
2
|
-
import { resolveComponent as f, openBlock as b, createElementBlock as x, createElementVNode as n, normalizeClass as w, normalizeStyle as h, createBlock as y, createCommentVNode as k } from "vue";
|
3
|
-
const v = {
|
4
|
-
data() {
|
5
|
-
return {
|
6
|
-
formValues: {},
|
7
|
-
scheme: null,
|
8
|
-
table: "",
|
9
|
-
token: "",
|
10
|
-
api: "",
|
11
|
-
style: null
|
12
|
-
};
|
13
|
-
},
|
14
|
-
mounted() {
|
15
|
-
this.getFormScheme();
|
16
|
-
},
|
17
|
-
computed: {
|
18
|
-
color() {
|
19
|
-
return d.value.buttonColor || "blue";
|
20
|
-
}
|
21
|
-
},
|
22
|
-
methods: {
|
23
|
-
flattenMenu(t) {
|
24
|
-
const e = [];
|
25
|
-
return t.forEach((o) => {
|
26
|
-
o.menu ? e.push(...this.flattenMenu(o.menu)) : e.push(o);
|
27
|
-
}), e;
|
28
|
-
},
|
29
|
-
async getFormScheme() {
|
30
|
-
var i, a;
|
31
|
-
const t = this.flattenMenu(g.value);
|
32
|
-
t != null && t.length || this.$router.replace("/404");
|
33
|
-
const e = t == null ? void 0 : t.find((r) => {
|
34
|
-
var s, l;
|
35
|
-
return (r == null ? void 0 : r.path) == ((l = (s = this.$route) == null ? void 0 : s.query) == null ? void 0 : l.table);
|
36
|
-
});
|
37
|
-
e || this.$router.replace("/404");
|
38
|
-
const o = e == null ? void 0 : e.table;
|
39
|
-
this.table = o;
|
40
|
-
try {
|
41
|
-
const r = await m.get(`/api/table-data/${o}`), { data: s } = await m.get(
|
42
|
-
`/api/template/form/${(i = r == null ? void 0 : r.data) == null ? void 0 : i.form}`
|
43
|
-
);
|
44
|
-
this.scheme = (s == null ? void 0 : s.schema) || s, this.style = (s == null ? void 0 : s.style) || null, this.api = (s == null ? void 0 : s.api) || "", this.token = (a = r == null ? void 0 : r.data) == null ? void 0 : a.addToken;
|
45
|
-
} catch {
|
46
|
-
}
|
47
|
-
},
|
48
|
-
getGroupedErrorNotification(t, e) {
|
49
|
-
debugger;
|
50
|
-
if (!t || !e) return "";
|
51
|
-
const o = {};
|
52
|
-
return Object.entries(t).forEach(([a, r]) => {
|
53
|
-
var l;
|
54
|
-
const s = ((l = e[a]) == null ? void 0 : l.ua) || a;
|
55
|
-
r.forEach((c) => {
|
56
|
-
const u = c.message;
|
57
|
-
o[u] || (o[u] = []), o[u].push(`"${s}"`);
|
58
|
-
});
|
59
|
-
}), Object.entries(o).map(([a, r]) => `<b>${a}:</b> ${r.join(", ")}`).join("<br>") || "Сталася помилка валідації";
|
60
|
-
},
|
61
|
-
async createObject() {
|
62
|
-
var e;
|
63
|
-
const t = this.$refs.form;
|
64
|
-
try {
|
65
|
-
await t.doValidation(), await m.post(
|
66
|
-
this.api || `/api/table/${this.token}`,
|
67
|
-
this.formValues
|
68
|
-
), await this.$router.back(), await this.$notify({
|
69
|
-
title: "Успішно!",
|
70
|
-
message: "Об'єкт успішно створено",
|
71
|
-
type: "success"
|
72
|
-
});
|
73
|
-
} catch (o) {
|
74
|
-
const i = this.getGroupedErrorNotification(
|
75
|
-
t == null ? void 0 : t.formErrors,
|
76
|
-
t == null ? void 0 : t.scheme
|
77
|
-
);
|
78
|
-
this.$notify({
|
79
|
-
title: "Помилка!",
|
80
|
-
message: ((e = o == null ? void 0 : o.response) == null ? void 0 : e.data) || i,
|
81
|
-
type: "error"
|
82
|
-
});
|
83
|
-
}
|
84
|
-
}
|
85
|
-
}
|
86
|
-
}, $ = { class: "bg-gray-100 lg:w-[calc(100vw-260px)] w-[100vw]" }, V = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white rounded-xl" }, _ = { class: "flex items-center gap-[6px]" }, j = { class: "bg-white w-full rounded-xl p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" };
|
87
|
-
function E(t, e, o, i, a, r) {
|
88
|
-
var l;
|
89
|
-
const s = f("VsForm");
|
90
|
-
return b(), x("div", $, [
|
91
|
-
n("div", V, [
|
92
|
-
e[3] || (e[3] = n("h2", { class: "text-xl font-medium" }, "Створити", -1)),
|
93
|
-
n("div", _, [
|
94
|
-
n("button", {
|
95
|
-
onClick: e[0] || (e[0] = (c) => t.$router.back()),
|
96
|
-
class: "flex items-center px-3 py-2 text-sm font-medium text-gray-800 duration-300 bg-white border border-gray-100 rounded-lg shadow gap-x-2 focus:outline-none hover:bg-gray-50 hover:border-gray-100"
|
97
|
-
}, " Скасувати "),
|
98
|
-
n("button", {
|
99
|
-
onClick: e[1] || (e[1] = (...c) => r.createObject && r.createObject(...c)),
|
100
|
-
class: w(`inline-flex items-center px-3 py-2 text-sm font-medium text-white duration-300 bg-${r.color}-700 border border-transparent rounded-lg gap-x-2 hover:bg-${r.color}-800 hover:text-white`)
|
101
|
-
}, " Зберегти ", 2)
|
102
|
-
])
|
103
|
-
]),
|
104
|
-
n("div", {
|
105
|
-
style: h({
|
106
|
-
height: ((l = t.$adminSettings) == null ? void 0 : l.header) === !1 ? "calc(100vh - 100px)" : "calc(100vh - 165px)"
|
107
|
-
}),
|
108
|
-
class: "bg-gray-100 p-[20px] flex lg:w-[calc(100vw-260px)] w-[100vw]"
|
109
|
-
}, [
|
110
|
-
n("div", j, [
|
111
|
-
a.scheme ? (b(), y(s, {
|
112
|
-
key: 0,
|
113
|
-
ref: "form",
|
114
|
-
scheme: a.scheme,
|
115
|
-
style: h(a.style),
|
116
|
-
modelValue: a.formValues,
|
117
|
-
"onUpdate:modelValue": e[2] || (e[2] = (c) => a.formValues = c),
|
118
|
-
class: "p-0 mt-[20px]"
|
119
|
-
}, null, 8, ["scheme", "style", "modelValue"])) : k("", !0)
|
120
|
-
])
|
121
|
-
], 4)
|
122
|
-
]);
|
123
|
-
}
|
124
|
-
const O = /* @__PURE__ */ p(v, [["render", E]]);
|
125
|
-
export {
|
126
|
-
O as default
|
127
|
-
};
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import { _ as f, s as y, u as x, f as m } from "./import-file-CsGJ_fsB.js";
|
2
|
-
import { resolveComponent as w, openBlock as b, createElementBlock as k, createElementVNode as u, normalizeClass as v, normalizeStyle as d, createBlock as $, createCommentVNode as V } from "vue";
|
3
|
-
const j = {
|
4
|
-
data() {
|
5
|
-
return {
|
6
|
-
formValues: {},
|
7
|
-
scheme: null,
|
8
|
-
table: "",
|
9
|
-
token: "",
|
10
|
-
style: null
|
11
|
-
};
|
12
|
-
},
|
13
|
-
mounted() {
|
14
|
-
this.getFormScheme();
|
15
|
-
},
|
16
|
-
computed: {
|
17
|
-
color() {
|
18
|
-
return y.value.buttonColor || "blue";
|
19
|
-
}
|
20
|
-
},
|
21
|
-
methods: {
|
22
|
-
flattenMenu(e) {
|
23
|
-
const t = [];
|
24
|
-
return e.forEach((o) => {
|
25
|
-
o.menu ? t.push(...this.flattenMenu(o.menu)) : t.push(o);
|
26
|
-
}), t;
|
27
|
-
},
|
28
|
-
async getFormScheme() {
|
29
|
-
var i, a;
|
30
|
-
const e = this.flattenMenu(x.value);
|
31
|
-
e != null && e.length || this.$router.replace("/404");
|
32
|
-
const t = e == null ? void 0 : e.find((r) => {
|
33
|
-
var l, s;
|
34
|
-
return (r == null ? void 0 : r.path) == ((s = (l = this.$route) == null ? void 0 : l.query) == null ? void 0 : s.table);
|
35
|
-
});
|
36
|
-
t || this.$router.replace("/404");
|
37
|
-
const o = t == null ? void 0 : t.table;
|
38
|
-
this.table = o;
|
39
|
-
try {
|
40
|
-
const {
|
41
|
-
data: { form: r }
|
42
|
-
} = await m.get(`/api/template/table/${o}`), { data: l } = await m.get(
|
43
|
-
`/api/table/${this.table}/${(a = (i = this.$route) == null ? void 0 : i.query) == null ? void 0 : a.id}`
|
44
|
-
);
|
45
|
-
this.token = (l == null ? void 0 : l.token) || "", this.formValues = l || {};
|
46
|
-
const { data: s } = await m.get(`/api/template/form/${r}`);
|
47
|
-
this.scheme = (s == null ? void 0 : s.schema) || s, this.style = (s == null ? void 0 : s.style) || null;
|
48
|
-
} catch {
|
49
|
-
}
|
50
|
-
},
|
51
|
-
async onlyEditObject() {
|
52
|
-
var t, o, i, a, r, l, s, c, n;
|
53
|
-
const e = this.$refs.form;
|
54
|
-
try {
|
55
|
-
await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$notify({
|
56
|
-
title: "Успішно!",
|
57
|
-
message: "Об'єкт успішно створено",
|
58
|
-
type: "success"
|
59
|
-
});
|
60
|
-
} catch (h) {
|
61
|
-
const p = ((t = h == null ? void 0 : h.response) == null ? void 0 : t.data) || "";
|
62
|
-
let g = ((r = (a = (i = (o = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : o[0]) == null ? void 0 : i[1]) == null ? void 0 : a[0]) == null ? void 0 : r.message) === "Це поле обов'язкове" ? "Заповніть обов'язкові поля" : (n = (c = (s = (l = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : l[0]) == null ? void 0 : s[1]) == null ? void 0 : c[0]) == null ? void 0 : n.message;
|
63
|
-
this.$notify({
|
64
|
-
title: "Помилка!",
|
65
|
-
message: p || g || "Сталася помилка валідаціі",
|
66
|
-
type: "error"
|
67
|
-
});
|
68
|
-
}
|
69
|
-
},
|
70
|
-
getGroupedErrorNotification(e, t) {
|
71
|
-
if (!e || !t) return "";
|
72
|
-
const o = {};
|
73
|
-
return Object.entries(e).forEach(([a, r]) => {
|
74
|
-
var s;
|
75
|
-
const l = ((s = t[a]) == null ? void 0 : s.ua) || a;
|
76
|
-
r.forEach((c) => {
|
77
|
-
const n = c.message;
|
78
|
-
o[n] || (o[n] = []), o[n].push(`"${l}"`);
|
79
|
-
});
|
80
|
-
}), Object.entries(o).map(([a, r]) => `<b>${a}:</b> ${r.join(", ")}`).join("<br>") || "Сталася помилка валідації";
|
81
|
-
},
|
82
|
-
async editObjectAndRedirect() {
|
83
|
-
const e = this.$refs.form;
|
84
|
-
try {
|
85
|
-
await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$router.back(), await this.$notify({
|
86
|
-
title: "Успішно!",
|
87
|
-
message: "Об'єкт успішно створено",
|
88
|
-
type: "success"
|
89
|
-
});
|
90
|
-
} catch {
|
91
|
-
const o = this.getGroupedErrorNotification(
|
92
|
-
e == null ? void 0 : e.formErrors,
|
93
|
-
e == null ? void 0 : e.scheme
|
94
|
-
);
|
95
|
-
this.$notify({
|
96
|
-
title: "Помилка!",
|
97
|
-
message: o,
|
98
|
-
type: "error"
|
99
|
-
});
|
100
|
-
}
|
101
|
-
}
|
102
|
-
}
|
103
|
-
}, E = { class: "bg-gray-100 lg:w-[calc(100vw-260px)] w-[100vw]" }, _ = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white rounded-xl" }, O = { class: "flex items-center gap-[6px]" }, M = { class: "bg-white w-full rounded-xl p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" };
|
104
|
-
function C(e, t, o, i, a, r) {
|
105
|
-
var s, c;
|
106
|
-
const l = w("VsForm");
|
107
|
-
return b(), k("div", E, [
|
108
|
-
u("div", _, [
|
109
|
-
t[3] || (t[3] = u("h2", { class: "text-xl font-medium" }, "Редагувати", -1)),
|
110
|
-
u("div", O, [
|
111
|
-
u("button", {
|
112
|
-
onClick: t[0] || (t[0] = (n) => e.$router.back()),
|
113
|
-
class: "flex items-center px-3 py-2 text-sm font-medium text-gray-800 duration-300 bg-white border border-gray-100 rounded-lg shadow gap-x-2 focus:outline-none hover:bg-gray-50 hover:border-gray-100"
|
114
|
-
}, " Скасувати "),
|
115
|
-
u("button", {
|
116
|
-
onClick: t[1] || (t[1] = (...n) => r.editObjectAndRedirect && r.editObjectAndRedirect(...n)),
|
117
|
-
class: v(`inline-flex items-center px-3 py-2 text-sm font-medium text-white duration-300 bg-${r.color}-700 border border-transparent rounded-lg gap-x-2 hover:bg-${r.color}-800 hover:text-white`)
|
118
|
-
}, " Зберегти ", 2)
|
119
|
-
])
|
120
|
-
]),
|
121
|
-
u("div", {
|
122
|
-
style: d({
|
123
|
-
height: ((s = e.$adminSettings) == null ? void 0 : s.header) === !1 ? "calc(100vh - 100px)" : "calc(100vh - 165px)"
|
124
|
-
}),
|
125
|
-
class: "bg-gray-100 p-[20px] flex lg:w-[calc(100vw-260px)] w-[100vw]"
|
126
|
-
}, [
|
127
|
-
u("div", M, [
|
128
|
-
a.scheme ? (b(), $(l, {
|
129
|
-
key: 0,
|
130
|
-
ref: "form",
|
131
|
-
scheme: a.scheme,
|
132
|
-
columns: (c = a.style) == null ? void 0 : c.columns,
|
133
|
-
style: d(a.style),
|
134
|
-
modelValue: a.formValues,
|
135
|
-
"onUpdate:modelValue": t[2] || (t[2] = (n) => a.formValues = n),
|
136
|
-
class: "p-0 mt-[20px]"
|
137
|
-
}, null, 8, ["scheme", "columns", "style", "modelValue"])) : V("", !0)
|
138
|
-
])
|
139
|
-
], 4)
|
140
|
-
]);
|
141
|
-
}
|
142
|
-
const S = /* @__PURE__ */ f(j, [["render", C]]);
|
143
|
-
export {
|
144
|
-
S as default
|
145
|
-
};
|