@opengis/admin 0.3.25 → 0.3.26

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,9 +1,9 @@
1
- import { resolveComponent as e, createBlock as r, openBlock as t } from "vue";
2
- import { _ as c } from "./import-file-B8gDejaq.js";
1
+ import { resolveComponent as e, openBlock as r, createBlock as t } from "vue";
2
+ import { _ as c } from "./import-file-DoPKjOx2.js";
3
3
  const n = {};
4
4
  function s(_, p, a, i, f, m) {
5
5
  const o = e("router-view");
6
- return t(), r(o);
6
+ return r(), t(o);
7
7
  }
8
8
  const l = /* @__PURE__ */ c(n, [["render", s]]);
9
9
  export {
@@ -0,0 +1,145 @@
1
+ import { _ as f, s as y, u as x, f as m } from "./import-file-DoPKjOx2.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.sidebarColor || "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
+ };