@opengis/admin 0.1.69 → 0.1.70

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,230 @@
1
+ import { g as L, h as R, _ as V, u as H, a as A } from "./import-file-DgJqxKyF.js";
2
+ import { computed as q, resolveComponent as $, openBlock as s, createElementBlock as a, createElementVNode as p, toDisplayString as j, createVNode as z, withCtx as B, createTextVNode as N, createBlock as m, createCommentVNode as v, normalizeClass as M, Fragment as w, renderList as D, resolveDynamicComponent as T } from "vue";
3
+ const E = { class: "h-[76px] bg-white border rounded-xl flex items-center justify-between px-[15px] mb-[16px]" }, S = { class: "text-lg font-semibold md:text-xl text-stone-800 dark:text-neutral-200" }, G = { class: "flex items-center gap-[6px]" }, O = {
4
+ __name: "admin-card-header",
5
+ props: {
6
+ title: {
7
+ type: String
8
+ },
9
+ getRoute: {
10
+ type: String,
11
+ required: !0
12
+ }
13
+ },
14
+ setup(t) {
15
+ const n = t, c = L(), l = R(), r = () => {
16
+ c.back();
17
+ }, u = q(
18
+ () => {
19
+ var d;
20
+ return `/edit?table=${n.getRoute}&id=${(d = l == null ? void 0 : l.params) == null ? void 0 : d.id}`;
21
+ }
22
+ );
23
+ return (d, h) => {
24
+ const b = $("router-link");
25
+ return s(), a("div", E, [
26
+ p("div", null, [
27
+ p("button", {
28
+ onClick: r,
29
+ class: "text-sm h-[20px] text-blue-600 font-medium hover:border-b hover:border-b-2 hover:border-b-blue-500"
30
+ }, " До таблиці "),
31
+ p("h2", S, j(t.title), 1)
32
+ ]),
33
+ p("div", G, [
34
+ z(b, {
35
+ to: u.value,
36
+ 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"
37
+ }, {
38
+ default: B(() => h[0] || (h[0] = [
39
+ N(" Редагувати ")
40
+ ])),
41
+ _: 1
42
+ }, 8, ["to"])
43
+ ])
44
+ ]);
45
+ };
46
+ }
47
+ }, F = {
48
+ components: { AdminCardHeader: O },
49
+ data() {
50
+ return {
51
+ objectData: null,
52
+ component: ""
53
+ };
54
+ },
55
+ computed: {
56
+ getRoute() {
57
+ const t = this.flattenMenu(H.value);
58
+ t != null && t.length || this.$router.replace("/404");
59
+ const n = t == null ? void 0 : t.find((c) => {
60
+ var l, r;
61
+ return (c == null ? void 0 : c.table) == ((r = (l = this.$route) == null ? void 0 : l.params) == null ? void 0 : r.table);
62
+ });
63
+ return n || this.$router.replace("/404"), n == null ? void 0 : n.path;
64
+ },
65
+ getTitle() {
66
+ var t, n, c, l, r, u, d, h, b, o, i, C, e, k, _;
67
+ if ((c = (n = (t = this.objectData) == null ? void 0 : t.rows) == null ? void 0 : n[0]) != null && c.name)
68
+ return ((d = (u = (r = (l = this.objectData) == null ? void 0 : l.rows) == null ? void 0 : r[0]) == null ? void 0 : u.name) == null ? void 0 : d.length) < 35 ? (o = (b = (h = this.objectData) == null ? void 0 : h.rows) == null ? void 0 : b[0]) == null ? void 0 : o.name : ((k = (e = (C = (i = this.objectData) == null ? void 0 : i.rows) == null ? void 0 : C[0]) == null ? void 0 : e.name) == null ? void 0 : k.slice(0, 35)) + " ...";
69
+ {
70
+ const x = (_ = this.flattenMenu(H.value)) == null ? void 0 : _.find(
71
+ (g) => {
72
+ var f, y;
73
+ return (g == null ? void 0 : g.table) === ((y = (f = this.$route) == null ? void 0 : f.params) == null ? void 0 : y.table);
74
+ }
75
+ );
76
+ return x == null ? void 0 : x.ua;
77
+ }
78
+ }
79
+ },
80
+ async mounted() {
81
+ await this.getObjectData(), await this.checkActiveComponent();
82
+ },
83
+ watch: {
84
+ component(t) {
85
+ this.$router.replace({ ...this.$route, query: { tab: t } });
86
+ }
87
+ },
88
+ methods: {
89
+ async getObjectData() {
90
+ var c;
91
+ const { table: t, id: n } = (c = this.$route) == null ? void 0 : c.params;
92
+ (!t || !n) && this.$router.replace("/404");
93
+ try {
94
+ const { data: l } = await A.get(`/api/table-data/${t}/${n}`);
95
+ this.objectData = l;
96
+ } catch (l) {
97
+ console.error(l);
98
+ }
99
+ },
100
+ getColClass(t) {
101
+ return `col-span-${t || 12}`;
102
+ },
103
+ getGridClass() {
104
+ return "grid-cols-12";
105
+ },
106
+ checkActiveComponent() {
107
+ var t, n, c, l, r, u, d, h, b;
108
+ if ((n = (t = this.$route) == null ? void 0 : t.query) != null && n.tab)
109
+ this.component = (l = (c = this.$route) == null ? void 0 : c.query) == null ? void 0 : l.tab;
110
+ else {
111
+ const o = (u = (r = this.objectData) == null ? void 0 : r.panels) == null ? void 0 : u.find((i) => (i == null ? void 0 : i.type) === "tabs");
112
+ (d = o == null ? void 0 : o.items) != null && d.length && (this.component = ((h = o.items[0]) == null ? void 0 : h.component) || ((b = o.items[0]) == null ? void 0 : b.name));
113
+ }
114
+ },
115
+ flattenMenu(t) {
116
+ const n = [];
117
+ return t.forEach((c) => {
118
+ c.menu ? n.push(...this.flattenMenu(c.menu)) : n.push(c);
119
+ }), n;
120
+ }
121
+ }
122
+ }, I = {
123
+ style: { width: "calc(100vw - 260px)", height: "calc(100vh - 60px)" },
124
+ class: "p-4 overflow-y-auto bg-gray-50"
125
+ }, P = {
126
+ key: 0,
127
+ class: "bg-white border rounded-xl"
128
+ }, J = { class: "p-[10px] pl-[20px] text-xl" }, K = ["innerHTML"], Q = { key: 1 }, U = { class: "p-[10px] pl-[20px] text-xl" }, W = {
129
+ key: 0,
130
+ class: "p-[20px] border-t"
131
+ }, X = {
132
+ key: 1,
133
+ class: "p-[20px] border-t"
134
+ }, Y = ["innerHTML"], Z = { class: "flex space-x-1 w-full bg-white border border-b-0 rounded-tr-xl rounded-tl-xl h-[60px] items-center pl-[20px]" }, ee = ["onClick"], te = {
135
+ key: 0,
136
+ class: "bg-white border border-t-0 rounded-bl-xl rounded-br-xl"
137
+ }, oe = {
138
+ key: 0,
139
+ class: "p-[20px] border-t"
140
+ }, re = {
141
+ key: 1,
142
+ class: "p-[20px] border-t"
143
+ }, ne = ["innerHTML"];
144
+ function se(t, n, c, l, r, u) {
145
+ var h, b;
146
+ const d = $("AdminCardHeader");
147
+ return s(), a("div", I, [
148
+ ((h = r.objectData) == null ? void 0 : h.isHeader) !== !1 ? (s(), m(d, {
149
+ key: 0,
150
+ title: u.getTitle,
151
+ "get-route": u.getRoute
152
+ }, null, 8, ["title", "get-route"])) : v("", !0),
153
+ p("div", {
154
+ class: M(["grid gap-[20px]", u.getGridClass()])
155
+ }, [
156
+ (s(!0), a(w, null, D((b = r.objectData) == null ? void 0 : b.panels, (o, i) => {
157
+ var C;
158
+ return s(), a("div", {
159
+ key: i,
160
+ class: M(u.getColClass(o.col))
161
+ }, [
162
+ o != null && o.name ? (s(), a("div", P, [
163
+ p("h2", J, j((o == null ? void 0 : o.title) || "Панель"), 1),
164
+ p("div", {
165
+ class: "p-[20px] border-t",
166
+ innerHTML: (C = r.objectData) == null ? void 0 : C.data[o == null ? void 0 : o.name]
167
+ }, null, 8, K)
168
+ ])) : o.type === "container" ? (s(), a("div", Q, [
169
+ (s(!0), a(w, null, D(o.items, (e, k) => {
170
+ var _, x, g, f, y;
171
+ return s(), a("div", {
172
+ key: k,
173
+ class: "border rounded-xl bg-white mb-[20px]"
174
+ }, [
175
+ p("h2", U, j((e == null ? void 0 : e.title) || "Панель"), 1),
176
+ e != null && e.component ? (s(), a("div", W, [
177
+ (s(), m(T(e.component), {
178
+ geometry: (x = (_ = r.objectData) == null ? void 0 : _.rows[0]) == null ? void 0 : x.geom,
179
+ zoom: 16,
180
+ id: (f = (g = t.$route) == null ? void 0 : g.params) == null ? void 0 : f.id
181
+ }, null, 8, ["geometry", "id"]))
182
+ ])) : v("", !0),
183
+ e != null && e.name ? (s(), a("div", X, [
184
+ p("div", {
185
+ innerHTML: (y = r.objectData) == null ? void 0 : y.data[e == null ? void 0 : e.name]
186
+ }, null, 8, Y)
187
+ ])) : v("", !0)
188
+ ]);
189
+ }), 128))
190
+ ])) : v("", !0),
191
+ (o == null ? void 0 : o.type) === "tabs" ? (s(), a(w, { key: 2 }, [
192
+ p("nav", Z, [
193
+ (s(!0), a(w, null, D(o == null ? void 0 : o.items, (e) => (s(), a("button", {
194
+ key: (e == null ? void 0 : e.name) || (e == null ? void 0 : e.component),
195
+ onClick: (k) => r.component = (e == null ? void 0 : e.component) || (e == null ? void 0 : e.name),
196
+ class: M(["px-2.5 h-[30px] py-1.5 relative inline-flex items-center gap-x-2 text-gray-500 hover:bg-gray-100 focus:bg-gray-100 hover:text-gray-800 text-sm whitespace-nowrap rounded-lg focus:outline-none", {
197
+ " font-semibold after:absolute after:bottom-[-14px] after:left-2.5 after:right-2.5 after:z-10 after:h-0.5 after:bg-gray-800": r.component === (e == null ? void 0 : e.component) || r.component === (e == null ? void 0 : e.name),
198
+ "": r.component !== (e == null ? void 0 : e.component) && r.component !== (e == null ? void 0 : e.name)
199
+ }])
200
+ }, j(e == null ? void 0 : e.title), 11, ee))), 128))
201
+ ]),
202
+ (s(!0), a(w, null, D(o.items, (e, k) => {
203
+ var _, x, g, f, y;
204
+ return s(), a(w, { key: k }, [
205
+ r.component === (e == null ? void 0 : e.component) || r.component === (e == null ? void 0 : e.name) ? (s(), a("div", te, [
206
+ e != null && e.component ? (s(), a("div", oe, [
207
+ (s(), m(T(e.component), {
208
+ geometry: (x = (_ = r.objectData) == null ? void 0 : _.rows[0]) == null ? void 0 : x.geom,
209
+ zoom: 16,
210
+ id: (f = (g = t.$route) == null ? void 0 : g.params) == null ? void 0 : f.id
211
+ }, null, 8, ["geometry", "id"]))
212
+ ])) : v("", !0),
213
+ e != null && e.name ? (s(), a("div", re, [
214
+ p("div", {
215
+ innerHTML: (y = r.objectData) == null ? void 0 : y.data[e == null ? void 0 : e.name]
216
+ }, null, 8, ne)
217
+ ])) : v("", !0)
218
+ ])) : v("", !0)
219
+ ], 64);
220
+ }), 128))
221
+ ], 64)) : v("", !0)
222
+ ], 2);
223
+ }), 128))
224
+ ], 2)
225
+ ]);
226
+ }
227
+ const le = /* @__PURE__ */ V(F, [["render", se], ["__scopeId", "data-v-274c6efe"]]);
228
+ export {
229
+ le as default
230
+ };
@@ -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-z-nSvLVJ.js";
2
+ import { _ as c } from "./import-file-DgJqxKyF.js";
3
3
  const n = {};
