@opengis/admin 0.2.133 → 0.2.134

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  import { resolveComponent as e, openBlock as r, createBlock as t } from "vue";
2
- import { _ as c } from "./import-file-CztGvKRc.js";
2
+ import { _ as c } from "./import-file-Cb13QIWH.js";
3
3
  const n = {};
4
4
  function s(_, p, a, i, f, m) {
5
5
  const o = e("router-view");
@@ -0,0 +1,138 @@
1
+ import { _ as g, u as f, f as m } from "./import-file-Cb13QIWH.js";
2
+ import { resolveComponent as y, openBlock as h, createElementBlock as x, createElementVNode as c, createBlock as w, normalizeStyle as k, createCommentVNode as v } from "vue";
3
+ const $ = {
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
+ methods: {
17
+ flattenMenu(e) {
18
+ const t = [];
19
+ return e.forEach((r) => {
20
+ r.menu ? t.push(...this.flattenMenu(r.menu)) : t.push(r);
21
+ }), t;
22
+ },
23
+ async getFormScheme() {
24
+ var i, o;
25
+ const e = this.flattenMenu(f.value);
26
+ e != null && e.length || this.$router.replace("/404");
27
+ const t = e == null ? void 0 : e.find((a) => {
28
+ var n, s;
29
+ return (a == null ? void 0 : a.path) == ((s = (n = this.$route) == null ? void 0 : n.query) == null ? void 0 : s.table);
30
+ });
31
+ t || this.$router.replace("/404");
32
+ const r = t == null ? void 0 : t.table;
33
+ this.table = r;
34
+ try {
35
+ const {
36
+ data: { form: a }
37
+ } = await m.get(`/api/template/table/${r}`), { data: n } = await m.get(
38
+ `/api/table/${this.table}/${(o = (i = this.$route) == null ? void 0 : i.query) == null ? void 0 : o.id}`
39
+ );
40
+ this.token = (n == null ? void 0 : n.token) || "", this.formValues = n || {};
41
+ const { data: s } = await m.get(`/api/template/form/${a}`);
42
+ this.scheme = (s == null ? void 0 : s.schema) || s, this.style = (s == null ? void 0 : s.style) || null;
43
+ } catch {
44
+ }
45
+ },
46
+ async onlyEditObject() {
47
+ var t, r, i, o, a, n, s, l, u;
48
+ const e = this.$refs.form;
49
+ try {
50
+ await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$notify({
51
+ title: "Успішно!",
52
+ message: "Об'єкт успішно створено",
53
+ type: "success"
54
+ });
55
+ } catch (b) {
56
+ const d = ((t = b == null ? void 0 : b.response) == null ? void 0 : t.data) || "";
57
+ let p = ((a = (o = (i = (r = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : r[0]) == null ? void 0 : i[1]) == null ? void 0 : o[0]) == null ? void 0 : a.message) === "Це поле обов'язкове" ? "Заповніть обов'язкові поля" : (u = (l = (s = (n = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : n[0]) == null ? void 0 : s[1]) == null ? void 0 : l[0]) == null ? void 0 : u.message;
58
+ this.$notify({
59
+ title: "Помилка!",
60
+ message: d || p || "Сталася помилка валідаціі",
61
+ type: "error"
62
+ });
63
+ }
64
+ },
65
+ getGroupedErrorNotification(e, t) {
66
+ if (!e || !t) return "";
67
+ const r = {};
68
+ return Object.entries(e).forEach(([o, a]) => {
69
+ var s;
70
+ const n = ((s = t[o]) == null ? void 0 : s.ua) || o;
71
+ a.forEach((l) => {
72
+ const u = l.message;
73
+ r[u] || (r[u] = []), r[u].push(`"${n}"`);
74
+ });
75
+ }), Object.entries(r).map(([o, a]) => `<b>${o}:</b> ${a.join(", ")}`).join("<br>") || "Сталася помилка валідації";
76
+ },
77
+ async editObjectAndRedirect() {
78
+ const e = this.$refs.form;
79
+ try {
80
+ await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$router.back(), await this.$notify({
81
+ title: "Успішно!",
82
+ message: "Об'єкт успішно створено",
83
+ type: "success"
84
+ });
85
+ } catch {
86
+ const r = this.getGroupedErrorNotification(
87
+ e == null ? void 0 : e.formErrors,
88
+ e == null ? void 0 : e.scheme
89
+ );
90
+ this.$notify({
91
+ title: "Помилка!",
92
+ message: r,
93
+ type: "error"
94
+ });
95
+ }
96
+ }
97
+ }
98
+ }, V = { class: "bg-gray-50 lg:w-[calc(100vw-260px)] w-[100vw]" }, _ = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white border rounded-xl" }, j = { class: "flex items-center gap-[6px]" }, E = {
99
+ style: { height: "calc(100vh - 155px)" },
100
+ class: "bg-gray-50 p-[20px] flex lg:w-[calc(100vw-260px)] w-[100vw]"
101
+ }, O = { class: "bg-white w-full rounded-xl border 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" };
102
+ function M(e, t, r, i, o, a) {
103
+ var s;
104
+ const n = y("VsForm");
105
+ return h(), x("div", V, [
106
+ c("div", _, [
107
+ t[3] || (t[3] = c("h2", { class: "text-xl font-medium" }, "Редагувати", -1)),
108
+ c("div", j, [
109
+ c("button", {
110
+ onClick: t[0] || (t[0] = (l) => e.$router.back()),
111
+ 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"
112
+ }, " Скасувати "),
113
+ c("button", {
114
+ onClick: t[1] || (t[1] = (...l) => a.editObjectAndRedirect && a.editObjectAndRedirect(...l)),
115
+ class: "inline-flex items-center px-3 py-2 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"
116
+ }, " Зберегти ")
117
+ ])
118
+ ]),
119
+ c("div", E, [
120
+ c("div", O, [
121
+ o.scheme ? (h(), w(n, {
122
+ key: 0,
123
+ ref: "form",
124
+ scheme: o.scheme,
125
+ columns: (s = o.style) == null ? void 0 : s.columns,
126
+ style: k(o.style),
127
+ modelValue: o.formValues,
128
+ "onUpdate:modelValue": t[2] || (t[2] = (l) => o.formValues = l),
129
+ class: "p-0 mt-[20px]"
130
+ }, null, 8, ["scheme", "columns", "style", "modelValue"])) : v("", !0)
131
+ ])
132
+ ])
133
+ ]);
134
+ }
135
+ const N = /* @__PURE__ */ g($, [["render", M]]);
136
+ export {
137
+ N as default
138
+ };