@opengis/admin 0.1.59 → 0.1.61

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,896 @@
1
+ import { _ as m, a as v } from "./import-file-bdYAo8iW.js";
2
+ import { u as F } from "./userMenu-CT1xO2Pt.js";
3
+ import { openBlock as a, createElementBlock as i, createStaticVNode as j, createTextVNode as k, toDisplayString as $, createCommentVNode as I, createElementVNode as r, Fragment as x, resolveComponent as d, createVNode as p, withCtx as y, withModifiers as O, renderList as w, withDirectives as E, vModelCheckbox as N, createBlock as M, vModelText as R, resolveDynamicComponent as W, Transition as G, vShow as J } from "vue";
4
+ const K = {}, Q = {
5
+ xmlns: "http://www.w3.org/2000/svg",
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ stroke: "currentColor",
9
+ "stroke-width": "2",
10
+ "stroke-linecap": "round",
11
+ "stroke-linejoin": "round",
12
+ class: "icon icon-tabler icons-tabler-outline icon-tabler-adjustments-horizontal"
13
+ };
14
+ function X(e, t, n, l, s, o) {
15
+ return a(), i("svg", Q, t[0] || (t[0] = [
16
+ j('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M4 6l8 0"></path><path d="M16 6l4 0"></path><path d="M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M4 12l2 0"></path><path d="M10 12l10 0"></path><path d="M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M4 18l11 0"></path><path d="M19 18l1 0"></path>', 10)
17
+ ]));
18
+ }
19
+ const Y = /* @__PURE__ */ m(K, [["render", X]]), Z = {
20
+ data() {
21
+ return {
22
+ currentSort: ""
23
+ };
24
+ },
25
+ props: {
26
+ data: {
27
+ type: Object,
28
+ default: () => null
29
+ },
30
+ activeColumn: { type: String }
31
+ },
32
+ computed: {
33
+ label() {
34
+ var e, t;
35
+ return ((e = this.data) == null ? void 0 : e.ua) || ((t = this.data) == null ? void 0 : t.label) || this.data.title || "null";
36
+ },
37
+ selectedSortParam() {
38
+ var e, t;
39
+ return (t = (e = this.$route) == null ? void 0 : e.query) == null ? void 0 : t.sort;
40
+ },
41
+ getVisibleIcon() {
42
+ return this.data.format !== "image" && this.data.format !== "verify";
43
+ }
44
+ },
45
+ watch: {
46
+ activeColumn(e) {
47
+ e !== this.data.name && (this.currentSort = "");
48
+ }
49
+ },
50
+ methods: {
51
+ changeCurrentSort(e) {
52
+ switch (e) {
53
+ case "":
54
+ return "asc";
55
+ case "asc":
56
+ return "desc";
57
+ case "desc":
58
+ return "";
59
+ default:
60
+ return "";
61
+ }
62
+ },
63
+ handleClickSortBtn(e) {
64
+ this.$emit("change-active", this.data.name), this.currentSort = this.changeCurrentSort(e);
65
+ const t = this.$route.query, { sort: n, ...l } = t, s = this.currentSort ? `${this.data.name}-${this.currentSort}` : "";
66
+ this.$router.replace({
67
+ query: {
68
+ ...l,
69
+ ...s && { sort: s }
70
+ }
71
+ });
72
+ },
73
+ isValueEqualToSelected(e) {
74
+ return `${this.data.name}-${e}` === this.selectedSortParam;
75
+ }
76
+ }
77
+ }, tt = {
78
+ scope: "col",
79
+ class: "min-w-[200px] max-w-[300px] text-start"
80
+ }, et = {
81
+ class: "flex-shrink-0 size-3.5",
82
+ xmlns: "http://www.w3.org/2000/svg",
83
+ width: "24",
84
+ height: "24",
85
+ viewBox: "0 0 24 24",
86
+ fill: "none",
87
+ stroke: "currentColor",
88
+ "stroke-width": "2",
89
+ "stroke-linecap": "round",
90
+ "stroke-linejoin": "round"
91
+ }, rt = {
92
+ key: 0,
93
+ d: "m7 15 5 5 5-5"
94
+ }, nt = {
95
+ key: 1,
96
+ d: "m7 9 5-5 5 5"
97
+ }, st = {
98
+ key: 1,
99
+ class: "text-sm text-gray-800 px-[4px] py-2.5 text-start font-normal text-gray-500"
100
+ };
101
+ function ot(e, t, n, l, s, o) {
102
+ return a(), i("th", tt, [
103
+ o.getVisibleIcon ? (a(), i("button", {
104
+ key: 0,
105
+ type: "button",
106
+ class: "text-sm text-gray-800 px-[4px] py-2.5 text-start font-normal text-gray-500 flex items-center gap-[6px]",
107
+ onClick: t[0] || (t[0] = (b) => o.handleClickSortBtn(s.currentSort))
108
+ }, [
109
+ k($(o.label) + " ", 1),
110
+ (a(), i("svg", et, [
111
+ s.currentSort === "asc" || s.currentSort === "" ? (a(), i("path", rt)) : I("", !0),
112
+ s.currentSort === "desc" || s.currentSort === "" ? (a(), i("path", nt)) : I("", !0)
113
+ ]))
114
+ ])) : (a(), i("p", st, $(o.label), 1))
115
+ ]);
116
+ }
117
+ const lt = /* @__PURE__ */ m(Z, [["render", ot]]), at = {}, it = {
118
+ xmlns: "http://www.w3.org/2000/svg",
119
+ viewBox: "0 0 24 24",
120
+ fill: "none",
121
+ stroke: "currentColor",
122
+ "stroke-width": "2",
123
+ "stroke-linecap": "round",
124
+ "stroke-linejoin": "round",
125
+ class: "icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
126
+ };
127
+ function ut(e, t, n, l, s, o) {
128
+ return a(), i("svg", it, t[0] || (t[0] = [
129
+ r("path", {
130
+ stroke: "none",
131
+ d: "M0 0h24v24H0z",
132
+ fill: "none"
133
+ }, null, -1),
134
+ r("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
135
+ r("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
136
+ r("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
137
+ ]));
138
+ }
139
+ const ct = /* @__PURE__ */ m(at, [["render", ut]]), dt = {}, pt = {
140
+ class: "flex-shrink-0 size-3.5",
141
+ xmlns: "http://www.w3.org/2000/svg",
142
+ viewBox: "0 0 24 24",
143
+ fill: "none",
144
+ stroke: "currentColor",
145
+ "stroke-width": "2",
146
+ "stroke-linecap": "round",
147
+ "stroke-linejoin": "round"
148
+ };
149
+ function ht(e, t, n, l, s, o) {
150
+ return a(), i("svg", pt, t[0] || (t[0] = [
151
+ j('<path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" x2="10" y1="11" y2="17"></line><line x1="14" x2="14" y1="11" y2="17"></line>', 5)
152
+ ]));
153
+ }
154
+ const bt = /* @__PURE__ */ m(dt, [["render", ht]]), mt = {
155
+ props: {
156
+ height: { type: String, default: "16" },
157
+ width: { type: String, default: "12" },
158
+ color: { type: String, default: "black" }
159
+ }
160
+ }, gt = { style: { display: "none" } }, ft = ["height", "width", "fill"];
161
+ function xt(e, t, n, l, s, o) {
162
+ return a(), i(x, null, [
163
+ (a(), i("svg", gt, t[0] || (t[0] = [
164
+ r("symbol", {
165
+ id: "icon-pencil",
166
+ viewBox: "0 0 32 32"
167
+ }, [
168
+ r("path", { d: "M27 0c2.761 0 5 2.239 5 5 0 1.126-0.372 2.164-1 3l-2 2-7-7 2-2c0.836-0.628 1.874-1 3-1zM2 23l-2 9 9-2 18.5-18.5-7-7-18.5 18.5zM22.362 11.362l-14 14-1.724-1.724 14-14 1.724 1.724z" })
169
+ ], -1)
170
+ ]))),
171
+ (a(), i("svg", {
172
+ height: n.height,
173
+ width: n.width,
174
+ fill: n.color
175
+ }, t[1] || (t[1] = [
176
+ r("use", { "xlink:href": "#icon-pencil" }, null, -1)
177
+ ]), 8, ft))
178
+ ], 64);
179
+ }
180
+ const yt = /* @__PURE__ */ m(mt, [["render", xt]]), _t = {
181
+ components: {
182
+ IconMore: ct,
183
+ IconDelete: bt,
184
+ IconEdit: yt
185
+ },
186
+ emits: ["updateTable"],
187
+ props: { item: Object, table: String },
188
+ data() {
189
+ return {
190
+ formVisible: !1,
191
+ isDeleteConfirm: !1,
192
+ formValue: {},
193
+ top: 0,
194
+ left: 0
195
+ };
196
+ },
197
+ methods: {
198
+ openConfirm() {
199
+ this.isDeleteConfirm = !0, document.querySelector("body").click();
200
+ },
201
+ async getData() {
202
+ var e;
203
+ try {
204
+ const { data: t } = await v.get(
205
+ `/api/table/${this.table}/${(e = this.item) == null ? void 0 : e.id}`
206
+ );
207
+ this.formValue = t;
208
+ } catch (t) {
209
+ console.error(t);
210
+ }
211
+ },
212
+ doSomethingOnCancel() {
213
+ this.formVisible = !1;
214
+ },
215
+ async deleteElement() {
216
+ var e;
217
+ try {
218
+ v.delete(`/api/table/${this.table}/${(e = this.item) == null ? void 0 : e.id}`), this.$notify({
219
+ title: "Успішно!",
220
+ message: "Об`єкт успішно видалeно",
221
+ type: "success"
222
+ }), await this.$emit("update-table"), this.isDeleteConfirm = !1;
223
+ } catch {
224
+ this.$notify({
225
+ title: "Помилка!",
226
+ message: "Сталася помилка",
227
+ type: "error"
228
+ });
229
+ }
230
+ }
231
+ }
232
+ }, vt = { class: "hs-dropdown [--placement:bottom-right] inline-flex" }, kt = {
233
+ id: "hs-pro-dupc1",
234
+ type: "button",
235
+ class: "gap-x-2 p-2 rounded-lg hover:border-transparent focus:outline-none text-black hover:bg-gray-50"
236
+ }, wt = { class: "pt-[7px] pb-[7px] flex flex-col items-start" }, $t = { class: "p-4" }, Ct = { class: "mt-4 flex justify-end gap-x-3" };
237
+ function Tt(e, t, n, l, s, o) {
238
+ const b = d("IconMore"), u = d("IconEdit"), g = d("router-link"), f = d("IconDelete"), C = d("VsPopover"), A = d("VsDialog");
239
+ return a(), i(x, null, [
240
+ r("div", vt, [
241
+ p(C, {
242
+ trigger: "click",
243
+ placement: "left"
244
+ }, {
245
+ reference: y(() => [
246
+ r("button", kt, [
247
+ p(b, {
248
+ height: "16",
249
+ width: "16"
250
+ })
251
+ ])
252
+ ]),
253
+ default: y(() => {
254
+ var _, S, T;
255
+ return [
256
+ r("div", wt, [
257
+ p(g, {
258
+ to: `/edit?table=${(S = (_ = e.$route) == null ? void 0 : _.params) == null ? void 0 : S.catchAll}&id=${(T = n.item) == null ? void 0 : T.id}`,
259
+ class: "w-[100px] ml-[2px] flex items-center justify-center gap-x-3 rounded-lg text-[13px] text-gray-800"
260
+ }, {
261
+ default: y(() => [
262
+ p(u, { color: "#000" }),
263
+ t[4] || (t[4] = k(" Редагувати "))
264
+ ]),
265
+ _: 1
266
+ }, 8, ["to"]),
267
+ t[6] || (t[6] = r("div", { class: "h-[1px] w-[80%] bg-gray-200 ml-auto mr-auto mt-[10px] mb-[10px]" }, null, -1)),
268
+ r("button", {
269
+ onClick: t[0] || (t[0] = O((...V) => o.openConfirm && o.openConfirm(...V), ["stop"])),
270
+ type: "button",
271
+ class: "w-[100px] flex items-center justify-center gap-x-3 rounded-lg text-[14px] text-red-500"
272
+ }, [
273
+ p(f),
274
+ t[5] || (t[5] = r("span", { class: "text-gray-800" }, "Видалити", -1))
275
+ ])
276
+ ])
277
+ ];
278
+ }),
279
+ _: 1
280
+ })
281
+ ]),
282
+ p(A, {
283
+ visible: s.isDeleteConfirm,
284
+ "onUpdate:visible": t[3] || (t[3] = (_) => s.isDeleteConfirm = _),
285
+ title: "Ви впевнені?"
286
+ }, {
287
+ default: y(() => [
288
+ r("div", $t, [
289
+ t[7] || (t[7] = r("p", { class: "mt-1 text-gray-500 dark:text-neutral-500" }, " Ви впевнені, що хочете видалити цей об'єкт? ", -1)),
290
+ r("div", Ct, [
291
+ r("button", {
292
+ type: "button",
293
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",
294
+ onClick: t[1] || (t[1] = (_) => s.isDeleteConfirm = !1)
295
+ }, " Скасувати "),
296
+ r("button", {
297
+ type: "button",
298
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",
299
+ onClick: t[2] || (t[2] = (..._) => o.deleteElement && o.deleteElement(..._))
300
+ }, " Так, я впевнена/ий ")
301
+ ])
302
+ ])
303
+ ]),
304
+ _: 1
305
+ }, 8, ["visible"])
306
+ ], 64);
307
+ }
308
+ const Mt = /* @__PURE__ */ m(_t, [["render", Tt]]), St = {}, Vt = {
309
+ class: "flex-shrink-0 mt-0.5 size-3.5",
310
+ xmlns: "http://www.w3.org/2000/svg",
311
+ viewBox: "0 0 24 24",
312
+ fill: "none",
313
+ stroke: "currentColor",
314
+ "stroke-width": "2",
315
+ "stroke-linecap": "round",
316
+ "stroke-linejoin": "round"
317
+ };
318
+ function Dt(e, t, n, l, s, o) {
319
+ return a(), i("svg", Vt, t[0] || (t[0] = [
320
+ r("path", { d: "m3 16 4 4 4-4" }, null, -1),
321
+ r("path", { d: "M7 20V4" }, null, -1),
322
+ r("path", { d: "m21 8-4-4-4 4" }, null, -1),
323
+ r("path", { d: "M17 4v16" }, null, -1)
324
+ ]));
325
+ }
326
+ const At = /* @__PURE__ */ m(St, [["render", Dt]]), Ft = {
327
+ props: {
328
+ columns: { type: Object, default: () => {
329
+ } },
330
+ table: { type: String, default: () => "" }
331
+ },
332
+ data() {
333
+ return {
334
+ tableFormats: ["json", "csv", "xlsx"],
335
+ format: "",
336
+ cols: []
337
+ };
338
+ },
339
+ methods: {
340
+ async exportTable() {
341
+ try {
342
+ const e = await v.get("/api/export", {
343
+ params: {
344
+ table: this.table,
345
+ format: this.format,
346
+ cols: this.cols.join(",")
347
+ },
348
+ responseType: "blob"
349
+ }), t = new Blob([e.data], {
350
+ type: "application/octet-stream"
351
+ }), n = window.URL.createObjectURL(t), l = document.createElement("a");
352
+ l.href = n, l.setAttribute(
353
+ "download",
354
+ `${this.table.split(".")[0]}.${this.format}`
355
+ ), document.body.appendChild(l), l.click(), document.body.removeChild(l), window.URL.revokeObjectURL(n), this.$notify({
356
+ type: "success",
357
+ title: "Експорт",
358
+ message: "Файл успішно експортовано!"
359
+ });
360
+ } catch (e) {
361
+ console.error("Ошибка при экспорте файла:", e), this.$notify({
362
+ type: "error",
363
+ title: "Помилка",
364
+ message: "Не вдалося експортувати файл."
365
+ });
366
+ }
367
+ },
368
+ selectFormat(e) {
369
+ this.format = e;
370
+ }
371
+ }
372
+ }, It = { class: "p-4" }, Et = { class: "pb-5 mb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700" }, jt = { class: "mt-2 flex row flex-wrap gap-y-[5px] gap-x-[10px]" }, zt = { class: "pb-5 mb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700" }, Pt = { class: "mt-2 space-y-2" }, Bt = ["id", "onChange"], Ut = ["for"], Ht = { class: "pb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700" }, qt = { class: "text-center" };
373
+ function Lt(e, t, n, l, s, o) {
374
+ const b = d("VsCheckbox");
375
+ return a(), i(x, null, [
376
+ t[4] || (t[4] = r("div", { class: "dark:border-neutral-700" }, null, -1)),
377
+ r("div", It, [
378
+ r("div", Et, [
379
+ t[2] || (t[2] = r("label", { class: "text-sm text-gray-500 dark:text-neutral-500" }, " Виберіть стовпці таблиці для експорту: ", -1)),
380
+ r("div", jt, [
381
+ (a(!0), i(x, null, w(n.columns, (u, g) => (a(), i("div", {
382
+ class: "flex items-center",
383
+ key: g,
384
+ style: { width: "calc((100% - 10px) / 2)" }
385
+ }, [
386
+ p(b, {
387
+ class: "py-0 shrink-0 border-gray-300 rounded text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-500 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800",
388
+ modelValue: s.cols,
389
+ "onUpdate:modelValue": t[0] || (t[0] = (f) => s.cols = f),
390
+ value: u == null ? void 0 : u.name,
391
+ label: u == null ? void 0 : u.ua
392
+ }, null, 8, ["modelValue", "value", "label"])
393
+ ]))), 128))
394
+ ])
395
+ ]),
396
+ r("div", zt, [
397
+ t[3] || (t[3] = r("label", { class: "text-sm text-gray-500 dark:text-neutral-500" }, " Виберіть формат таблиці: ", -1)),
398
+ r("div", Pt, [
399
+ (a(!0), i(x, null, w(s.tableFormats, (u, g) => (a(), i("div", {
400
+ class: "flex items-center",
401
+ key: g
402
+ }, [
403
+ r("input", {
404
+ type: "radio",
405
+ name: "hs-pro-duecmfm",
406
+ class: "shrink-0 border-gray-300 rounded-full text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-500 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800",
407
+ id: u,
408
+ onChange: (f) => o.selectFormat(u)
409
+ }, null, 40, Bt),
410
+ r("label", {
411
+ for: u,
412
+ class: "text-sm text-gray-800 ms-3 dark:text-neutral-400"
413
+ }, " Формат " + $(u), 9, Ut)
414
+ ]))), 128))
415
+ ])
416
+ ]),
417
+ r("div", Ht, [
418
+ r("div", qt, [
419
+ r("button", {
420
+ type: "button",
421
+ class: "p-2 inline-flex items-center gap-x-2 text-xs font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:ring-2 focus:ring-blue-500",
422
+ onClick: t[1] || (t[1] = (...u) => o.exportTable && o.exportTable(...u))
423
+ }, " Завантажити таблицю ")
424
+ ])
425
+ ])
426
+ ])
427
+ ], 64);
428
+ }
429
+ const Ot = /* @__PURE__ */ m(Ft, [["render", Lt]]), Nt = {
430
+ components: { IconExport: At, AdminTableExportForm: Ot },
431
+ props: { table: String, columns: Array },
432
+ data() {
433
+ return {
434
+ isOpen: !1
435
+ };
436
+ }
437
+ };
438
+ function Rt(e, t, n, l, s, o) {
439
+ const b = d("IconExport"), u = d("AdminTableExportForm"), g = d("VsDialog");
440
+ return a(), i(x, null, [
441
+ r("button", {
442
+ onClick: t[0] || (t[0] = (f) => s.isOpen = !0),
443
+ class: "py-2 px-3 relative flex items-center gap-x-2 text-sm border focus:outline-none border-gray-100 font-medium rounded-lg text-gray-800 hover:border-gray-100 focus:border-gray-100 hover:bg-gray-50 shadow-sm duration-300"
444
+ }, [
445
+ p(b, {
446
+ height: "16",
447
+ width: "16"
448
+ }),
449
+ t[2] || (t[2] = k(" Експорт "))
450
+ ]),
451
+ p(g, {
452
+ visible: s.isOpen,
453
+ "onUpdate:visible": t[1] || (t[1] = (f) => s.isOpen = f),
454
+ title: "Експорт таблиці"
455
+ }, {
456
+ default: y(() => [
457
+ p(u, {
458
+ table: n.table,
459
+ columns: n.columns
460
+ }, null, 8, ["table", "columns"])
461
+ ]),
462
+ _: 1
463
+ }, 8, ["visible"])
464
+ ], 64);
465
+ }
466
+ const Wt = /* @__PURE__ */ m(Nt, [["render", Rt]]), Gt = {}, Jt = {
467
+ xmlns: "http://www.w3.org/2000/svg",
468
+ viewBox: "0 0 24 24",
469
+ fill: "none",
470
+ stroke: "currentColor",
471
+ "stroke-width": "2",
472
+ "stroke-linecap": "round",
473
+ "stroke-linejoin": "round",
474
+ class: "icon icon-tabler icons-tabler-outline icon-tabler-columns"
475
+ };
476
+ function Kt(e, t, n, l, s, o) {
477
+ return a(), i("svg", Jt, t[0] || (t[0] = [
478
+ j('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M4 6l5.5 0"></path><path d="M4 10l5.5 0"></path><path d="M4 14l5.5 0"></path><path d="M4 18l5.5 0"></path><path d="M14.5 6l5.5 0"></path><path d="M14.5 10l5.5 0"></path><path d="M14.5 14l5.5 0"></path><path d="M14.5 18l5.5 0"></path>', 9)
479
+ ]));
480
+ }
481
+ const Qt = /* @__PURE__ */ m(Gt, [["render", Kt]]), Xt = {
482
+ props: { column: Object },
483
+ emits: ["update-column"],
484
+ data() {
485
+ return {
486
+ value: !1
487
+ };
488
+ },
489
+ watch: {
490
+ value(e) {
491
+ this.$emit("update-column", { ...this.column, hidden: !e });
492
+ }
493
+ },
494
+ mounted() {
495
+ var e;
496
+ ((e = this.column) == null ? void 0 : e.hidden) !== !0 && (this.value = !0);
497
+ }
498
+ }, Yt = { class: "flex w-full gap-[8px] items-centr" };
499
+ function Zt(e, t, n, l, s, o) {
500
+ var b, u;
501
+ return a(), i("label", Yt, [
502
+ E(r("input", {
503
+ "onUpdate:modelValue": t[0] || (t[0] = (g) => s.value = g),
504
+ type: "checkbox"
505
+ }, null, 512), [
506
+ [N, s.value]
507
+ ]),
508
+ k(" " + $(((b = n.column) == null ? void 0 : b.ua) || ((u = n.column) == null ? void 0 : u.title)), 1)
509
+ ]);
510
+ }
511
+ const te = /* @__PURE__ */ m(Xt, [["render", Zt]]), ee = {
512
+ components: { IconColumns: Qt, AdminTableColumnsHiddenItem: te },
513
+ emits: ["update-columns"],
514
+ props: { columns: Array },
515
+ methods: {
516
+ updateColumn(e) {
517
+ const t = this.columns.findIndex((l) => (l == null ? void 0 : l.name) === (e == null ? void 0 : e.name)), n = this.columns;
518
+ n[t] = e, this.$emit("update-columns", [...n]);
519
+ }
520
+ }
521
+ }, re = { class: "py-2 px-3 flex items-center gap-x-2 text-sm border focus:outline-none border-gray-100 font-medium rounded-lg text-gray-800 hover:border-gray-100 focus:border-gray-100 hover:bg-gray-50 shadow-sm duration-300" }, ne = { class: "flex flex-col gap-[3px] h-[400px] w-[300px] 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" };
522
+ function se(e, t, n, l, s, o) {
523
+ const b = d("IconColumns"), u = d("AdminTableColumnsHiddenItem"), g = d("VsPopover");
524
+ return a(), M(g, {
525
+ trigger: "click",
526
+ placement: "bottom"
527
+ }, {
528
+ reference: y(() => [
529
+ r("button", re, [
530
+ p(b, {
531
+ height: "20",
532
+ width: "16"
533
+ })
534
+ ])
535
+ ]),
536
+ default: y(() => [
537
+ r("div", null, [
538
+ t[0] || (t[0] = r("h2", { class: "text-sm mb-[8px]" }, "Оберіть колонки, щоб приховати", -1)),
539
+ r("ul", ne, [
540
+ (a(!0), i(x, null, w(n.columns, (f, C) => (a(), i("li", { key: C }, [
541
+ p(u, {
542
+ column: f,
543
+ onUpdateColumn: o.updateColumn
544
+ }, null, 8, ["column", "onUpdateColumn"])
545
+ ]))), 128))
546
+ ])
547
+ ])
548
+ ]),
549
+ _: 1
550
+ });
551
+ }
552
+ const oe = /* @__PURE__ */ m(ee, [["render", se]]), le = {
553
+ props: { table: String },
554
+ components: {
555
+ IconFilter: Y,
556
+ AdminTableControl: Mt,
557
+ AdminTableExport: Wt,
558
+ AdminTableColumnsHidden: oe,
559
+ AdminTableColumn: lt
560
+ },
561
+ data() {
562
+ return {
563
+ tableData: {},
564
+ isFilters: !1,
565
+ filterScheme: [],
566
+ page: 1,
567
+ searchValue: "",
568
+ limit: 20,
569
+ filters: null,
570
+ activeColumn: ""
571
+ };
572
+ },
573
+ mounted() {
574
+ var e, t;
575
+ this.page = ((t = (e = this.$route) == null ? void 0 : e.query) == null ? void 0 : t.page) || 1, this.getTableData(), this.getFilters();
576
+ },
577
+ computed: {
578
+ defaultPage() {
579
+ var e, t;
580
+ return ((t = (e = this.$route) == null ? void 0 : e.query) == null ? void 0 : t.page) || 1;
581
+ },
582
+ getFilterScheme() {
583
+ var e;
584
+ return (e = this.tableData) == null ? void 0 : e.filters;
585
+ },
586
+ columns() {
587
+ var e, t;
588
+ return (t = (e = this.tableData) == null ? void 0 : e.columns) == null ? void 0 : t.filter((n) => (n == null ? void 0 : n.hidden) !== !0);
589
+ }
590
+ },
591
+ watch: {
592
+ async table() {
593
+ await this.getTableData();
594
+ },
595
+ searchValue() {
596
+ this.getTableData();
597
+ },
598
+ $route: {
599
+ handler(e, t) {
600
+ var n, l;
601
+ ((n = e == null ? void 0 : e.params) == null ? void 0 : n.catchAll) !== ((l = t == null ? void 0 : t.params) == null ? void 0 : l.catchAll) && (this.filterScheme = null, this.getFilters());
602
+ },
603
+ deep: !0
604
+ }
605
+ },
606
+ methods: {
607
+ async getTableData() {
608
+ var e, t;
609
+ try {
610
+ const { data: n } = await v.get(`/api/template/table/${this.table}`), l = await v.get(`/api/table-data/${this.table}`, {
611
+ params: {
612
+ page: this.page,
613
+ search: this.searchValue || null,
614
+ limit: this.limit,
615
+ filter: this.filters || null,
616
+ order: ((t = (e = this.$route) == null ? void 0 : e.query) == null ? void 0 : t.sort) || null
617
+ }
618
+ });
619
+ this.tableData = {
620
+ ...this.tableData,
621
+ ...n,
622
+ ...(l == null ? void 0 : l.data) || {}
623
+ };
624
+ } catch {
625
+ }
626
+ },
627
+ async getFilters() {
628
+ var e;
629
+ try {
630
+ const { data: t } = await v.get(`/api/table-filter/${this.table}`);
631
+ this.filterScheme = (e = t == null ? void 0 : t.list) == null ? void 0 : e.map((n) => ({
632
+ ...n,
633
+ label: (n == null ? void 0 : n.label) || (n == null ? void 0 : n.ua)
634
+ }));
635
+ } catch {
636
+ }
637
+ },
638
+ async handlePageChange(e) {
639
+ const t = this.$route.query;
640
+ this.page = e, !(!(t != null && t.page) && e === 1 || t.page === e) && (await this.$router.replace({ query: { ...t, page: e } }), await this.getTableData());
641
+ },
642
+ async changeLimit(e) {
643
+ this.limit = await e, this.defaultPage = 1, await this.getTableData();
644
+ },
645
+ closeFilter({ target: e }) {
646
+ this.isFilters && e.classList.contains("filter-container") && (this.isFilters = !1);
647
+ },
648
+ async filterChange({ url: e }) {
649
+ this.filters = e, this.page = 1, await this.getTableData();
650
+ },
651
+ changeActiveColumn(e) {
652
+ this.activeColumn = e, this.getTableData();
653
+ }
654
+ }
655
+ }, ae = { class: "w-[calc(100vw - 320px)]" }, ie = { class: "h-[58px] bg-gray-50 flex items-center justify-between px-[30px]" }, ue = { class: "text-xl font-medium" }, ce = {
656
+ style: { height: "calc(100vh - 60px)", width: "calc(100vw - 260px)" },
657
+ class: "bg-gray-50 p-[20px] flex"
658
+ }, de = { class: "bg-white w-full rounded-xl border p-[20px]" }, pe = { class: "flex sm:grid sm:grid-cols-2 gap-x-2 sm:gap-x-5 mb-[10px]" }, he = { class: "flex gap-[6px] ml-auto" }, be = { class: "space-y-5 flex items-start w-full justify-start" }, me = {
659
+ style: { height: "calc(100vh - 250px)" },
660
+ class: "overflow-x-auto w-full border-t [&::-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"
661
+ }, ge = { class: "inline-block align-middle" }, fe = { class: "divide-y divide-gray-200 dark:divide-neutral-700 relative" }, xe = { class: "sticky top-0 bg-white w-full relative after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200" }, ye = { class: "border-stone-200 z-[1]" }, _e = { class: "divide-y divide-gray-200" }, ve = { class: "size-px min-w-[200px] max-w-[300px] text-start pe-4 py-3 text-sm text-gray-600" }, ke = { class: "text-center sticky right-0 bg-white" }, we = { class: "p-[20px] flex justify-end w-full" }, $e = { class: "filter-content h-screen bg-white w-[400px] p-[20px] pt-[10px] overflow-x-auto bg-[rgba(0,0,0,0.5)] [&::-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" };
662
+ function Ce(e, t, n, l, s, o) {
663
+ var T, V, z, P, B, U, H;
664
+ const b = d("router-link"), u = d("AdminTableColumnsHidden"), g = d("AdminTableExport"), f = d("IconFilter"), C = d("AdminTableColumn"), A = d("AdminTableControl"), _ = d("VsPagination"), S = d("VsFilter");
665
+ return a(), i(x, null, [
666
+ r("div", ae, [
667
+ r("div", ie, [
668
+ r("h2", ue, $((T = s.tableData) == null ? void 0 : T.title), 1),
669
+ p(b, {
670
+ to: `/add?table=${(z = (V = e.$route) == null ? void 0 : V.params) == null ? void 0 : z.catchAll}`,
671
+ class: "py-2 px-3 flex items-center gap-x-2 text-sm text-white font-medium rounded-lg bg-blue-500 text-gray-800 shadow-sm hover:bg-blue-700 hover:text-white duration-300"
672
+ }, {
673
+ default: y(() => t[5] || (t[5] = [
674
+ k(" Додати ")
675
+ ])),
676
+ _: 1
677
+ }, 8, ["to"])
678
+ ]),
679
+ r("div", ce, [
680
+ r("div", de, [
681
+ r("div", pe, [
682
+ E(r("input", {
683
+ "onUpdate:modelValue": t[0] || (t[0] = (c) => s.searchValue = c),
684
+ class: "py-2 pl-[15px] h-[38px] w-[400px] block w-full border rounded-lg text-sm focus:border-blue-600 focus:border-[2px] outline-none",
685
+ placeholder: "Пошук..."
686
+ }, null, 512), [
687
+ [R, s.searchValue]
688
+ ]),
689
+ r("div", he, [
690
+ p(u, {
691
+ columns: (P = s.tableData) == null ? void 0 : P.columns,
692
+ onUpdateColumns: t[1] || (t[1] = (c) => s.tableData.columns = c)
693
+ }, null, 8, ["columns"]),
694
+ p(g, {
695
+ table: n.table,
696
+ columns: (B = s.tableData) == null ? void 0 : B.columns
697
+ }, null, 8, ["table", "columns"]),
698
+ r("button", {
699
+ onClick: t[2] || (t[2] = (c) => s.isFilters = !s.isFilters),
700
+ class: "py-2 px-3 flex items-center gap-x-2 text-sm border focus:outline-none border-gray-100 font-medium rounded-lg text-gray-800 hover:border-gray-100 focus:border-gray-100 hover:bg-gray-50 shadow-sm duration-300"
701
+ }, [
702
+ p(f, {
703
+ height: "16",
704
+ width: "16"
705
+ }),
706
+ t[6] || (t[6] = k(" Фільтри "))
707
+ ])
708
+ ])
709
+ ]),
710
+ r("div", be, [
711
+ r("div", me, [
712
+ r("div", ge, [
713
+ r("table", fe, [
714
+ r("thead", xe, [
715
+ r("tr", ye, [
716
+ (a(!0), i(x, null, w(o.columns, (c) => (a(), M(C, {
717
+ key: c.name,
718
+ data: c,
719
+ activeColumn: s.activeColumn,
720
+ onChangeActive: o.changeActiveColumn
721
+ }, null, 8, ["data", "activeColumn", "onChangeActive"]))), 128)),
722
+ t[7] || (t[7] = r("th", { class: "min-w-[70px] max-w-[70px] sticky right-0 top-0 bg-white" }, null, -1))
723
+ ])
724
+ ]),
725
+ r("tbody", _e, [
726
+ (a(!0), i(x, null, w((U = s.tableData) == null ? void 0 : U.rows, (c, D) => {
727
+ var q;
728
+ return a(), i("tr", { key: D }, [
729
+ r("td", ve, [
730
+ p(b, {
731
+ to: `/card/${n.table}/${c == null ? void 0 : c.id}`,
732
+ class: "text-sm text-green-600 decoration-2 hover:underline font-medium focus:outline-none focus:underline hover:text-green-600"
733
+ }, {
734
+ default: y(() => {
735
+ var h;
736
+ return [
737
+ k($(c == null ? void 0 : c[(h = o.columns[0]) == null ? void 0 : h.name]), 1)
738
+ ];
739
+ }),
740
+ _: 2
741
+ }, 1032, ["to"])
742
+ ]),
743
+ (a(!0), i(x, null, w((q = o.columns) == null ? void 0 : q.slice(1), (h) => {
744
+ var L;
745
+ return a(), i("td", {
746
+ class: "size-px min-w-[300px] max-w-[400px] text-start px-[4px] py-3 text-sm text-gray-600",
747
+ key: h.name
748
+ }, [
749
+ (a(), M(W(
750
+ (h == null ? void 0 : h.format) === "custom" ? h == null ? void 0 : h.component : e.$componentsConfig[`table-format-${((L = h == null ? void 0 : h.format) == null ? void 0 : L.toLowerCase()) || e.text}`]
751
+ ), {
752
+ name: h == null ? void 0 : h.name,
753
+ data: c,
754
+ value: c == null ? void 0 : c[h == null ? void 0 : h.name]
755
+ }, null, 8, ["name", "data", "value"]))
756
+ ]);
757
+ }), 128)),
758
+ r("td", ke, [
759
+ p(A, {
760
+ item: c,
761
+ table: n.table,
762
+ onUpdateTable: o.getTableData
763
+ }, null, 8, ["item", "table", "onUpdateTable"])
764
+ ])
765
+ ]);
766
+ }), 128))
767
+ ])
768
+ ])
769
+ ])
770
+ ])
771
+ ]),
772
+ r("div", we, [
773
+ p(_, {
774
+ goTo: !1,
775
+ class: "justify-end",
776
+ "default-page": o.defaultPage,
777
+ total: ((H = s.tableData) == null ? void 0 : H.total) || 0,
778
+ pageSize: s.limit,
779
+ onPageChange: o.handlePageChange,
780
+ pageSizes: [10, 16, 20],
781
+ onPageSizeChange: o.changeLimit
782
+ }, null, 8, ["default-page", "total", "pageSize", "onPageChange", "onPageSizeChange"])
783
+ ])
784
+ ])
785
+ ])
786
+ ]),
787
+ p(G, { name: "fade" }, {
788
+ default: y(() => {
789
+ var c;
790
+ return [
791
+ E(r("div", {
792
+ onClick: t[4] || (t[4] = (...D) => o.closeFilter && o.closeFilter(...D)),
793
+ style: { height: "100vh" },
794
+ class: "fixed filter-container top-0 flex justify-end items-center z-[2] right-0 left-0 bottom-0 bg-[rgba(0,0,0,0.5)]"
795
+ }, [
796
+ r("div", $e, [
797
+ (c = s.filterScheme) != null && c.length ? (a(), M(S, {
798
+ key: 0,
799
+ ref: "filter",
800
+ scheme: s.filterScheme,
801
+ layout: "default",
802
+ "apply-vue-router": "",
803
+ history: "",
804
+ name: "filter",
805
+ onFilterChange: o.filterChange,
806
+ closeFilterBtn: !0,
807
+ onFilterClose: t[3] || (t[3] = (D) => s.isFilters = !1)
808
+ }, null, 8, ["scheme", "onFilterChange"])) : I("", !0)
809
+ ])
810
+ ], 512), [
811
+ [J, s.isFilters]
812
+ ])
813
+ ];
814
+ }),
815
+ _: 1
816
+ })
817
+ ], 64);
818
+ }
819
+ const Te = /* @__PURE__ */ m(le, [["render", Ce]]), Me = {
820
+ components: { AdminTable: Te },
821
+ data() {
822
+ return {
823
+ table: !1,
824
+ interface: "",
825
+ title: ""
826
+ };
827
+ },
828
+ watch: {
829
+ $route: {
830
+ async handler() {
831
+ var e;
832
+ (e = F) != null && e.value || await this.getMenu(), await this.checkPageType();
833
+ },
834
+ deep: !0
835
+ },
836
+ title(e) {
837
+ e && (document.title = e);
838
+ }
839
+ },
840
+ async mounted() {
841
+ await this.checkPageType();
842
+ },
843
+ methods: {
844
+ flattenMenu(e) {
845
+ const t = [];
846
+ return e.forEach((n) => {
847
+ n.menu ? t.push(...this.flattenMenu(n.menu)) : t.push(n);
848
+ }), t;
849
+ },
850
+ async getMenu() {
851
+ try {
852
+ const { data: e } = await v.get("/api/user-menu");
853
+ F.value = e;
854
+ } catch {
855
+ }
856
+ },
857
+ async checkPageType() {
858
+ const e = this.flattenMenu(F.value);
859
+ e != null && e.length || this.$router.replace("/404");
860
+ const t = e == null ? void 0 : e.find((l) => {
861
+ var s, o;
862
+ return (l == null ? void 0 : l.path) == ((o = (s = this.$route) == null ? void 0 : s.params) == null ? void 0 : o.catchAll);
863
+ });
864
+ this.title = t == null ? void 0 : t.ua, t || this.$router.replace("/404");
865
+ const n = t == null ? void 0 : t.table;
866
+ this.table = n || !1, !n && this.getInterface();
867
+ },
868
+ async getInterface() {
869
+ var e, t;
870
+ try {
871
+ const { data: n } = await v.get(
872
+ `/api/template/interface/${((t = (e = this.$route) == null ? void 0 : e.params) == null ? void 0 : t.catchAll) || ""}`
873
+ );
874
+ this.interface = n || "";
875
+ } catch {
876
+ this.interface = "";
877
+ }
878
+ }
879
+ }
880
+ }, Se = {
881
+ key: 1,
882
+ class: "w-full"
883
+ }, Ve = ["innerHTML"];
884
+ function De(e, t, n, l, s, o) {
885
+ const b = d("AdminTable");
886
+ return s.table ? (a(), M(b, {
887
+ key: 0,
888
+ table: s.table
889
+ }, null, 8, ["table"])) : (a(), i("div", Se, [
890
+ r("div", { innerHTML: s.interface }, null, 8, Ve)
891
+ ]));
892
+ }
893
+ const Ee = /* @__PURE__ */ m(Me, [["render", De]]);
894
+ export {
895
+ Ee as default
896
+ };