@opengis/cms 0.0.51 → 0.0.52
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.
- package/dist/{ArticlesPage-BcR1hbds.js → ArticlesPage-Cddv2qte.js} +5 -5
- package/dist/{BuilderPage-CK_osM89.js → BuilderPage-BgcBJcw7.js} +158 -158
- package/dist/{CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-CnOe9ORD.js → CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-C-k8QGA-.js} +1 -1
- package/dist/{CollectionsPage-JfmrHNR_.js → CollectionsPage-d5MLIIAG.js} +3 -3
- package/dist/{CreateForm-BMOBeP4G.js → CreateForm-B0srHu5e.js} +2 -2
- package/dist/{EditCollectionPage-DtgvKGm-.js → EditCollectionPage-NUVatLkY.js} +65 -59
- package/dist/{EmptyData-DaZt_nAm.js → EmptyData-BSW20VKP.js} +5 -5
- package/dist/{MenuAddPage-Bf48Z-ah.js → MenuAddPage-Cn3JN04F.js} +3 -3
- package/dist/{MenuItemPage-BSwUW8tv.js → MenuItemPage-B0Th9EOe.js} +3 -3
- package/dist/{MenuPage-tJZtK46W.js → MenuPage-DQpD3IXx.js} +4 -4
- package/dist/{MonacoEditor.vue_vue_type_script_setup_true_lang-B1DrxmQX.js → MonacoEditor.vue_vue_type_script_setup_true_lang-CTKNG0qR.js} +2 -2
- package/dist/{UniversalTable.vue_vue_type_script_setup_true_lang-CJGTsd1V.js → UniversalTable.vue_vue_type_script_setup_true_lang-DW6O-xoY.js} +6 -6
- package/dist/{UniversalTablePagination.vue_vue_type_script_setup_true_lang-GYZd_gkA.js → UniversalTablePagination.vue_vue_type_script_setup_true_lang-DBIPBmpm.js} +4 -4
- package/dist/contentForm-C4Jp-FbQ.js +586 -0
- package/dist/{getField-C7EZs-YQ.js → getField-CKcz_b0t.js} +960 -933
- package/dist/index.js +10 -10
- package/dist/style.css +1 -1
- package/dist/{vuedraggable-CoAPPFYd.js → vuedraggable-mqqAYsch.js} +107 -107
- package/locales/en.json +6 -1
- package/locales/uk.json +4 -1
- package/package.json +4 -4
- package/server/functions/getContent.js +6 -15
- package/server/functions/getSearchData.js +2 -12
- package/server/functions/utils/mock.reply.js +56 -0
- package/server/routes/cms/controllers/getPermissions.js +15 -15
- package/server/routes/cms/controllers/listMedia.js +30 -3
- package/server/routes/cms/controllers/searchContent.js +2 -2
- package/server/routes/cms/controllers/setPermissions.js +49 -49
- package/server/templates/select/core.user_mentioned.sql +1 -1
- package/dist/contentForm-NcG15_5z.js +0 -553
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import { defineAsyncComponent as xe, useModel as ke, ref as y, provide as $e, onMounted as Y, nextTick as D, watch as K, computed as p, createBlock as re, createCommentVNode as z, openBlock as h, unref as _, createElementBlock as b, createElementVNode as d, createTextVNode as ie, createVNode as A, defineComponent as Se, inject as Ae, getCurrentInstance as Ce, toRef as Te, withDirectives as W, toDisplayString as L, Fragment as Ve, renderList as je, normalizeClass as ae, vModelCheckbox as Fe, vShow as oe } from "vue";
|
|
2
|
+
import { useRouter as ze, useRoute as Ne } from "vue-router";
|
|
3
|
+
import { ExternalLink as Ee, ArrowLeft as Pe, HelpCircle as Le, Settings as Ue, Save as Be } from "lucide-vue-next";
|
|
4
|
+
import { _ as Oe, a as De, V as Je, b as X, c as Me, d as Re, e as He, g as Ke } from "./getField-CKcz_b0t.js";
|
|
5
|
+
import { useI18n as ne } from "vue-i18n";
|
|
6
|
+
import { inputs as S, VForm as le } from "@opengis/form";
|
|
7
|
+
import { notify as U } from "@opengis/core";
|
|
8
|
+
import { _ as Ie } from "./CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-C-k8QGA-.js";
|
|
9
|
+
const qe = [
|
|
10
|
+
{
|
|
11
|
+
key: "title",
|
|
12
|
+
label: "cms.common.title",
|
|
13
|
+
localization: !0,
|
|
14
|
+
type: "text"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: "description",
|
|
18
|
+
label: "cms.common.description",
|
|
19
|
+
localization: !0,
|
|
20
|
+
type: "text"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: "keywords",
|
|
24
|
+
label: "cms.common.keywords",
|
|
25
|
+
localization: !0,
|
|
26
|
+
type: "text"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
key: "meta",
|
|
30
|
+
label: "cms.common.meta",
|
|
31
|
+
type: "key-value",
|
|
32
|
+
ignore: ["title", "description", "keywords"]
|
|
33
|
+
}
|
|
34
|
+
], Ge = {
|
|
35
|
+
__name: "VsFormTags",
|
|
36
|
+
props: {
|
|
37
|
+
modelValue: { default: () => [] },
|
|
38
|
+
modelModifiers: {}
|
|
39
|
+
},
|
|
40
|
+
emits: ["update:modelValue"],
|
|
41
|
+
setup($, { expose: i }) {
|
|
42
|
+
const C = xe(() => import("@opengis/form")), { t: w } = ne(), o = ke($, "modelValue"), g = y({}), u = y(!1);
|
|
43
|
+
$e("metaParentValue", o);
|
|
44
|
+
const f = (a) => Array.isArray(a) ? a.map((n) => typeof n == "object" && n !== null && n.id ? n.id : n) : [], T = async (a) => {
|
|
45
|
+
if (!Array.isArray(a) || a.length === 0)
|
|
46
|
+
return [];
|
|
47
|
+
try {
|
|
48
|
+
const x = await (await fetch("/api/tags")).json(), N = (x == null ? void 0 : x.rows) || [];
|
|
49
|
+
return a.map((M) => {
|
|
50
|
+
const V = N.find((R) => R.tag_id === M);
|
|
51
|
+
return V ? { id: V.tag_id, text: V.value, color: V.color } : { id: M, text: "", color: "#ababab" };
|
|
52
|
+
});
|
|
53
|
+
} catch (n) {
|
|
54
|
+
return console.error("Error fetching tags:", n), a.map((x) => ({ id: x, text: "", color: "#ababab" }));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
Y(async () => {
|
|
58
|
+
await D(), await D(), setTimeout(() => {
|
|
59
|
+
var a;
|
|
60
|
+
if (Array.isArray((a = o.value) == null ? void 0 : a.tag_list)) {
|
|
61
|
+
const n = f(o.value.tag_list);
|
|
62
|
+
JSON.stringify(n) !== JSON.stringify(o.value.tag_list) && (o.value.tag_list = n);
|
|
63
|
+
}
|
|
64
|
+
}, 100);
|
|
65
|
+
}), K(
|
|
66
|
+
() => o.value.tag_list,
|
|
67
|
+
(a) => {
|
|
68
|
+
if (Array.isArray(a) && !u.value) {
|
|
69
|
+
const n = f(a);
|
|
70
|
+
JSON.stringify(n) !== JSON.stringify(a) && (o.value.tag_list = n);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{ deep: !0 }
|
|
74
|
+
), K(
|
|
75
|
+
() => o.value,
|
|
76
|
+
(a) => {
|
|
77
|
+
if (a && Array.isArray(a.tag_list) && !u.value) {
|
|
78
|
+
const n = f(a.tag_list);
|
|
79
|
+
JSON.stringify(n) !== JSON.stringify(a.tag_list) && (a.tag_list = n);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{ deep: !0, immediate: !0 }
|
|
83
|
+
), K(
|
|
84
|
+
() => {
|
|
85
|
+
var a;
|
|
86
|
+
return (a = o.value) == null ? void 0 : a.tag_list;
|
|
87
|
+
},
|
|
88
|
+
(a) => {
|
|
89
|
+
Array.isArray(a) && g.value && D(() => {
|
|
90
|
+
g.value && g.value.setValue && g.value.setValue("tag_list", a);
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
{ deep: !0 }
|
|
94
|
+
);
|
|
95
|
+
const B = async (a) => {
|
|
96
|
+
if (a.tag_list && (a.tag_list = f(a.tag_list), o.value.tag_list = a.tag_list), await g.value.validate()) {
|
|
97
|
+
U({
|
|
98
|
+
type: "warning",
|
|
99
|
+
title: w("cms.common.actions.warning"),
|
|
100
|
+
message: w("cms.builder.editFieldFailed")
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
i({
|
|
106
|
+
restoreTagsBeforeSubmit: async () => {
|
|
107
|
+
var a;
|
|
108
|
+
if (u.value = !0, Array.isArray((a = o.value) == null ? void 0 : a.tag_list)) {
|
|
109
|
+
const n = await T(o.value.tag_list);
|
|
110
|
+
o.value.tag_list = n;
|
|
111
|
+
}
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
u.value = !1;
|
|
114
|
+
}, 2e3);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
const O = p(() => {
|
|
118
|
+
var a;
|
|
119
|
+
return [
|
|
120
|
+
{
|
|
121
|
+
key: "tag_list",
|
|
122
|
+
type: "select",
|
|
123
|
+
multiple: !0,
|
|
124
|
+
searchable: !1,
|
|
125
|
+
placeholder: w("cms.builder.tags"),
|
|
126
|
+
data: "tag_id",
|
|
127
|
+
value: ((a = o.value) == null ? void 0 : a.tag_list) || []
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
});
|
|
131
|
+
return (a, n) => o.value ? (h(), re(_(C), {
|
|
132
|
+
key: 0,
|
|
133
|
+
schema: O.value,
|
|
134
|
+
modelValue: o.value,
|
|
135
|
+
"onUpdate:modelValue": [
|
|
136
|
+
n[0] || (n[0] = (x) => o.value = x),
|
|
137
|
+
B
|
|
138
|
+
]
|
|
139
|
+
}, null, 8, ["schema", "modelValue"])) : z("", !0);
|
|
140
|
+
}
|
|
141
|
+
}, Qe = { class: "flex justify-end mb-4" }, We = ["href"], Xe = ["src"], Ye = ["src"], Ze = {
|
|
142
|
+
key: 2,
|
|
143
|
+
class: "w-full h-[80vh] flex items-center justify-center text-gray-500"
|
|
144
|
+
}, et = {
|
|
145
|
+
__name: "VsPreview",
|
|
146
|
+
props: {
|
|
147
|
+
preview_path: {
|
|
148
|
+
type: String,
|
|
149
|
+
default: ""
|
|
150
|
+
},
|
|
151
|
+
slug: {
|
|
152
|
+
type: String,
|
|
153
|
+
default: ""
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
setup($) {
|
|
157
|
+
const i = y(""), C = y(""), w = async () => {
|
|
158
|
+
var g, u;
|
|
159
|
+
try {
|
|
160
|
+
const T = await (await fetch("/api/settings")).json();
|
|
161
|
+
i.value = ((u = (g = T == null ? void 0 : T.settings) == null ? void 0 : g.site_info) == null ? void 0 : u.previewUrl) || "http://ip.local.softpro.ua";
|
|
162
|
+
} catch (f) {
|
|
163
|
+
console.error("Failed to fetch settings:", f), i.value = "http://ip.local.softpro.ua";
|
|
164
|
+
}
|
|
165
|
+
}, o = async () => {
|
|
166
|
+
var g;
|
|
167
|
+
try {
|
|
168
|
+
const f = await (await fetch("/user")).json();
|
|
169
|
+
C.value = (g = f == null ? void 0 : f.user) == null ? void 0 : g.draftKey;
|
|
170
|
+
} catch (u) {
|
|
171
|
+
console.error("Failed to fetch user:", u);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
return Y(() => {
|
|
175
|
+
w(), o();
|
|
176
|
+
}), (g, u) => (h(), b("div", null, [
|
|
177
|
+
d("div", Qe, [
|
|
178
|
+
d("a", {
|
|
179
|
+
href: `${i.value}/uk/${$.preview_path}${$.slug}${C.value ? `?draftKey=${C.value}` : ""}`,
|
|
180
|
+
target: "_blank",
|
|
181
|
+
class: "inline-flex items-center gap-2 px-3 py-1.5 text-black-600 bg-white border border-blue-200 rounded hover:border-blue-300 hover:bg-blue-50 transition-colors duration-200 font-normal cursor-pointer"
|
|
182
|
+
}, [
|
|
183
|
+
u[0] || (u[0] = ie(" Переглянути на сайті ", -1)),
|
|
184
|
+
A(_(Ee), { class: "w-4 h-4" })
|
|
185
|
+
], 8, We)
|
|
186
|
+
]),
|
|
187
|
+
i.value && $.preview_path ? (h(), b("iframe", {
|
|
188
|
+
key: 0,
|
|
189
|
+
src: `${i.value}/uk/${$.preview_path}${$.slug}?hideHeader=true&hideFooter=true`,
|
|
190
|
+
class: "w-full h-[80vh]"
|
|
191
|
+
}, null, 8, Xe)) : i.value ? (h(), b("iframe", {
|
|
192
|
+
key: 1,
|
|
193
|
+
src: `${i.value}/uk/${$.slug}?hideHeader=true&hideFooter=true`,
|
|
194
|
+
class: "w-full h-[80vh]"
|
|
195
|
+
}, null, 8, Ye)) : (h(), b("div", Ze, " Loading preview... "))
|
|
196
|
+
]));
|
|
197
|
+
}
|
|
198
|
+
}, tt = { class: "space-y-6 mx-auto relativ max-w-[90%]" }, st = { class: "" }, at = { class: "flex items-center justify-between" }, ot = { class: "flex items-center gap-4" }, lt = { class: "text-2xl font-semibold text-gray-900 dark:text-white line-clamp-1" }, rt = ["href", "title"], it = { class: "flex items-center space-x-3" }, nt = ["title"], ct = { class: "w-full mt-6 flex items-center justify-between" }, ut = { class: "flex items-center w-full h-10 max-w-md grid-cols-3 p-1 bg-white border border-gray-200 rounded-md text-muted-foreground" }, dt = ["onClick"], mt = { class: "flex items-center gap-4" }, vt = { class: "flex items-center gap-2" }, pt = {
|
|
199
|
+
for: "is_pin",
|
|
200
|
+
class: "text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer"
|
|
201
|
+
}, ft = { class: "relative" }, gt = {
|
|
202
|
+
key: 0,
|
|
203
|
+
class: "w-3 h-3 text-white",
|
|
204
|
+
fill: "currentColor",
|
|
205
|
+
viewBox: "0 0 20 20"
|
|
206
|
+
}, yt = { class: "mx-auto bg-white rounded-md p-5" }, ht = { class: "mx-auto bg-white rounded-md p-5" }, bt = {
|
|
207
|
+
key: 0,
|
|
208
|
+
class: "mx-auto bg-white rounded-md p-5"
|
|
209
|
+
}, wt = {
|
|
210
|
+
key: 1,
|
|
211
|
+
class: "mx-auto bg-white rounded-md p-5"
|
|
212
|
+
}, Vt = /* @__PURE__ */ Se({
|
|
213
|
+
__name: "contentForm",
|
|
214
|
+
setup($) {
|
|
215
|
+
S["vs-input-custom-datatable"] = Oe, S["vs-input-reference"] = De, S["vs-input-texteditor"] = Je, S["vs-input-mediaselect"] = X, S["vs-input-file"] = X, S["vs-input-image"] = X, S["vs-input-richtext-md"] = Me, S["vs-input-integer"] = Re, S["vs-input-relation-link"] = He;
|
|
216
|
+
const { t: i, locale: C } = ne(), w = ze(), o = Ne(), g = Ae("menu", y([])), u = y([]), f = y({}), T = y({}), B = y({}), J = y(""), O = Ce(), a = O == null ? void 0 : O.appContext, n = (a == null ? void 0 : a.config.globalProperties) || {}, x = Te(n, "$settings"), N = p(() => {
|
|
217
|
+
var e;
|
|
218
|
+
return ((e = x.value) == null ? void 0 : e.cms) || {};
|
|
219
|
+
}), M = p(() => Array.isArray(N.value.locales) ? N.value.locales : []), V = p(
|
|
220
|
+
() => M.value.filter(Boolean)
|
|
221
|
+
), R = p(
|
|
222
|
+
() => N.value.locale || V.value[0] || "uk"
|
|
223
|
+
);
|
|
224
|
+
K(
|
|
225
|
+
x,
|
|
226
|
+
() => {
|
|
227
|
+
u.value.length && (u.value = u.value.map((e) => ({
|
|
228
|
+
...e
|
|
229
|
+
})));
|
|
230
|
+
},
|
|
231
|
+
{ deep: !0 }
|
|
232
|
+
);
|
|
233
|
+
const ce = (e) => {
|
|
234
|
+
const t = [], r = V.value.filter(
|
|
235
|
+
(l) => l !== R.value
|
|
236
|
+
);
|
|
237
|
+
return Array.isArray(e) && e.forEach((l) => {
|
|
238
|
+
t.push(l), !(!l.localization || r.length === 0) && r.forEach((s) => {
|
|
239
|
+
t.push({
|
|
240
|
+
...l,
|
|
241
|
+
name: `${l.name}:${s}`,
|
|
242
|
+
label: `${l.label} (${s})`
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}), t;
|
|
246
|
+
}, Z = p(() => ce(u.value)), ue = p(
|
|
247
|
+
() => Array.isArray(u.value) && u.value.some(
|
|
248
|
+
(e) => e.localization === !0 && e.name !== "title"
|
|
249
|
+
)
|
|
250
|
+
), de = p(() => {
|
|
251
|
+
var e;
|
|
252
|
+
return (e = Z.value) == null ? void 0 : e.map(Ke);
|
|
253
|
+
}), me = p(() => {
|
|
254
|
+
C.value;
|
|
255
|
+
const e = V.value.filter(
|
|
256
|
+
(t) => t !== R.value
|
|
257
|
+
);
|
|
258
|
+
return qe.flatMap((t) => {
|
|
259
|
+
const r = {
|
|
260
|
+
...t,
|
|
261
|
+
label: i(t.label)
|
|
262
|
+
};
|
|
263
|
+
if (!t.localization || e.length === 0)
|
|
264
|
+
return [r];
|
|
265
|
+
const l = e.map((s) => ({
|
|
266
|
+
...t,
|
|
267
|
+
key: `${t.key}:${s}`,
|
|
268
|
+
label: `${i(t.label)} (${s})`,
|
|
269
|
+
localization: !1
|
|
270
|
+
}));
|
|
271
|
+
return [r, ...l];
|
|
272
|
+
});
|
|
273
|
+
}), k = y({}), m = y({
|
|
274
|
+
title: "",
|
|
275
|
+
status: "draft"
|
|
276
|
+
}), I = y(null), q = p(
|
|
277
|
+
() => {
|
|
278
|
+
var e;
|
|
279
|
+
return (((e = m.value) == null ? void 0 : e.type) || I.value) === "single";
|
|
280
|
+
}
|
|
281
|
+
), ve = p(() => {
|
|
282
|
+
const e = [
|
|
283
|
+
{ id: "content", name: i("cms.builder.content") },
|
|
284
|
+
{ id: "seo", name: i("cms.builder.seo") },
|
|
285
|
+
{ id: "tags", name: i("cms.builder.tags") }
|
|
286
|
+
];
|
|
287
|
+
return J.value && e.push({ id: "preview", name: i("cms.builder.preview") }), e;
|
|
288
|
+
}), E = y("content"), pe = p(() => {
|
|
289
|
+
var t, r, l, s;
|
|
290
|
+
const e = ((t = o.params) == null ? void 0 : t.collection) || ((r = o.params) == null ? void 0 : r.id);
|
|
291
|
+
return ((s = (l = g.value) == null ? void 0 : l.find((v) => v.id === e)) == null ? void 0 : s.title) || e;
|
|
292
|
+
}), fe = p(() => {
|
|
293
|
+
var t, r;
|
|
294
|
+
const e = q.value ? "cms.builder.editPage" : "cms.builder.editCollection";
|
|
295
|
+
return ((t = m.value) == null ? void 0 : t.title) || ((r = o.params) != null && r.id ? i(e) : i("cms.articles.createArticle"));
|
|
296
|
+
}), ge = p(() => {
|
|
297
|
+
var l, s, v;
|
|
298
|
+
const e = ((l = o.params) == null ? void 0 : l.collection) || ((s = o.params) == null ? void 0 : s.id), t = (v = o.params) == null ? void 0 : v.id, r = [
|
|
299
|
+
{
|
|
300
|
+
label: pe.value,
|
|
301
|
+
route: `collections/${e}`
|
|
302
|
+
}
|
|
303
|
+
];
|
|
304
|
+
return t ? r.push({
|
|
305
|
+
label: fe.value,
|
|
306
|
+
route: `collections/${e}/${t}`
|
|
307
|
+
}) : r.push({
|
|
308
|
+
label: i("cms.articles.createArticle"),
|
|
309
|
+
route: `collections/${e}/create`
|
|
310
|
+
}), r;
|
|
311
|
+
}), ye = (e) => {
|
|
312
|
+
e === "collections" ? w.push("/collections") : w.push(`/${e}`);
|
|
313
|
+
}, ee = async (e, t) => {
|
|
314
|
+
var r;
|
|
315
|
+
try {
|
|
316
|
+
if (!t || !e)
|
|
317
|
+
return;
|
|
318
|
+
const l = await fetch(`/api/cms/${e}/${t}`);
|
|
319
|
+
if (!l.ok)
|
|
320
|
+
throw new Error("Failed to fetch article");
|
|
321
|
+
const s = await l.json();
|
|
322
|
+
if (u.value = (s == null ? void 0 : s.columns) || [], s != null && s.preview_path && (J.value = s == null ? void 0 : s.preview_path), I.value = (s == null ? void 0 : s.type) || null, s.rows) {
|
|
323
|
+
let v = s.rows;
|
|
324
|
+
Array.isArray(v) || (v = [v]), m.value = v[0], await D(), (r = v[0]) != null && r.meta ? k.value = { ...v[0].meta } : k.value = {
|
|
325
|
+
title: "",
|
|
326
|
+
description: "",
|
|
327
|
+
keywords: "",
|
|
328
|
+
meta: {}
|
|
329
|
+
};
|
|
330
|
+
} else
|
|
331
|
+
m.value = s, await D(), s != null && s.meta ? (k.value = {
|
|
332
|
+
title: s.meta.title || "",
|
|
333
|
+
description: s.meta.description || "",
|
|
334
|
+
keywords: s.meta.keywords || "",
|
|
335
|
+
meta: { ...s.meta }
|
|
336
|
+
}, delete k.value.meta.title, delete k.value.meta.description, delete k.value.meta.keywords) : k.value = {
|
|
337
|
+
title: "",
|
|
338
|
+
description: "",
|
|
339
|
+
keywords: "",
|
|
340
|
+
meta: {}
|
|
341
|
+
};
|
|
342
|
+
} catch (l) {
|
|
343
|
+
console.error("Error fetching article:", l);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
Y(async () => {
|
|
347
|
+
var s, v;
|
|
348
|
+
const e = (s = o.params) == null ? void 0 : s.collection, t = (v = o.params) == null ? void 0 : v.id, r = e || t, l = e && t ? t : void 0;
|
|
349
|
+
if (!l) {
|
|
350
|
+
if (!r)
|
|
351
|
+
return;
|
|
352
|
+
const c = await (await fetch(`/api/cms/${r}/`)).json();
|
|
353
|
+
u.value = c.columns, I.value = (c == null ? void 0 : c.type) || null;
|
|
354
|
+
}
|
|
355
|
+
await ee(r, l ?? "");
|
|
356
|
+
});
|
|
357
|
+
const te = p({
|
|
358
|
+
get: () => {
|
|
359
|
+
var e;
|
|
360
|
+
return ((e = m.value) == null ? void 0 : e.is_pin) || !1;
|
|
361
|
+
},
|
|
362
|
+
set: (e) => {
|
|
363
|
+
m.value && (m.value.is_pin = e);
|
|
364
|
+
}
|
|
365
|
+
}), he = () => {
|
|
366
|
+
m.value && (m.value.is_pin = !m.value.is_pin);
|
|
367
|
+
}, G = p(() => {
|
|
368
|
+
var t;
|
|
369
|
+
const e = (t = m.value) == null ? void 0 : t.content_type_id;
|
|
370
|
+
return e ? `/collections/${e}/edit` : null;
|
|
371
|
+
}), be = () => {
|
|
372
|
+
G.value && w.push(G.value);
|
|
373
|
+
}, we = async () => {
|
|
374
|
+
var l, s;
|
|
375
|
+
const e = (l = o.params) == null ? void 0 : l.collection, t = (s = o.params) == null ? void 0 : s.id;
|
|
376
|
+
(await fetch(
|
|
377
|
+
`/api/cms-translate?id=${t}&collection=${e}&to=en&nocache=1`
|
|
378
|
+
)).ok ? (U({
|
|
379
|
+
title: i("cms.collections.translateContentSuccess"),
|
|
380
|
+
message: i("cms.collections.translateContentSuccess"),
|
|
381
|
+
type: "success"
|
|
382
|
+
}), await ee(e, t)) : U({
|
|
383
|
+
title: i("cms.collections.translateContentError"),
|
|
384
|
+
message: i("cms.collections.translateContentError"),
|
|
385
|
+
type: "error"
|
|
386
|
+
});
|
|
387
|
+
}, _e = async (e) => {
|
|
388
|
+
var P, c, Q, se;
|
|
389
|
+
const t = (P = o.params) == null ? void 0 : P.collection, r = (c = o.params) == null ? void 0 : c.id, l = await f.value.validate();
|
|
390
|
+
if (l) {
|
|
391
|
+
U({
|
|
392
|
+
title: i("cms.validation"),
|
|
393
|
+
message: JSON.stringify(l),
|
|
394
|
+
type: "warning"
|
|
395
|
+
});
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
(Q = B.value) != null && Q.restoreTagsBeforeSubmit && await B.value.restoreTagsBeforeSubmit();
|
|
399
|
+
const s = k.value || {}, v = {
|
|
400
|
+
...m.value,
|
|
401
|
+
meta: {
|
|
402
|
+
...s,
|
|
403
|
+
...s.meta || {}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
console.log("Payload before submit:", v);
|
|
407
|
+
try {
|
|
408
|
+
const F = await fetch(`/api/cms/${t}/${r || ""}`, {
|
|
409
|
+
method: r ? "PUT" : "POST",
|
|
410
|
+
headers: {
|
|
411
|
+
"Content-Type": "application/json"
|
|
412
|
+
},
|
|
413
|
+
body: JSON.stringify(v)
|
|
414
|
+
});
|
|
415
|
+
if (!F.ok) {
|
|
416
|
+
let j;
|
|
417
|
+
try {
|
|
418
|
+
const H = await F.json();
|
|
419
|
+
j = JSON.stringify(H, null, 2);
|
|
420
|
+
} catch {
|
|
421
|
+
j = await F.text();
|
|
422
|
+
}
|
|
423
|
+
throw new Error(`HTTP ${F.status}: ${j}`);
|
|
424
|
+
}
|
|
425
|
+
if (!r)
|
|
426
|
+
try {
|
|
427
|
+
const j = await F.json(), H = j.id || ((se = j.data) == null ? void 0 : se.id);
|
|
428
|
+
H && o.name === "createArticle" && await w.push(`/collections/${t}/${H}`);
|
|
429
|
+
} catch (j) {
|
|
430
|
+
console.warn("Could not parse response to get ID:", j);
|
|
431
|
+
}
|
|
432
|
+
U({
|
|
433
|
+
title: i("cms.common.success"),
|
|
434
|
+
message: i("cms.common.successMessage"),
|
|
435
|
+
type: "success"
|
|
436
|
+
});
|
|
437
|
+
} catch (F) {
|
|
438
|
+
console.error("Submit error:", F), U({
|
|
439
|
+
title: i("cms.common.error"),
|
|
440
|
+
message: "Помилка збереження",
|
|
441
|
+
type: "error"
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
return (e, t) => {
|
|
446
|
+
var r, l, s, v, P;
|
|
447
|
+
return h(), b("div", tt, [
|
|
448
|
+
d("div", st, [
|
|
449
|
+
A(Ie, {
|
|
450
|
+
items: ge.value,
|
|
451
|
+
onNavigate: ye
|
|
452
|
+
}, null, 8, ["items"]),
|
|
453
|
+
d("div", at, [
|
|
454
|
+
d("div", ot, [
|
|
455
|
+
d("button", {
|
|
456
|
+
onClick: t[0] || (t[0] = (c) => _(w).back()),
|
|
457
|
+
class: "p-2 text-gray-500 rounded-full hover:text-gray-900 dark:text-gray-400 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700"
|
|
458
|
+
}, [
|
|
459
|
+
A(_(Pe), { class: "w-5 h-5" })
|
|
460
|
+
]),
|
|
461
|
+
d("h1", lt, L(e.$t(
|
|
462
|
+
q.value ? "cms.builder.editPage" : "cms.builder.editCollection"
|
|
463
|
+
)) + ' "' + L(m.value.title) + '" ', 1),
|
|
464
|
+
d("a", {
|
|
465
|
+
href: `https://cms.opengis.info/${_(C)}/guides/content/`,
|
|
466
|
+
target: "_blank",
|
|
467
|
+
title: e.$t("cms.guide.content")
|
|
468
|
+
}, [
|
|
469
|
+
A(_(Le), { class: "w-5 h-5" })
|
|
470
|
+
], 8, rt)
|
|
471
|
+
]),
|
|
472
|
+
d("div", it, [
|
|
473
|
+
G.value && q.value ? (h(), b("button", {
|
|
474
|
+
key: 0,
|
|
475
|
+
onClick: be,
|
|
476
|
+
type: "button",
|
|
477
|
+
title: e.$t("cms.builder.editContentType"),
|
|
478
|
+
class: "inline-flex items-center justify-center rounded-md h-9 w-9 border border-gray-200 bg-white text-gray-700 shadow-sm transition-all duration-200 transform hover:text-gray-900 hover:shadow-md focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
479
|
+
"aria-label": "$t('cms.builder.editContentType')"
|
|
480
|
+
}, [
|
|
481
|
+
A(_(Ue), { class: "w-4 h-4" })
|
|
482
|
+
], 8, nt)) : z("", !0),
|
|
483
|
+
d("button", {
|
|
484
|
+
onClick: _e,
|
|
485
|
+
type: "submit",
|
|
486
|
+
class: "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium h-9 px-4 py-2 bg-blue-600 text-white shadow-md transition-all duration-200 transform hover:bg-blue-700 hover:shadow-lg hover:scale-105 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
|
|
487
|
+
}, [
|
|
488
|
+
A(_(Be), { class: "w-4 h-4 mr-2" }),
|
|
489
|
+
ie(" " + L(e.$t("cms.builder.save")), 1)
|
|
490
|
+
])
|
|
491
|
+
])
|
|
492
|
+
]),
|
|
493
|
+
d("div", ct, [
|
|
494
|
+
d("div", ut, [
|
|
495
|
+
(h(!0), b(Ve, null, je(ve.value, (c) => (h(), b("button", {
|
|
496
|
+
key: c.id,
|
|
497
|
+
onClick: (Q) => {
|
|
498
|
+
E.value = c.id, console.log("cmsSettings:", N.value.value);
|
|
499
|
+
},
|
|
500
|
+
class: ae([
|
|
501
|
+
"inline-flex flex-1 items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm data-[state=active]:bg-blue-50 data-[state=active]:text-blue-700 data-[state=active]:border-blue-200",
|
|
502
|
+
c.id === E.value ? "bg-blue-50 text-blue-700 border-blue-200" : ""
|
|
503
|
+
])
|
|
504
|
+
}, L(c.name), 11, dt))), 128))
|
|
505
|
+
]),
|
|
506
|
+
d("div", mt, [
|
|
507
|
+
(r = _(o).params) != null && r.id && ue.value ? (h(), b("button", {
|
|
508
|
+
key: 0,
|
|
509
|
+
class: "text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer bg-white border border-gray-200 rounded-md text-muted-foreground px-4 py-2",
|
|
510
|
+
onClick: we
|
|
511
|
+
}, L(e.$t("cms.collections.enLocalization")), 1)) : z("", !0),
|
|
512
|
+
d("div", vt, [
|
|
513
|
+
d("label", pt, L(e.$t("cms.collections.pinPublication")), 1),
|
|
514
|
+
d("div", ft, [
|
|
515
|
+
W(d("input", {
|
|
516
|
+
type: "checkbox",
|
|
517
|
+
id: "is_pin",
|
|
518
|
+
"onUpdate:modelValue": t[1] || (t[1] = (c) => te.value = c),
|
|
519
|
+
class: "sr-only"
|
|
520
|
+
}, null, 512), [
|
|
521
|
+
[Fe, te.value]
|
|
522
|
+
]),
|
|
523
|
+
d("div", {
|
|
524
|
+
class: ae([
|
|
525
|
+
"w-5 h-5 border-2 rounded transition-all duration-200 cursor-pointer flex items-center justify-center",
|
|
526
|
+
(l = m.value) != null && l.is_pin ? "bg-sky-600 border-sky-600" : "bg-white border-gray-300 hover:border-sky-400 dark:bg-gray-700 dark:border-gray-600 dark:hover:border-sky-400"
|
|
527
|
+
]),
|
|
528
|
+
onClick: he
|
|
529
|
+
}, [
|
|
530
|
+
(s = m.value) != null && s.is_pin ? (h(), b("svg", gt, [...t[7] || (t[7] = [
|
|
531
|
+
d("path", {
|
|
532
|
+
"fill-rule": "evenodd",
|
|
533
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
534
|
+
"clip-rule": "evenodd"
|
|
535
|
+
}, null, -1)
|
|
536
|
+
])])) : z("", !0)
|
|
537
|
+
], 2)
|
|
538
|
+
])
|
|
539
|
+
])
|
|
540
|
+
])
|
|
541
|
+
])
|
|
542
|
+
]),
|
|
543
|
+
W(d("div", yt, [
|
|
544
|
+
(v = Z.value) != null && v.length ? (h(), re(_(le), {
|
|
545
|
+
key: 0,
|
|
546
|
+
modelValue: m.value,
|
|
547
|
+
"onUpdate:modelValue": t[2] || (t[2] = (c) => m.value = c),
|
|
548
|
+
schema: de.value,
|
|
549
|
+
form: f.value,
|
|
550
|
+
"onUpdate:form": t[3] || (t[3] = (c) => f.value = c)
|
|
551
|
+
}, null, 8, ["modelValue", "schema", "form"])) : z("", !0)
|
|
552
|
+
], 512), [
|
|
553
|
+
[oe, E.value === "content"]
|
|
554
|
+
]),
|
|
555
|
+
W(d("div", ht, [
|
|
556
|
+
A(_(le), {
|
|
557
|
+
schema: me.value,
|
|
558
|
+
values: k.value,
|
|
559
|
+
"onUpdate:values": t[4] || (t[4] = (c) => k.value = c),
|
|
560
|
+
form: T.value,
|
|
561
|
+
"onUpdate:form": t[5] || (t[5] = (c) => T.value = c)
|
|
562
|
+
}, null, 8, ["schema", "values", "form"])
|
|
563
|
+
], 512), [
|
|
564
|
+
[oe, E.value === "seo"]
|
|
565
|
+
]),
|
|
566
|
+
E.value === "tags" ? (h(), b("div", bt, [
|
|
567
|
+
A(Ge, {
|
|
568
|
+
ref_key: "tagsForm",
|
|
569
|
+
ref: B,
|
|
570
|
+
modelValue: m.value,
|
|
571
|
+
"onUpdate:modelValue": t[6] || (t[6] = (c) => m.value = c)
|
|
572
|
+
}, null, 8, ["modelValue"])
|
|
573
|
+
])) : z("", !0),
|
|
574
|
+
E.value === "preview" ? (h(), b("div", wt, [
|
|
575
|
+
A(et, {
|
|
576
|
+
slug: (P = m.value) == null ? void 0 : P.slug,
|
|
577
|
+
preview_path: J.value
|
|
578
|
+
}, null, 8, ["slug", "preview_path"])
|
|
579
|
+
])) : z("", !0)
|
|
580
|
+
]);
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
export {
|
|
585
|
+
Vt as default
|
|
586
|
+
};
|