4
4
  function s(_, p, a, i, f, m) {
5
5
  const o = e("router-view");
@@ -0,0 +1,103 @@
1
+ import { _ as b, u as h, a as c } from "./import-file-DgJqxKyF.js";
2
+ import { resolveComponent as d, openBlock as m, createElementBlock as p, createElementVNode as l, createBlock as f, createCommentVNode as g } from "vue";
3
+ const x = {
4
+ data() {
5
+ return {
6
+ formValues: {},
7
+ scheme: null,
8
+ table: ""
9
+ };
10
+ },
11
+ mounted() {
12
+ this.getFormScheme();
13
+ },
14
+ methods: {
15
+ flattenMenu(t) {
16
+ const e = [];
17
+ return t.forEach((r) => {
18
+ r.menu ? e.push(...this.flattenMenu(r.menu)) : e.push(r);
19
+ }), e;
20
+ },
21
+ async getFormScheme() {
22
+ var u, a;
23
+ const t = this.flattenMenu(h.value);
24
+ t != null && t.length || this.$router.replace("/404");
25
+ const e = t == null ? void 0 : t.find((o) => {
26
+ var n, s;
27
+ return (o == null ? void 0 : o.path) == ((s = (n = this.$route) == null ? void 0 : n.query) == null ? void 0 : s.table);
28
+ });
29
+ e || this.$router.replace("/404");
30
+ const r = e == null ? void 0 : e.table;
31
+ this.table = r;
32
+ try {
33
+ const {
34
+ data: { token: o, form: n }
35
+ } = await c.get(`/api/template/table/${r}`), {
36
+ data: s
37
+ } = await c.get(
38
+ `/api/table/${this.table}/${(a = (u = this.$route) == null ? void 0 : u.query) == null ? void 0 : a.id}`
39
+ );
40
+ this.formValues = s;
41
+ const { data: i } = await c.get(`/api/template/form/${o || n}`);
42
+ this.scheme = (i == null ? void 0 : i.schema) || i;
43
+ } catch {
44
+ }
45
+ },
46
+ async editObject() {
47
+ var t, e;
48
+ try {
49
+ await this.$refs.form.doValidation(), await c.put(
50
+ `/api/table/${this.table}/${(e = (t = this.$route) == null ? void 0 : t.query) == null ? void 0 : e.id}`,
51
+ this.formValues
52
+ ), await this.$router.back(), await this.$notify({
53
+ title: "Успішно!",
54
+ message: "Об'єкт успішно створено",
55
+ type: "success"
56
+ });
57
+ } catch {
58
+ this.$notify({
59
+ title: "Помилка!",
60
+ message: "Сталася помилка",
61
+ type: "error"
62
+ });
63
+ }
64
+ }
65
+ }
66
+ }, w = { style: { width: "calc(100vw - 260px)" } }, y = { class: "h-[76px] bg-gray-50 flex items-center justify-between px-[30px]" }, k = { class: "flex items-center gap-[6px]" }, v = {
67
+ style: { height: "calc(100vh - 140px)", width: "calc(100vw - 260px)" },
68
+ class: "bg-gray-50 p-[20px] flex"
69
+ }, $ = { 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" };
70
+ function V(t, e, r, u, a, o) {
71
+ const n = d("VsForm");
72
+ return m(), p("div", w, [
73
+ l("div", y, [
74
+ e[3] || (e[3] = l("h2", { class: "text-xl font-medium" }, "Редагувати", -1)),
75
+ l("div", k, [
76
+ l("button", {
77
+ onClick: e[0] || (e[0] = (s) => t.$router.back()),
78
+ class: "py-2 px-3 flex items-center gap-x-2 text-sm font-medium rounded-lg border bg-white border-gray-100 text-gray-800 shadow focus:outline-none hover:bg-gray-50 hover:border-gray-100 duration-300"
79
+ }, " Скасувати "),
80
+ l("button", {
81
+ onClick: e[1] || (e[1] = (...s) => o.editObject && o.editObject(...s)),
82
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"
83
+ }, " Зберегти ")
84
+ ])
85
+ ]),
86
+ l("div", v, [
87
+ l("div", $, [
88
+ a.scheme ? (m(), f(n, {
89
+ key: 0,
90
+ ref: "form",
91
+ scheme: a.scheme,
92
+ modelValue: a.formValues,
93
+ "onUpdate:modelValue": e[2] || (e[2] = (s) => a.formValues = s),
94
+ class: "p-0 mt-[20px]"
95
+ }, null, 8, ["scheme", "modelValue"])) : g("", !0)
96
+ ])
97
+ ])
98
+ ]);
99
+ }
100
+ const C = /* @__PURE__ */ b(x, [["render", V]]);
101
+ export {
102
+ C as default
103
+ };