@opengis/admin 0.2.132 → 0.2.134

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