@webx-ui/module-pages 0.1.0 → 0.2.0

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/index.js CHANGED
@@ -1,38 +1,38 @@
1
- import { inject as je, provide as Ge, defineComponent as H, ref as P, computed as V, openBlock as d, createBlock as x, unref as e, withCtx as n, createElementVNode as N, createElementBlock as M, createVNode as f, createTextVNode as h, toDisplayString as g, createCommentVNode as D, useTemplateRef as Pe, watch as ae, onMounted as ye, onBeforeUnmount as Je, Fragment as F, renderList as ie, normalizeClass as Qe, useModel as Xe, mergeModels as Ye, withModifiers as xe, nextTick as Ze, isRef as Re, withKeys as De } from "vue";
2
- import { useRouter as Ce, useRoute as qe, onBeforeRouteLeave as et } from "vue-router";
3
- import { useAdmin as X, useTranslate as j, WxScreen as tt } from "@webx-ui/module-admin";
4
- import { WxCard as Oe, WxText as O, WxButton as R, confirm as le, toast as z, useLocales as Ue, useElementWidth as Ie, localizedValue as at, WxSkeleton as ke, WxBreadcrumb as lt, WxBreadcrumbItem as we, WxBadge as We, WxDropdown as Le, WxDropdownItem as re, WxAction as $e, WxAlert as Ve, WxEmpty as nt, WxTreeSelect as st, WxFormItem as ue, WxActions as ot, useModal as Fe, WxDialog as Ke, WxInput as Me, WxSpace as Te, createModal as Ae, WxHeading as it, WxTable as rt, WxSegmented as ut } from "@webx-ui/core";
5
- import { provideBlocksPreview as dt } from "@webx-ui/module-blocks";
6
- function Z(v) {
7
- const u = `${v.apiPath}/pages`, p = (l) => l.data;
1
+ import { inject as Le, provide as Oe, defineComponent as K, ref as k, computed as W, openBlock as m, createBlock as V, unref as e, withCtx as n, createElementVNode as E, createElementBlock as A, createVNode as v, createTextVNode as y, toDisplayString as b, createCommentVNode as N, useTemplateRef as Me, watch as ae, onMounted as pe, onBeforeUnmount as Ke, Fragment as j, renderList as De, normalizeClass as Fe, useModel as He, mergeModels as je, nextTick as Ge, isRef as Se, withKeys as Pe, createSlots as Je, withModifiers as Qe } from "vue";
2
+ import { useRouter as ye, useRoute as Xe, onBeforeRouteLeave as Ye } from "vue-router";
3
+ import { useAdmin as G, useTranslate as F, useErrorText as ie, WxScreen as Ze, WxDate as me, WxRowMenu as qe, WxListScreen as et } from "@webx-ui/module-admin";
4
+ import { WxCard as tt, WxText as R, WxButton as I, confirm as O, toast as z, useLocales as Be, useElementWidth as at, localizedValue as lt, WxSkeleton as be, WxBreadcrumb as nt, WxBreadcrumbItem as fe, WxBadge as we, WxDropdown as st, WxDropdownItem as We, WxAction as ot, WxAlert as xe, WxActionBar as it, WxEmpty as rt, WxTreeSelect as ut, WxFormItem as oe, useModal as Ne, WxDialog as Ae, WxInput as Ve, WxSpace as _e, createModal as ze, WxTable as dt } from "@webx-ui/core";
5
+ import { provideBlocksPreview as ct } from "@webx-ui/module-blocks";
6
+ function Z(p) {
7
+ const r = `${p.apiPath}/pages`, h = (l) => l.data;
8
8
  return {
9
9
  list: (l = {}) => {
10
- const i = new URLSearchParams();
11
- l.parent != null && i.set("parent", String(l.parent)), l.search && i.set("search", l.search), l.status && i.set("status", l.status), l.trashed && i.set("trashed", "1"), l.flat && i.set("flat", "1");
12
- const t = i.size > 0 ? `?${i}` : "";
13
- return v.http.get(`${u}${t}`).then(p);
10
+ const s = new URLSearchParams();
11
+ l.parent != null && s.set("parent", String(l.parent)), l.search && s.set("search", l.search), l.status && s.set("status", l.status), l.trashed && s.set("trashed", "1"), l.flat && s.set("flat", "1");
12
+ const t = s.size > 0 ? `?${s}` : "";
13
+ return p.http.get(`${r}${t}`).then(h);
14
14
  },
15
- get: (l) => v.http.get(`${u}/${l}`).then(p),
16
- create: (l) => v.http.post(u, l).then(p),
17
- save: (l, i) => v.http.put(`${u}/${l}`, i).then(p),
18
- move: (l, i, t) => v.http.post(`${u}/${l}/move`, { target: i, zone: t }).then(p),
19
- duplicate: (l) => v.http.post(`${u}/${l}/duplicate`, {}).then(p),
20
- publish: (l) => v.http.post(`${u}/${l}/publish`, {}).then(p),
21
- unpublish: (l) => v.http.post(`${u}/${l}/unpublish`, {}).then(p),
22
- remove: (l) => v.http.delete(`${u}/${l}`).then((i) => i.data.trashed),
23
- restore: (l) => v.http.post(`${u}/${l}/restore`, {}).then((i) => i.data.restored),
24
- versions: (l) => v.http.get(`${u}/${l}/versions`).then(p),
25
- restoreVersion: (l, i) => v.http.post(`${u}/${l}/versions/${i}/restore`, {}).then(p)
15
+ get: (l) => p.http.get(`${r}/${l}`).then(h),
16
+ create: (l) => p.http.post(r, l).then(h),
17
+ save: (l, s) => p.http.put(`${r}/${l}`, s).then(h),
18
+ move: (l, s, t) => p.http.post(`${r}/${l}/move`, { target: s, zone: t }).then(h),
19
+ duplicate: (l) => p.http.post(`${r}/${l}/duplicate`, {}).then(h),
20
+ publish: (l) => p.http.post(`${r}/${l}/publish`, {}).then(h),
21
+ unpublish: (l) => p.http.post(`${r}/${l}/unpublish`, {}).then(h),
22
+ remove: (l) => p.http.delete(`${r}/${l}`).then((s) => s.data.trashed),
23
+ restore: (l) => p.http.post(`${r}/${l}/restore`, {}).then((s) => s.data.restored),
24
+ versions: (l) => p.http.get(`${r}/${l}/versions`).then(h),
25
+ restoreVersion: (l, s) => p.http.post(`${r}/${l}/versions/${s}/restore`, {}).then(h)
26
26
  };
27
27
  }
28
- const He = /* @__PURE__ */ Symbol("wx-page-editor");
29
- function ct(v) {
30
- Ge(He, v);
28
+ const Ee = /* @__PURE__ */ Symbol("wx-page-editor");
29
+ function pt(p) {
30
+ Oe(Ee, p);
31
31
  }
32
- function ze() {
33
- return je(He, null);
32
+ function ke() {
33
+ return Le(Ee, null);
34
34
  }
35
- const pt = {
35
+ const gt = {
36
36
  module: {
37
37
  title: "Pages"
38
38
  },
@@ -78,6 +78,7 @@ const pt = {
78
78
  "move-title": "Move “:title”",
79
79
  "move-help": "Pick the page it goes inside. Everything under it moves too, and their addresses change with it.",
80
80
  "move-confirm": "Move",
81
+ "move-branch": ":count addresses change — the page and everything inside it. The old ones will redirect to the new ones.",
81
82
  moved: "Moved. :count addresses changed; the old ones now redirect to the new ones.",
82
83
  "moved-one": "Moved. The address changed; the old one now redirects to it.",
83
84
  "delete-title": "Delete “:title”?",
@@ -85,6 +86,10 @@ const pt = {
85
86
  "delete-branch": "The :count pages inside it go with it.",
86
87
  deleted: "The page is in the bin.",
87
88
  restored: "The page is back.",
89
+ "restore-page-title": "Bring “:title” back?",
90
+ "restore-page-text": "The page leaves the bin and takes its address back. One that was on the site answers again.",
91
+ "restore-branch": "The :count pages that went in with it come back too.",
92
+ "restored-branch": ":count pages are back.",
88
93
  "copy-of": ":title (copy)",
89
94
  duplicated: "The copy is ready, and it is not on the site.",
90
95
  "address-copied": "The address is on the clipboard.",
@@ -97,6 +102,9 @@ const pt = {
97
102
  save: "Save",
98
103
  "save-failed": "The page was not saved.",
99
104
  publish: "Publish",
105
+ "publish-title": "Put “:title” on the site?",
106
+ "publish-text": "It answers at :address from the moment you do, for everyone.",
107
+ "publish-text-nowhere": "It starts answering on the site from the moment you do, for everyone.",
100
108
  published: "The page is on the site.",
101
109
  preview: "Preview",
102
110
  more: "More",
@@ -129,129 +137,126 @@ const pt = {
129
137
  "restore-text": "It becomes the draft. The site keeps showing what is published until you publish this.",
130
138
  "restored-version": "Version :number is now the draft."
131
139
  }
132
- }, Be = /* @__PURE__ */ new WeakSet();
133
- function G() {
140
+ }, Ce = /* @__PURE__ */ new WeakSet();
141
+ function H() {
134
142
  try {
135
- const { i18n: v } = X();
136
- Be.has(v) || (v.defaults("webx-pages", pt), Be.add(v));
143
+ const { i18n: p } = G();
144
+ Ce.has(p) || (p.defaults("webx-pages", gt), Ce.add(p));
137
145
  } catch {
138
146
  }
139
147
  }
140
- const gt = { class: "wx-page-danger" }, vt = {
148
+ const vt = { class: "wx-page-danger" }, ht = {
141
149
  key: 0,
142
150
  class: "wx-page-danger__row"
143
- }, ft = { class: "wx-page-danger__what" }, ht = { class: "wx-page-danger__row" }, mt = { class: "wx-page-danger__what" }, yt = /* @__PURE__ */ H({
151
+ }, ft = { class: "wx-page-danger__what" }, mt = { class: "wx-page-danger__row" }, bt = { class: "wx-page-danger__what" }, _t = /* @__PURE__ */ K({
144
152
  name: "WxPageDanger",
145
153
  __name: "PageDanger",
146
- setup(v) {
147
- const u = X(), p = Z(u), l = Ce(), i = ze();
148
- G();
149
- const t = j("webx-pages"), c = P(!1), a = V(() => i?.page.value ?? null), o = V(() => u.can("pages.manage"));
150
- async function s() {
151
- const $ = a.value;
152
- if (!(!$ || !await le({
153
- title: t("page.unpublish-title", { title: $.title }),
154
+ setup(p) {
155
+ const r = G(), h = Z(r), l = ye(), s = ke();
156
+ H();
157
+ const t = F("webx-pages"), u = ie(), a = k(!1), d = W(() => s?.page.value ?? null), f = W(() => r.can("pages.manage"));
158
+ async function i() {
159
+ const x = d.value;
160
+ if (!(!x || !await O({
161
+ title: t("page.unpublish-title", { title: x.title }),
154
162
  message: t("page.unpublish-text"),
155
163
  confirmText: t("page.unpublish"),
156
164
  cancelText: t("page.cancel"),
157
165
  tone: "danger"
158
166
  }))) {
159
- c.value = !0;
167
+ a.value = !0;
160
168
  try {
161
- await p.unpublish($.id), await i?.reload(), z.success(t("page.unpublished"));
162
- } catch (y) {
163
- z.danger(k(y));
169
+ await h.unpublish(x.id), await s?.reload(), z.success(t("page.unpublished"));
170
+ } catch (_) {
171
+ z.danger(u(_));
164
172
  } finally {
165
- c.value = !1;
173
+ a.value = !1;
166
174
  }
167
175
  }
168
176
  }
169
- async function C() {
170
- const $ = a.value;
171
- if (!(!$ || !await le({
172
- title: t("page.delete-title", { title: $.title }),
177
+ async function T() {
178
+ const x = d.value;
179
+ if (!(!x || !await O({
180
+ title: t("page.delete-title", { title: x.title }),
173
181
  // The whole branch, not the level under it (§7): a catalogue with two sections and forty
174
182
  // products is forty-two pages leaving the site at once.
175
- message: $.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: $.descendants_count })}` : t("page.delete-text"),
183
+ message: x.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: x.descendants_count })}` : t("page.delete-text"),
176
184
  confirmText: t("page.delete"),
177
185
  cancelText: t("page.cancel"),
178
186
  tone: "danger"
179
187
  }))) {
180
- c.value = !0;
188
+ a.value = !0;
181
189
  try {
182
- await p.remove($.id), z.success(t("page.deleted")), l.push(i?.base ?? "/pages");
183
- } catch (y) {
184
- z.danger(k(y));
190
+ await h.remove(x.id), z.success(t("page.deleted")), l.push(s?.base ?? "/pages");
191
+ } catch (_) {
192
+ z.danger(u(_));
185
193
  } finally {
186
- c.value = !1;
194
+ a.value = !1;
187
195
  }
188
196
  }
189
197
  }
190
- function k($) {
191
- return $.body?.message ?? String($);
192
- }
193
- return ($, T) => a.value && o.value ? (d(), x(e(Oe), {
198
+ return (x, C) => d.value && f.value ? (m(), V(e(tt), {
194
199
  key: 0,
195
200
  title: e(t)("page.danger")
196
201
  }, {
197
202
  default: n(() => [
198
- N("div", gt, [
199
- a.value.status !== "draft" ? (d(), M("div", vt, [
200
- N("div", ft, [
201
- f(e(O), { weight: "medium" }, {
203
+ E("div", vt, [
204
+ d.value.status !== "draft" ? (m(), A("div", ht, [
205
+ E("div", ft, [
206
+ v(e(R), { weight: "medium" }, {
202
207
  default: n(() => [
203
- h(g(e(t)("page.unpublish")), 1)
208
+ y(b(e(t)("page.unpublish")), 1)
204
209
  ]),
205
210
  _: 1
206
211
  }),
207
- f(e(O), {
212
+ v(e(R), {
208
213
  size: "sm",
209
214
  tone: "muted"
210
215
  }, {
211
216
  default: n(() => [
212
- h(g(e(t)("page.unpublish-help")), 1)
217
+ y(b(e(t)("page.unpublish-help")), 1)
213
218
  ]),
214
219
  _: 1
215
220
  })
216
221
  ]),
217
- f(e(R), {
222
+ v(e(I), {
218
223
  variant: "outline",
219
- loading: c.value,
220
- onClick: s
224
+ loading: a.value,
225
+ onClick: i
221
226
  }, {
222
227
  default: n(() => [
223
- h(g(e(t)("page.unpublish")), 1)
228
+ y(b(e(t)("page.unpublish")), 1)
224
229
  ]),
225
230
  _: 1
226
231
  }, 8, ["loading"])
227
- ])) : D("", !0),
228
- N("div", ht, [
229
- N("div", mt, [
230
- f(e(O), { weight: "medium" }, {
232
+ ])) : N("", !0),
233
+ E("div", mt, [
234
+ E("div", bt, [
235
+ v(e(R), { weight: "medium" }, {
231
236
  default: n(() => [
232
- h(g(e(t)("page.delete")), 1)
237
+ y(b(e(t)("page.delete")), 1)
233
238
  ]),
234
239
  _: 1
235
240
  }),
236
- f(e(O), {
241
+ v(e(R), {
237
242
  size: "sm",
238
243
  tone: "muted"
239
244
  }, {
240
245
  default: n(() => [
241
- h(g(a.value.can.delete ? e(t)("page.delete-help") : e(t)("page.delete-home")), 1)
246
+ y(b(d.value.can.delete ? e(t)("page.delete-help") : e(t)("page.delete-home")), 1)
242
247
  ]),
243
248
  _: 1
244
249
  })
245
250
  ]),
246
- f(e(R), {
251
+ v(e(I), {
247
252
  type: "danger",
248
253
  variant: "outline",
249
- disabled: !a.value.can.delete,
250
- loading: c.value,
251
- onClick: C
254
+ disabled: !d.value.can.delete,
255
+ loading: a.value,
256
+ onClick: T
252
257
  }, {
253
258
  default: n(() => [
254
- h(g(e(t)("page.delete")), 1)
259
+ y(b(e(t)("page.delete")), 1)
255
260
  ]),
256
261
  _: 1
257
262
  }, 8, ["disabled", "loading"])
@@ -259,79 +264,79 @@ const gt = { class: "wx-page-danger" }, vt = {
259
264
  ])
260
265
  ]),
261
266
  _: 1
262
- }, 8, ["title"])) : D("", !0);
267
+ }, 8, ["title"])) : N("", !0);
263
268
  }
264
- }), de = (v, u) => {
265
- const p = v.__vccOpts || v;
266
- for (const [l, i] of u)
267
- p[l] = i;
268
- return p;
269
- }, bt = /* @__PURE__ */ de(yt, [["__scopeId", "data-v-94c0abe4"]]), _t = { class: "wx-page-editor__head" }, wt = { class: "wx-page-editor__id" }, xt = { class: "wx-page-editor__name" }, kt = { class: "wx-page-editor__title" }, $t = { class: "wx-page-editor__actions" }, Tt = { class: "wx-page-editor__screen" }, Pt = 1200, Ct = 720, Wt = /* @__PURE__ */ H({
269
+ }), re = (p, r) => {
270
+ const h = p.__vccOpts || p;
271
+ for (const [l, s] of r)
272
+ h[l] = s;
273
+ return h;
274
+ }, yt = /* @__PURE__ */ re(_t, [["__scopeId", "data-v-d4a9083f"]]), wt = { class: "wx-page-editor__head" }, xt = { class: "wx-page-editor__id" }, kt = { class: "wx-page-editor__name" }, Tt = { class: "wx-page-editor__title" }, $t = { class: "wx-page-editor__actions" }, Pt = { class: "wx-page-editor__screen" }, Wt = 1200, Vt = 720, zt = /* @__PURE__ */ K({
270
275
  __name: "PageEditorPage",
271
276
  props: {
272
277
  base: { default: "/pages" }
273
278
  },
274
- setup(v) {
275
- const u = v, p = X(), l = Z(p), i = qe(), t = Ce(), c = Ue();
276
- G();
277
- const a = j("webx-pages"), o = V(() => Number(i.params.id)), s = P(null), C = P([]), k = P({}), $ = P(""), T = P(null), y = P({}), S = P(!0), W = P(!1), _ = P(!1), A = P({}), U = P(null), q = P(""), ce = P(0), I = V(() => p.can("pages.manage")), pe = Pe("root"), ge = Ie(pe), L = V(() => ge.value > 0 && ge.value < Ct), ee = V(() => JSON.stringify(k.value)), B = V(() => q.value !== "" && ee.value !== q.value), ne = V(() => W.value ? "saving" : B.value ? "unsaved" : "saved"), se = V(() => {
278
- const m = k.value.title;
279
- return at(m, c.active.value, s.value?.title ?? "");
280
- }), ve = V(
281
- () => C.value.map((m) => ({
282
- id: m.id,
283
- label: m.is_home ? a("pages.home") : m.title
279
+ setup(p) {
280
+ const r = p, h = G(), l = Z(h), s = Xe(), t = ye(), u = Be();
281
+ H();
282
+ const a = F("webx-pages"), d = ie(), f = W(() => Number(s.params.id)), i = k(null), T = k([]), x = k({}), C = k(""), _ = k(null), c = k({}), M = k(!0), $ = k(!1), S = k(!1), le = k({}), U = k(null), q = k(""), ue = k(0), D = W(() => h.can("pages.manage")), de = Me("root"), ee = at(de), ce = W(() => ee.value > 0 && ee.value < Vt), te = W(() => JSON.stringify(x.value)), L = W(() => q.value !== "" && te.value !== q.value), ge = W(() => $.value ? "saving" : L.value ? "unsaved" : "saved"), ne = W(() => {
283
+ const P = x.value.title;
284
+ return lt(P, u.active.value, i.value?.title ?? "");
285
+ }), ve = W(
286
+ () => T.value.map((P) => ({
287
+ id: P.id,
288
+ label: P.is_home ? a("pages.home") : P.title
284
289
  }))
285
290
  );
286
- dt({ url: V(() => T.value), reload: ce }), ct({
287
- page: s,
288
- ancestors: C,
289
- values: k,
290
- prefixes: y,
291
- base: u.base,
292
- canManage: I.value,
291
+ ct({ url: W(() => _.value), reload: ue }), pt({
292
+ page: i,
293
+ ancestors: T,
294
+ values: x,
295
+ prefixes: c,
296
+ base: r.base,
297
+ canManage: D.value,
293
298
  reload: () => J(!0),
294
- save: () => K()
299
+ save: () => g()
295
300
  });
296
- function be(m) {
297
- s.value = m.page, C.value = m.ancestors, k.value = m.values, $.value = m.revision, T.value = m.preview_url, y.value = m.address_prefix, q.value = JSON.stringify(m.values), U.value = null;
301
+ function he(P) {
302
+ i.value = P.page, T.value = P.ancestors, x.value = P.values, C.value = P.revision, _.value = P.preview_url, c.value = P.address_prefix, q.value = JSON.stringify(P.values), U.value = null;
298
303
  }
299
- async function J(m = !1) {
300
- m || (S.value = !0);
304
+ async function J(P = !1) {
305
+ P || (M.value = !0);
301
306
  try {
302
- be(await l.get(o.value));
303
- } catch (te) {
304
- z.danger(r(te)), t.push(u.base);
307
+ he(await l.get(f.value));
308
+ } catch (Y) {
309
+ z.danger(d(Y)), t.push(r.base);
305
310
  } finally {
306
- S.value = !1;
311
+ M.value = !1;
307
312
  }
308
313
  }
309
314
  let Q;
310
- function fe() {
311
- !I.value || U.value || !B.value || (clearTimeout(Q), Q = setTimeout(() => {
312
- K();
313
- }, Pt));
315
+ function o() {
316
+ !D.value || U.value || !L.value || (clearTimeout(Q), Q = setTimeout(() => {
317
+ g();
318
+ }, Wt));
314
319
  }
315
- function he() {
316
- !I.value || U.value || !B.value || W.value || (clearTimeout(Q), K());
320
+ function w() {
321
+ !D.value || U.value || !L.value || $.value || (clearTimeout(Q), g());
317
322
  }
318
- async function K() {
319
- if (!s.value || W.value || !I.value) return;
323
+ async function g() {
324
+ if (!i.value || $.value || !D.value) return;
320
325
  clearTimeout(Q);
321
- const m = ee.value, te = k.value;
322
- W.value = !0, A.value = {};
326
+ const P = te.value, Y = x.value;
327
+ $.value = !0, le.value = {};
323
328
  try {
324
- const E = await l.save(s.value.id, { values: te, revision: $.value });
325
- s.value = E.page, C.value = E.ancestors, $.value = E.revision, T.value = E.preview_url, y.value = E.address_prefix, U.value = null, ee.value === m && (q.value = m), ce.value += 1;
326
- } catch (E) {
327
- const oe = E;
328
- oe.status === 409 && oe.body?.data ? U.value = oe.body : oe.body?.errors ? (A.value = oe.body.errors, z.danger(a("page.save-failed"))) : z.danger(r(E));
329
+ const B = await l.save(i.value.id, { values: Y, revision: C.value });
330
+ i.value = B.page, T.value = B.ancestors, C.value = B.revision, _.value = B.preview_url, c.value = B.address_prefix, U.value = null, te.value === P && (q.value = P), ue.value += 1;
331
+ } catch (B) {
332
+ const se = B;
333
+ se.status === 409 && se.body?.data ? U.value = se.body : se.body?.errors ? (le.value = se.body.errors, z.danger(a("page.save-failed"))) : z.danger(d(B));
329
334
  } finally {
330
- W.value = !1;
335
+ $.value = !1;
331
336
  }
332
337
  }
333
- async function me() {
334
- await le({
338
+ async function X() {
339
+ await O({
335
340
  title: a("page.conflict-theirs-title"),
336
341
  message: a("page.conflict-theirs-text"),
337
342
  confirmText: a("page.conflict-theirs"),
@@ -339,371 +344,362 @@ const gt = { class: "wx-page-danger" }, vt = {
339
344
  tone: "danger"
340
345
  }) && await J(!0);
341
346
  }
342
- async function Y() {
343
- const m = U.value;
344
- m && ($.value = m.data.revision, U.value = null, await K());
347
+ async function Ie() {
348
+ const P = U.value;
349
+ P && (C.value = P.data.revision, U.value = null, await g());
345
350
  }
346
- async function _e() {
347
- if (s.value && (B.value && await K(), !U.value)) {
348
- _.value = !0;
351
+ async function Ue() {
352
+ if (!i.value) return;
353
+ const P = i.value.path === null ? null : `/${i.value.path}`;
354
+ if (await O({
355
+ title: a("page.publish-title", { title: i.value.title }),
356
+ message: P === null ? a("page.publish-text-nowhere") : a("page.publish-text", { address: P }),
357
+ confirmText: a("page.publish"),
358
+ cancelText: a("page.cancel")
359
+ }) && (L.value && await g(), !U.value)) {
360
+ S.value = !0;
349
361
  try {
350
- await l.publish(s.value.id), await J(!0), z.success(a("page.published"));
351
- } catch (m) {
352
- z.danger(r(m));
362
+ await l.publish(i.value.id), await J(!0), z.success(a("page.published"));
363
+ } catch (B) {
364
+ z.danger(d(B));
353
365
  } finally {
354
- _.value = !1;
366
+ S.value = !1;
355
367
  }
356
368
  }
357
369
  }
358
- function r(m) {
359
- return m.body?.message ?? String(m);
360
- }
361
- function b() {
362
- return s.value?.status === "published" ? "success" : s.value?.status === "modified" ? "warning" : "default";
370
+ function Re() {
371
+ return i.value?.status === "published" ? "success" : i.value?.status === "modified" ? "warning" : "default";
363
372
  }
364
- function w(m) {
365
- B.value && m.preventDefault();
373
+ function $e(P) {
374
+ L.value && P.preventDefault();
366
375
  }
367
- return ae(ee, fe), ae(o, () => {
376
+ return ae(te, o), ae(f, () => {
368
377
  J();
369
- }), ye(() => {
370
- J(), window.addEventListener("beforeunload", w);
371
- }), Je(() => {
372
- clearTimeout(Q), window.removeEventListener("beforeunload", w);
373
- }), et(async () => !B.value || !I.value || (await K(), !B.value) ? !0 : await le({
378
+ }), pe(() => {
379
+ J(), window.addEventListener("beforeunload", $e);
380
+ }), Ke(() => {
381
+ clearTimeout(Q), window.removeEventListener("beforeunload", $e);
382
+ }), Ye(async () => !L.value || !D.value || (await g(), !L.value) ? !0 : await O({
374
383
  title: a("page.leave-title"),
375
384
  message: a("page.leave-text"),
376
385
  confirmText: a("page.leave"),
377
386
  cancelText: a("page.cancel"),
378
387
  tone: "danger"
379
- })), (m, te) => (d(), M("div", {
388
+ })), (P, Y) => (m(), A("div", {
380
389
  ref_key: "root",
381
- ref: pe,
390
+ ref: de,
382
391
  class: "wx-page-editor",
383
392
  "data-wx-fill": "",
384
- onFocusout: he
393
+ onFocusout: w
385
394
  }, [
386
- S.value || !s.value ? (d(), M(F, { key: 0 }, [
387
- f(e(ke), {
395
+ M.value || !i.value ? (m(), A(j, { key: 0 }, [
396
+ v(e(be), {
388
397
  class: "wx-page-editor__ghost",
389
398
  title: "",
390
399
  rows: 1
391
400
  }),
392
- f(e(ke), { rows: 8 })
393
- ], 64)) : (d(), M(F, { key: 1 }, [
394
- N("div", _t, [
395
- N("div", wt, [
396
- f(e(lt), {
401
+ v(e(be), { rows: 8 })
402
+ ], 64)) : (m(), A(j, { key: 1 }, [
403
+ E("div", wt, [
404
+ E("div", xt, [
405
+ v(e(nt), {
397
406
  size: "sm",
398
407
  label: e(a)("page.trail")
399
408
  }, {
400
409
  default: n(() => [
401
- f(e(we), {
410
+ v(e(fe), {
402
411
  as: "router-link",
403
- to: v.base
412
+ to: p.base
404
413
  }, {
405
414
  default: n(() => [
406
- h(g(e(a)("module.title")), 1)
415
+ y(b(e(a)("module.title")), 1)
407
416
  ]),
408
417
  _: 1
409
418
  }, 8, ["to"]),
410
- (d(!0), M(F, null, ie(ve.value, (E) => (d(), x(e(we), {
411
- key: E.id,
419
+ (m(!0), A(j, null, De(ve.value, (B) => (m(), V(e(fe), {
420
+ key: B.id,
412
421
  as: "router-link",
413
- to: `${v.base}/${E.id}`
422
+ to: `${p.base}/${B.id}`
414
423
  }, {
415
424
  default: n(() => [
416
- h(g(E.label), 1)
425
+ y(b(B.label), 1)
417
426
  ]),
418
427
  _: 2
419
428
  }, 1032, ["to"]))), 128)),
420
- f(e(we), { current: "" }, {
429
+ v(e(fe), { current: "" }, {
421
430
  default: n(() => [
422
- h(g(s.value.is_home ? e(a)("pages.home") : se.value), 1)
431
+ y(b(i.value.is_home ? e(a)("pages.home") : ne.value), 1)
423
432
  ]),
424
433
  _: 1
425
434
  })
426
435
  ]),
427
436
  _: 1
428
437
  }, 8, ["label"]),
429
- N("div", xt, [
430
- N("span", kt, g(s.value.is_home ? e(a)("pages.home") : se.value || e(a)("page.untitled")), 1),
431
- f(e(We), {
432
- type: b(),
438
+ E("div", kt, [
439
+ E("span", Tt, b(i.value.is_home ? e(a)("pages.home") : ne.value || e(a)("page.untitled")), 1),
440
+ v(e(we), {
441
+ type: Re(),
433
442
  dot: ""
434
443
  }, {
435
444
  default: n(() => [
436
- h(g(e(a)(`page.status-${s.value.status}`)), 1)
437
- ]),
438
- _: 1
439
- }, 8, ["type"]),
440
- f(e(O), {
441
- size: "sm",
442
- tone: "muted",
443
- class: "wx-page-editor__state"
444
- }, {
445
- default: n(() => [
446
- h(g(e(a)(`page.state-${ne.value}`)), 1)
445
+ y(b(e(a)(`page.status-${i.value.status}`)), 1)
447
446
  ]),
448
447
  _: 1
449
- })
448
+ }, 8, ["type"])
450
449
  ])
451
450
  ]),
452
- N("div", $t, [
453
- L.value ? (d(), x(e(Le), {
451
+ E("div", $t, [
452
+ ce.value ? (m(), V(e(st), {
454
453
  key: 0,
455
454
  align: "end"
456
455
  }, {
457
456
  trigger: n(() => [
458
- f(e($e), {
457
+ v(e(ot), {
459
458
  type: "more",
460
459
  title: e(a)("page.more")
461
460
  }, null, 8, ["title"])
462
461
  ]),
463
462
  default: n(() => [
464
- T.value ? (d(), x(e(re), {
463
+ _.value ? (m(), V(e(We), {
465
464
  key: 0,
466
465
  icon: "eye",
467
- href: T.value,
466
+ href: _.value,
468
467
  target: "_blank",
469
468
  rel: "noopener"
470
469
  }, {
471
470
  default: n(() => [
472
- h(g(e(a)("page.preview")), 1)
471
+ y(b(e(a)("page.preview")), 1)
473
472
  ]),
474
473
  _: 1
475
- }, 8, ["href"])) : D("", !0),
476
- s.value.url && s.value.status !== "draft" ? (d(), x(e(re), {
474
+ }, 8, ["href"])) : N("", !0),
475
+ i.value.url && i.value.status !== "draft" ? (m(), V(e(We), {
477
476
  key: 1,
478
477
  icon: "link",
479
- href: s.value.url,
478
+ href: i.value.url,
480
479
  target: "_blank",
481
480
  rel: "noopener"
482
481
  }, {
483
482
  default: n(() => [
484
- h(g(e(a)("page.open-on-site")), 1)
485
- ]),
486
- _: 1
487
- }, 8, ["href"])) : D("", !0),
488
- I.value ? (d(), x(e(re), {
489
- key: 2,
490
- icon: "check",
491
- disabled: !B.value,
492
- onClick: K
493
- }, {
494
- default: n(() => [
495
- h(g(e(a)("page.save")), 1)
483
+ y(b(e(a)("page.open-on-site")), 1)
496
484
  ]),
497
485
  _: 1
498
- }, 8, ["disabled"])) : D("", !0)
486
+ }, 8, ["href"])) : N("", !0)
499
487
  ]),
500
488
  _: 1
501
- })) : (d(), M(F, { key: 1 }, [
502
- T.value ? (d(), x(e(R), {
489
+ })) : (m(), A(j, { key: 1 }, [
490
+ _.value ? (m(), V(e(I), {
503
491
  key: 0,
504
492
  variant: "text",
505
493
  icon: "eye",
506
- href: T.value,
494
+ href: _.value,
507
495
  target: "_blank",
508
496
  rel: "noopener"
509
497
  }, {
510
498
  default: n(() => [
511
- h(g(e(a)("page.preview")), 1)
499
+ y(b(e(a)("page.preview")), 1)
512
500
  ]),
513
501
  _: 1
514
- }, 8, ["href"])) : D("", !0),
515
- s.value.url && s.value.status !== "draft" ? (d(), x(e(R), {
502
+ }, 8, ["href"])) : N("", !0),
503
+ i.value.url && i.value.status !== "draft" ? (m(), V(e(I), {
516
504
  key: 1,
517
505
  variant: "text",
518
506
  icon: "link",
519
- href: s.value.url,
507
+ href: i.value.url,
520
508
  target: "_blank",
521
509
  rel: "noopener"
522
510
  }, {
523
511
  default: n(() => [
524
- h(g(e(a)("page.open-on-site")), 1)
525
- ]),
526
- _: 1
527
- }, 8, ["href"])) : D("", !0),
528
- I.value ? (d(), x(e(R), {
529
- key: 2,
530
- variant: "outline",
531
- loading: W.value,
532
- disabled: !B.value,
533
- onClick: K
534
- }, {
535
- default: n(() => [
536
- h(g(e(a)("page.save")), 1)
512
+ y(b(e(a)("page.open-on-site")), 1)
537
513
  ]),
538
514
  _: 1
539
- }, 8, ["loading", "disabled"])) : D("", !0)
540
- ], 64)),
541
- I.value ? (d(), x(e(R), {
542
- key: 2,
543
- type: "primary",
544
- loading: _.value,
545
- disabled: s.value.status === "published" && !B.value,
546
- onClick: _e
547
- }, {
548
- default: n(() => [
549
- h(g(e(a)("page.publish")), 1)
550
- ]),
551
- _: 1
552
- }, 8, ["loading", "disabled"])) : D("", !0)
515
+ }, 8, ["href"])) : N("", !0)
516
+ ], 64))
553
517
  ])
554
518
  ]),
555
- U.value ? (d(), x(e(Ve), {
519
+ U.value ? (m(), V(e(xe), {
556
520
  key: 0,
557
521
  type: "warning",
558
522
  title: e(a)("page.conflict-title"),
559
523
  description: U.value.message
560
524
  }, {
561
525
  actions: n(() => [
562
- f(e(R), {
526
+ v(e(I), {
563
527
  size: "sm",
564
528
  variant: "outline",
565
- onClick: me
529
+ onClick: X
566
530
  }, {
567
531
  default: n(() => [
568
- h(g(e(a)("page.conflict-theirs")), 1)
532
+ y(b(e(a)("page.conflict-theirs")), 1)
569
533
  ]),
570
534
  _: 1
571
535
  }),
572
- f(e(R), {
536
+ v(e(I), {
573
537
  size: "sm",
574
538
  type: "primary",
575
- onClick: Y
539
+ onClick: Ie
576
540
  }, {
577
541
  default: n(() => [
578
- h(g(e(a)("page.conflict-mine")), 1)
542
+ y(b(e(a)("page.conflict-mine")), 1)
579
543
  ]),
580
544
  _: 1
581
545
  })
582
546
  ]),
583
547
  _: 1
584
- }, 8, ["title", "description"])) : D("", !0),
585
- N("div", Tt, [
586
- f(e(tt), {
587
- modelValue: k.value,
588
- "onUpdate:modelValue": te[0] || (te[0] = (E) => k.value = E),
548
+ }, 8, ["title", "description"])) : N("", !0),
549
+ E("div", Pt, [
550
+ v(e(Ze), {
551
+ modelValue: x.value,
552
+ "onUpdate:modelValue": Y[0] || (Y[0] = (B) => x.value = B),
589
553
  name: "pages.form",
590
- errors: A.value,
591
- disabled: !I.value || _.value
554
+ errors: le.value,
555
+ disabled: !D.value || S.value
592
556
  }, null, 8, ["modelValue", "errors", "disabled"])
593
- ])
557
+ ]),
558
+ D.value ? (m(), V(e(it), { key: 1 }, {
559
+ state: n(() => [
560
+ v(e(R), {
561
+ size: "sm",
562
+ tone: "muted"
563
+ }, {
564
+ default: n(() => [
565
+ y(b(e(a)(`page.state-${ge.value}`)), 1)
566
+ ]),
567
+ _: 1
568
+ })
569
+ ]),
570
+ default: n(() => [
571
+ v(e(I), {
572
+ variant: "outline",
573
+ loading: $.value,
574
+ disabled: !L.value,
575
+ onClick: g
576
+ }, {
577
+ default: n(() => [
578
+ y(b(e(a)("page.save")), 1)
579
+ ]),
580
+ _: 1
581
+ }, 8, ["loading", "disabled"]),
582
+ v(e(I), {
583
+ type: "primary",
584
+ loading: S.value,
585
+ disabled: i.value.status === "published" && !L.value,
586
+ onClick: Ue
587
+ }, {
588
+ default: n(() => [
589
+ y(b(e(a)("page.publish")), 1)
590
+ ]),
591
+ _: 1
592
+ }, 8, ["loading", "disabled"])
593
+ ]),
594
+ _: 1
595
+ })) : N("", !0)
594
596
  ], 64))
595
597
  ], 544));
596
598
  }
597
- }), Vt = /* @__PURE__ */ de(Wt, [["__scopeId", "data-v-861519ac"]]), zt = { class: "wx-page-history" }, St = { class: "wx-page-history__number" }, Dt = { class: "wx-page-history__who" }, Mt = /* @__PURE__ */ H({
599
+ }), Ct = /* @__PURE__ */ re(zt, [["__scopeId", "data-v-597a1f2f"]]), Mt = { class: "wx-page-history" }, Dt = { class: "wx-page-history__number" }, St = { class: "wx-page-history__who" }, Bt = /* @__PURE__ */ K({
598
600
  name: "WxPageHistory",
599
601
  __name: "PageHistory",
600
- setup(v) {
601
- const u = X(), p = Z(u), l = ze();
602
- G();
603
- const i = j("webx-pages"), t = P(null), c = P(!1), a = V(() => l?.page.value ?? null), o = V(() => u.can("pages.manage")), s = V(
604
- () => a.value?.published_at ? t.value?.[0]?.number ?? null : null
602
+ setup(p) {
603
+ const r = G(), h = Z(r), l = ke();
604
+ H();
605
+ const s = F("webx-pages"), t = ie(), u = k(null), a = k(!1), d = W(() => l?.page.value ?? null), f = W(() => r.can("pages.manage")), i = W(
606
+ () => d.value?.published_at ? u.value?.[0]?.number ?? null : null
605
607
  );
606
- async function C() {
607
- const y = a.value;
608
- if (y)
608
+ async function T() {
609
+ const C = d.value;
610
+ if (C)
609
611
  try {
610
- t.value = await p.versions(y.id);
611
- } catch (S) {
612
- t.value = [], z.danger(T(S));
612
+ u.value = await h.versions(C.id);
613
+ } catch (_) {
614
+ u.value = [], z.danger(t(_));
613
615
  }
614
616
  }
615
- async function k(y) {
616
- const S = a.value;
617
- if (!(!S || !await le({
618
- title: i("page.restore-title", { number: y.number }),
619
- message: i("page.restore-text"),
620
- confirmText: i("page.restore"),
621
- cancelText: i("page.cancel")
617
+ async function x(C) {
618
+ const _ = d.value;
619
+ if (!(!_ || !await O({
620
+ title: s("page.restore-title", { number: C.number }),
621
+ message: s("page.restore-text"),
622
+ confirmText: s("page.restore"),
623
+ cancelText: s("page.cancel")
622
624
  }))) {
623
- c.value = !0;
625
+ a.value = !0;
624
626
  try {
625
- await p.restoreVersion(S.id, y.number), await l?.reload(), z.success(i("page.restored-version", { number: y.number }));
626
- } catch (_) {
627
- z.danger(T(_));
627
+ await h.restoreVersion(_.id, C.number), await l?.reload(), z.success(s("page.restored-version", { number: C.number }));
628
+ } catch (M) {
629
+ z.danger(t(M));
628
630
  } finally {
629
- c.value = !1;
631
+ a.value = !1;
630
632
  }
631
633
  }
632
634
  }
633
- function $(y) {
634
- return y.created_at ? new Date(y.created_at).toLocaleString(u.i18n.state.locale) : "";
635
- }
636
- function T(y) {
637
- return y.body?.message ?? String(y);
638
- }
639
635
  return ae(
640
- () => [a.value?.id, a.value?.published_at, a.value?.updated_at],
636
+ () => [d.value?.id, d.value?.published_at, d.value?.updated_at],
641
637
  () => {
642
- C();
638
+ T();
643
639
  },
644
640
  {
645
641
  immediate: !0
646
642
  }
647
- ), (y, S) => (d(), M("div", zt, [
648
- t.value === null ? (d(), x(e(ke), {
643
+ ), (C, _) => (m(), A("div", Mt, [
644
+ u.value === null ? (m(), V(e(be), {
649
645
  key: 0,
650
646
  rows: 3
651
- })) : t.value.length === 0 ? (d(), x(e(nt), {
647
+ })) : u.value.length === 0 ? (m(), V(e(rt), {
652
648
  key: 1,
653
- description: e(i)("page.history-empty")
654
- }, null, 8, ["description"])) : (d(!0), M(F, { key: 2 }, ie(t.value, (W) => (d(), M("div", {
655
- key: W.number,
656
- class: Qe(["wx-page-history__row", { "is-live": W.number === s.value }])
649
+ description: e(s)("page.history-empty")
650
+ }, null, 8, ["description"])) : (m(!0), A(j, { key: 2 }, De(u.value, (c) => (m(), A("div", {
651
+ key: c.number,
652
+ class: Fe(["wx-page-history__row", { "is-live": c.number === i.value }])
657
653
  }, [
658
- N("code", St, g(e(i)("page.version", { number: W.number })), 1),
659
- N("div", Dt, [
660
- f(e(O), null, {
661
- default: n(() => [
662
- h(g($(W)), 1)
663
- ]),
664
- _: 2
665
- }, 1024),
666
- f(e(O), {
654
+ E("code", Dt, b(e(s)("page.version", { number: c.number })), 1),
655
+ E("div", St, [
656
+ c.created_at ? (m(), V(e(me), {
657
+ key: 0,
658
+ value: c.created_at,
659
+ size: "md",
660
+ tone: "default"
661
+ }, null, 8, ["value"])) : N("", !0),
662
+ v(e(R), {
667
663
  size: "sm",
668
664
  tone: "muted"
669
665
  }, {
670
666
  default: n(() => [
671
- h(g(W.author ?? e(i)(`page.source-${W.source}`)) + " ", 1),
672
- W.comment ? (d(), M(F, { key: 0 }, [
673
- h(" · " + g(W.comment), 1)
674
- ], 64)) : D("", !0)
667
+ y(b(c.author ?? e(s)(`page.source-${c.source}`)) + " ", 1),
668
+ c.comment ? (m(), A(j, { key: 0 }, [
669
+ y(" · " + b(c.comment), 1)
670
+ ], 64)) : N("", !0)
675
671
  ]),
676
672
  _: 2
677
673
  }, 1024)
678
674
  ]),
679
- W.number === s.value ? (d(), x(e(We), {
675
+ c.number === i.value ? (m(), V(e(we), {
680
676
  key: 0,
681
677
  type: "success",
682
678
  dot: ""
683
679
  }, {
684
680
  default: n(() => [
685
- h(g(e(i)("page.version-live")), 1)
681
+ y(b(e(s)("page.version-live")), 1)
686
682
  ]),
687
683
  _: 1
688
- })) : D("", !0),
689
- o.value && W.number !== s.value ? (d(), x(e(R), {
684
+ })) : N("", !0),
685
+ f.value && c.number !== i.value ? (m(), V(e(I), {
690
686
  key: 1,
691
687
  size: "sm",
692
688
  variant: "outline",
693
- loading: c.value,
694
- onClick: (_) => k(W)
689
+ loading: a.value,
690
+ onClick: (M) => x(c)
695
691
  }, {
696
692
  default: n(() => [
697
- h(g(e(i)("page.restore")), 1)
693
+ y(b(e(s)("page.restore")), 1)
698
694
  ]),
699
695
  _: 1
700
- }, 8, ["loading", "onClick"])) : D("", !0)
696
+ }, 8, ["loading", "onClick"])) : N("", !0)
701
697
  ], 2))), 128))
702
698
  ]));
703
699
  }
704
- }), At = /* @__PURE__ */ de(Mt, [["__scopeId", "data-v-d24bb671"]]), Se = /* @__PURE__ */ H({
700
+ }), Nt = /* @__PURE__ */ re(Bt, [["__scopeId", "data-v-91e617ec"]]), Te = /* @__PURE__ */ K({
705
701
  __name: "PagePicker",
706
- props: /* @__PURE__ */ Ye({
702
+ props: /* @__PURE__ */ je({
707
703
  exclude: { default: () => [] },
708
704
  placeholder: { default: void 0 },
709
705
  selected: { default: () => [] }
@@ -712,282 +708,203 @@ const gt = { class: "wx-page-danger" }, vt = {
712
708
  modelModifiers: {}
713
709
  }),
714
710
  emits: ["update:modelValue"],
715
- setup(v) {
716
- const u = v, p = Xe(v, "modelValue"), l = X(), i = Z(l);
717
- G();
718
- const t = j("webx-pages"), c = P([]);
719
- ye(async () => {
720
- const s = await i.list();
721
- s.home && (c.value = [
711
+ setup(p) {
712
+ const r = p, h = He(p, "modelValue"), l = G(), s = Z(l);
713
+ H();
714
+ const t = F("webx-pages"), u = k([]);
715
+ pe(async () => {
716
+ const f = await s.list();
717
+ f.home && (u.value = [
722
718
  a(
723
- s.home,
724
- s.items.map((C) => a(C))
719
+ f.home,
720
+ f.items.map((i) => a(i))
725
721
  )
726
722
  ]);
727
723
  });
728
- function a(s, C) {
724
+ function a(f, i) {
729
725
  return {
730
- id: s.id,
731
- label: s.is_home ? t("pages.home") : s.title,
732
- disabled: u.exclude.includes(s.id),
733
- leaf: s.children_count === 0,
734
- ...C ? { children: C } : {}
726
+ id: f.id,
727
+ label: f.is_home ? t("pages.home") : f.title,
728
+ disabled: r.exclude.includes(f.id),
729
+ leaf: f.children_count === 0,
730
+ ...i ? { children: i } : {}
735
731
  };
736
732
  }
737
- async function o(s) {
738
- return (await i.list({ parent: Number(s.id) })).items.map((k) => a(k));
733
+ async function d(f) {
734
+ return (await s.list({ parent: Number(f.id) })).items.map((T) => a(T));
739
735
  }
740
- return (s, C) => (d(), x(e(st), {
741
- modelValue: p.value,
742
- "onUpdate:modelValue": C[0] || (C[0] = (k) => p.value = k),
743
- nodes: c.value,
736
+ return (f, i) => (m(), V(e(ut), {
737
+ modelValue: h.value,
738
+ "onUpdate:modelValue": i[0] || (i[0] = (T) => h.value = T),
739
+ nodes: u.value,
744
740
  lazy: "",
745
- load: o,
741
+ load: d,
746
742
  "show-path": "",
747
743
  clearable: "",
748
- "selected-path": u.selected.map((k) => ({
749
- id: k.id,
750
- label: k.is_home ? e(t)("pages.home") : k.title
744
+ "selected-path": r.selected.map((T) => ({
745
+ id: T.id,
746
+ label: T.is_home ? e(t)("pages.home") : T.title
751
747
  })),
752
- placeholder: u.placeholder ?? e(t)("page.field-parent"),
748
+ placeholder: r.placeholder ?? e(t)("page.field-parent"),
753
749
  "aria-label": e(t)("page.field-parent"),
754
750
  teleport: ""
755
751
  }, null, 8, ["modelValue", "nodes", "selected-path", "placeholder", "aria-label"]));
756
752
  }
757
- }), Bt = {
753
+ }), At = {
758
754
  key: 0,
759
755
  class: "wx-page-place"
760
- }, Nt = /* @__PURE__ */ H({
756
+ }, Et = /* @__PURE__ */ K({
761
757
  name: "WxPagePlace",
762
758
  __name: "PagePlace",
763
- setup(v) {
764
- const u = X(), p = Z(u), l = ze(), i = Ue();
765
- G();
766
- const t = j("webx-pages"), c = P(!1), a = P(null), o = V(() => l?.page.value ?? null), s = V(() => l?.ancestors.value.length === 0 ? null : l?.prefixes.value[i.active.value] ?? null), C = V(() => {
767
- const T = l?.values.value.slug;
768
- return typeof T == "string" ? T : T?.[i.active.value] ?? "";
769
- }), k = V(() => o.value?.is_home ? "/" : s.value === null || C.value === "" ? null : `/${[s.value, C.value].filter(Boolean).join("/")}`);
759
+ setup(p) {
760
+ const r = G(), h = Z(r), l = ke(), s = Be();
761
+ H();
762
+ const t = F("webx-pages"), u = ie(), a = k(!1), d = k(null), f = W(() => l?.page.value ?? null), i = W(() => l?.ancestors.value.length === 0 ? null : l?.prefixes.value[s.active.value] ?? null), T = W(() => {
763
+ const _ = l?.values.value.slug;
764
+ return typeof _ == "string" ? _ : _?.[s.active.value] ?? "";
765
+ }), x = W(() => f.value?.is_home ? "/" : i.value === null || T.value === "" ? null : `/${[i.value, T.value].filter(Boolean).join("/")}`);
770
766
  ae(
771
- o,
772
- (T) => {
773
- a.value = T?.parent_id ?? null;
767
+ f,
768
+ (_) => {
769
+ d.value = _?.parent_id ?? null;
774
770
  },
775
771
  { immediate: !0 }
776
772
  );
777
- async function $(T) {
778
- const y = o.value;
779
- if (!(!y || T === null || T === y.parent_id || c.value)) {
780
- c.value = !0;
781
- try {
782
- const S = await p.move(y.id, T, "inside");
783
- z.success(
784
- S.addresses_changed > 1 ? t("page.moved", { count: S.addresses_changed }) : t("page.moved-one")
785
- ), await l?.reload();
786
- } catch (S) {
787
- z.danger(S.body?.message ?? String(S)), a.value = y.parent_id;
788
- } finally {
789
- c.value = !1;
790
- }
773
+ async function C(_) {
774
+ const c = f.value;
775
+ if (!c || _ === null || _ === c.parent_id || a.value) return;
776
+ const M = c.descendants_count + 1;
777
+ if (M > 1 && !await O({
778
+ title: t("page.move-title", { title: c.title }),
779
+ message: t("page.move-branch", { count: M }),
780
+ confirmText: t("page.move-confirm"),
781
+ cancelText: t("page.cancel")
782
+ })) {
783
+ d.value = c.parent_id;
784
+ return;
785
+ }
786
+ a.value = !0;
787
+ try {
788
+ const $ = await h.move(c.id, _, "inside");
789
+ z.success(
790
+ $.addresses_changed > 1 ? t("page.moved", { count: $.addresses_changed }) : t("page.moved-one")
791
+ ), await l?.reload();
792
+ } catch ($) {
793
+ z.danger(u($)), d.value = c.parent_id;
794
+ } finally {
795
+ a.value = !1;
791
796
  }
792
797
  }
793
- return (T, y) => o.value ? (d(), M("div", Bt, [
794
- f(e(ue), {
798
+ return (_, c) => f.value ? (m(), A("div", At, [
799
+ v(e(oe), {
795
800
  label: e(t)("page.address")
796
801
  }, {
797
802
  default: n(() => [
798
- k.value ? (d(), x(e(O), {
803
+ x.value ? (m(), V(e(R), {
799
804
  key: 0,
800
805
  mono: "",
801
806
  class: "wx-page-place__address"
802
807
  }, {
803
808
  default: n(() => [
804
- h(g(k.value), 1)
809
+ y(b(x.value), 1)
805
810
  ]),
806
811
  _: 1
807
- })) : (d(), x(e(O), {
812
+ })) : (m(), V(e(R), {
808
813
  key: 1,
809
814
  size: "sm",
810
815
  tone: "muted"
811
816
  }, {
812
817
  default: n(() => [
813
- h(g(e(t)("page.no-address")), 1)
818
+ y(b(e(t)("page.no-address")), 1)
814
819
  ]),
815
820
  _: 1
816
821
  }))
817
822
  ]),
818
823
  _: 1
819
824
  }, 8, ["label"]),
820
- o.value.can.move ? (d(), M(F, { key: 0 }, [
821
- f(e(ue), {
825
+ f.value.can.move ? (m(), A(j, { key: 0 }, [
826
+ v(e(oe), {
822
827
  label: e(t)("page.field-parent"),
823
828
  help: e(t)("page.parent-help")
824
829
  }, {
825
830
  default: n(() => [
826
- f(Se, {
827
- modelValue: a.value,
831
+ v(Te, {
832
+ modelValue: d.value,
828
833
  "onUpdate:modelValue": [
829
- y[0] || (y[0] = (S) => a.value = S),
830
- $
834
+ c[0] || (c[0] = (M) => d.value = M),
835
+ C
831
836
  ],
832
- exclude: [o.value.id],
837
+ exclude: [f.value.id],
833
838
  selected: e(l)?.ancestors.value ?? []
834
839
  }, null, 8, ["modelValue", "exclude", "selected"])
835
840
  ]),
836
841
  _: 1
837
842
  }, 8, ["label", "help"]),
838
- f(e(Ve), {
843
+ v(e(xe), {
839
844
  type: "info",
840
845
  variant: "soft",
841
846
  description: e(t)("page.parent-warning")
842
847
  }, null, 8, ["description"])
843
- ], 64)) : D("", !0)
844
- ])) : D("", !0);
848
+ ], 64)) : N("", !0)
849
+ ])) : N("", !0);
845
850
  }
846
- }), Et = /* @__PURE__ */ de(Nt, [["__scopeId", "data-v-1adcb4ab"]]), Ne = /* @__PURE__ */ H({
851
+ }), It = /* @__PURE__ */ re(Et, [["__scopeId", "data-v-bf094be2"]]), Ut = /* @__PURE__ */ K({
847
852
  __name: "PageActions",
848
853
  props: {
849
854
  page: {},
850
- inBin: { type: Boolean, default: !1 },
851
- menuOnly: { type: Boolean, default: !1 }
855
+ inBin: { type: Boolean, default: !1 }
852
856
  },
853
857
  emits: ["open", "add", "duplicate", "move", "copy", "remove", "restore"],
854
- setup(v, { emit: u }) {
855
- const p = v, l = u;
856
- G();
857
- const i = j("webx-pages"), t = V(() => {
858
- const c = p.page;
859
- if (p.inBin)
858
+ setup(p, { emit: r }) {
859
+ const h = p, l = r;
860
+ H();
861
+ const s = F("webx-pages"), t = W(() => {
862
+ const u = h.page;
863
+ if (h.inBin)
860
864
  return [
861
865
  {
862
866
  key: "restore",
863
- type: "restore",
864
867
  icon: "refresh",
865
- label: i("page.restore"),
866
- run: () => l("restore", c)
868
+ label: s("page.restore"),
869
+ run: () => l("restore", u)
867
870
  }
868
871
  ];
869
872
  const a = [
870
- {
871
- key: "open",
872
- type: "edit",
873
- icon: "edit",
874
- label: i("page.open"),
875
- run: () => l("open", c)
876
- },
877
- {
878
- key: "add",
879
- type: "add",
880
- icon: "plus",
881
- label: i("page.add-child"),
882
- run: () => l("add", c)
883
- }
873
+ { key: "open", icon: "edit", label: s("page.open"), run: () => l("open", u) },
874
+ { key: "add", icon: "plus", label: s("page.add-child"), run: () => l("add", u) }
884
875
  ];
885
- return c.is_home || a.push({
876
+ return u.is_home || a.push({
886
877
  key: "duplicate",
887
- type: "copy",
888
878
  icon: "copy",
889
- label: i("page.duplicate"),
890
- run: () => l("duplicate", c)
891
- }), c.can.move && a.push({
892
- key: "move",
893
- type: "sort",
894
- icon: "drag",
895
- label: i("page.move"),
896
- run: () => l("move", c)
897
- }), a.push(
879
+ label: s("page.duplicate"),
880
+ run: () => l("duplicate", u)
881
+ }), u.can.move && a.push({ key: "move", icon: "drag", label: s("page.move"), run: () => l("move", u) }), a.push(
898
882
  {
899
883
  key: "copy-address",
900
- type: "link",
901
884
  icon: "link",
902
- label: i("page.copy-address"),
903
- disabled: !c.url,
904
- run: () => l("copy", c)
885
+ label: s("page.copy-address"),
886
+ disabled: !u.url,
887
+ run: () => l("copy", u)
905
888
  },
906
889
  {
907
890
  key: "on-site",
908
- type: "goto",
909
891
  icon: "external-link",
910
- label: i("page.open-on-site"),
911
- disabled: !c.url,
912
- href: c.url ?? void 0
892
+ label: s("page.open-on-site"),
893
+ disabled: !u.url,
894
+ href: u.url ?? void 0
913
895
  }
914
- ), c.can.delete && a.push({
896
+ ), u.can.delete && a.push({
915
897
  key: "delete",
916
- type: "remove",
917
898
  icon: "trash",
918
- label: i("page.delete"),
899
+ label: s("page.delete"),
919
900
  danger: !0,
920
- run: () => l("remove", c)
901
+ run: () => l("remove", u)
921
902
  }), a;
922
903
  });
923
- return (c, a) => p.menuOnly ? (d(), x(e(Le), {
924
- key: 0,
925
- align: "end",
926
- onClick: a[0] || (a[0] = xe(() => {
927
- }, ["stop"]))
928
- }, {
929
- trigger: n(() => [
930
- f(e($e), {
931
- type: "more",
932
- size: "sm",
933
- title: p.page.title
934
- }, null, 8, ["title"])
935
- ]),
936
- default: n(() => [
937
- (d(!0), M(F, null, ie(t.value, (o) => (d(), x(e(re), {
938
- key: o.key,
939
- icon: o.icon,
940
- tone: o.danger ? "danger" : "default",
941
- href: o.href,
942
- target: o.href ? "_blank" : void 0,
943
- disabled: o.disabled,
944
- onClick: (s) => o.run?.()
945
- }, {
946
- default: n(() => [
947
- h(g(o.label), 1)
948
- ]),
949
- _: 2
950
- }, 1032, ["icon", "tone", "href", "target", "disabled", "onClick"]))), 128))
951
- ]),
952
- _: 1
953
- })) : (d(), x(e(ot), {
954
- key: 1,
955
- size: "sm",
956
- align: "end",
957
- collapse: "",
958
- "aria-label": p.page.title,
959
- onClick: a[1] || (a[1] = xe(() => {
960
- }, ["stop"]))
961
- }, {
962
- collapsed: n(() => [
963
- (d(!0), M(F, null, ie(t.value, (o) => (d(), x(e(re), {
964
- key: o.key,
965
- icon: o.icon,
966
- tone: o.danger ? "danger" : "default",
967
- href: o.href,
968
- target: o.href ? "_blank" : void 0,
969
- disabled: o.disabled,
970
- onClick: (s) => o.run?.()
971
- }, {
972
- default: n(() => [
973
- h(g(o.label), 1)
974
- ]),
975
- _: 2
976
- }, 1032, ["icon", "tone", "href", "target", "disabled", "onClick"]))), 128))
977
- ]),
978
- default: n(() => [
979
- (d(!0), M(F, null, ie(t.value, (o) => (d(), x(e($e), {
980
- key: o.key,
981
- type: o.type,
982
- title: o.label,
983
- href: o.href,
984
- target: o.href ? "_blank" : void 0,
985
- disabled: o.disabled,
986
- onClick: (s) => o.run?.()
987
- }, null, 8, ["type", "title", "href", "target", "disabled", "onClick"]))), 128))
988
- ]),
989
- _: 1
990
- }, 8, ["aria-label"]));
904
+ return (u, a) => (m(), V(e(qe), {
905
+ actions: t.value,
906
+ label: h.page.title
907
+ }, null, 8, ["actions", "label"]));
991
908
  }
992
909
  }), Rt = {
993
910
  а: "a",
@@ -1048,67 +965,67 @@ const gt = { class: "wx-page-danger" }, vt = {
1048
965
  ź: "z",
1049
966
  ż: "z"
1050
967
  };
1051
- function Ot(v) {
1052
- return v.toLowerCase().split("").map((u) => Rt[u] ?? u).join("").normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
968
+ function Lt(p) {
969
+ return p.toLowerCase().split("").map((r) => Rt[r] ?? r).join("").normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
1053
970
  }
1054
- const Ut = /* @__PURE__ */ H({
971
+ const Ot = /* @__PURE__ */ K({
1055
972
  __name: "PageCreateDialog",
1056
973
  props: {
1057
974
  parent: { default: null }
1058
975
  },
1059
- setup(v) {
1060
- const u = v, { open: p, resolve: l, dismiss: i } = Fe(), t = X(), c = Z(t);
1061
- G();
1062
- const a = j("webx-pages"), o = P(""), s = P(""), C = P(u.parent?.id ?? null), k = P(!1), $ = P({}), T = Pe("field"), y = P(!1);
1063
- ae(o, (W) => {
1064
- y.value || (s.value = Ot(W));
1065
- }), ye(async () => {
1066
- await Ze(), T.value?.querySelector("input")?.focus();
976
+ setup(p) {
977
+ const r = p, { open: h, resolve: l, dismiss: s } = Ne(), t = G(), u = Z(t);
978
+ H();
979
+ const a = F("webx-pages"), d = k(""), f = k(""), i = k(r.parent?.id ?? null), T = k(!1), x = k({}), C = Me("field"), _ = k(!1);
980
+ ae(d, (M) => {
981
+ _.value || (f.value = Lt(M));
982
+ }), pe(async () => {
983
+ await Ge(), C.value?.querySelector("input")?.focus();
1067
984
  });
1068
- async function S() {
1069
- if (!(o.value.trim() === "" || k.value)) {
1070
- k.value = !0, $.value = {};
985
+ async function c() {
986
+ if (!(d.value.trim() === "" || T.value)) {
987
+ T.value = !0, x.value = {};
1071
988
  try {
1072
989
  l(
1073
- await c.create({
1074
- title: o.value.trim(),
1075
- slug: s.value.trim(),
1076
- parent_id: C.value
990
+ await u.create({
991
+ title: d.value.trim(),
992
+ slug: f.value.trim(),
993
+ parent_id: i.value
1077
994
  })
1078
995
  );
1079
- } catch (W) {
1080
- $.value = W.body?.errors ?? {};
996
+ } catch (M) {
997
+ x.value = M.body?.errors ?? {};
1081
998
  } finally {
1082
- k.value = !1;
999
+ T.value = !1;
1083
1000
  }
1084
1001
  }
1085
1002
  }
1086
- return (W, _) => (d(), x(e(Ke), {
1087
- open: e(p),
1088
- "onUpdate:open": _[5] || (_[5] = (A) => Re(p) ? p.value = A : null),
1003
+ return (M, $) => (m(), V(e(Ae), {
1004
+ open: e(h),
1005
+ "onUpdate:open": $[5] || ($[5] = (S) => Se(h) ? h.value = S : null),
1089
1006
  title: e(a)("page.new-title"),
1090
1007
  width: 460
1091
1008
  }, {
1092
1009
  footer: n(() => [
1093
- f(e(Te), { size: "sm" }, {
1010
+ v(e(_e), { size: "sm" }, {
1094
1011
  default: n(() => [
1095
- f(e(R), {
1012
+ v(e(I), {
1096
1013
  variant: "outline",
1097
- onClick: _[4] || (_[4] = (A) => e(i)())
1014
+ onClick: $[4] || ($[4] = (S) => e(s)())
1098
1015
  }, {
1099
1016
  default: n(() => [
1100
- h(g(e(a)("page.cancel")), 1)
1017
+ y(b(e(a)("page.cancel")), 1)
1101
1018
  ]),
1102
1019
  _: 1
1103
1020
  }),
1104
- f(e(R), {
1021
+ v(e(I), {
1105
1022
  type: "primary",
1106
- loading: k.value,
1107
- disabled: o.value.trim() === "",
1108
- onClick: S
1023
+ loading: T.value,
1024
+ disabled: d.value.trim() === "",
1025
+ onClick: c
1109
1026
  }, {
1110
1027
  default: n(() => [
1111
- h(g(e(a)("page.create")), 1)
1028
+ y(b(e(a)("page.create")), 1)
1112
1029
  ]),
1113
1030
  _: 1
1114
1031
  }, 8, ["loading", "disabled"])
@@ -1117,51 +1034,51 @@ const Ut = /* @__PURE__ */ H({
1117
1034
  })
1118
1035
  ]),
1119
1036
  default: n(() => [
1120
- f(e(ue), {
1037
+ v(e(oe), {
1121
1038
  label: e(a)("page.field-title"),
1122
- error: $.value.title?.[0],
1039
+ error: x.value.title?.[0],
1123
1040
  required: ""
1124
1041
  }, {
1125
1042
  default: n(() => [
1126
- N("div", {
1043
+ E("div", {
1127
1044
  ref_key: "field",
1128
- ref: T
1045
+ ref: C
1129
1046
  }, [
1130
- f(e(Me), {
1131
- modelValue: o.value,
1132
- "onUpdate:modelValue": _[0] || (_[0] = (A) => o.value = A),
1047
+ v(e(Ve), {
1048
+ modelValue: d.value,
1049
+ "onUpdate:modelValue": $[0] || ($[0] = (S) => d.value = S),
1133
1050
  "aria-label": e(a)("page.field-title"),
1134
- onKeyup: De(S, ["enter"])
1051
+ onKeyup: Pe(c, ["enter"])
1135
1052
  }, null, 8, ["modelValue", "aria-label"])
1136
1053
  ], 512)
1137
1054
  ]),
1138
1055
  _: 1
1139
1056
  }, 8, ["label", "error"]),
1140
- f(e(ue), {
1057
+ v(e(oe), {
1141
1058
  label: e(a)("page.field-slug"),
1142
- error: $.value.slug?.[0],
1059
+ error: x.value.slug?.[0],
1143
1060
  help: e(a)("page.slug-help")
1144
1061
  }, {
1145
1062
  default: n(() => [
1146
- f(e(Me), {
1147
- modelValue: s.value,
1148
- "onUpdate:modelValue": _[1] || (_[1] = (A) => s.value = A),
1063
+ v(e(Ve), {
1064
+ modelValue: f.value,
1065
+ "onUpdate:modelValue": $[1] || ($[1] = (S) => f.value = S),
1149
1066
  "aria-label": e(a)("page.field-slug"),
1150
- onInput: _[2] || (_[2] = (A) => y.value = !0),
1151
- onKeyup: De(S, ["enter"])
1067
+ onInput: $[2] || ($[2] = (S) => _.value = !0),
1068
+ onKeyup: Pe(c, ["enter"])
1152
1069
  }, null, 8, ["modelValue", "aria-label"])
1153
1070
  ]),
1154
1071
  _: 1
1155
1072
  }, 8, ["label", "error", "help"]),
1156
- f(e(ue), {
1073
+ v(e(oe), {
1157
1074
  label: e(a)("page.field-parent"),
1158
- error: $.value.parent_id?.[0]
1075
+ error: x.value.parent_id?.[0]
1159
1076
  }, {
1160
1077
  default: n(() => [
1161
- f(Se, {
1162
- modelValue: C.value,
1163
- "onUpdate:modelValue": _[3] || (_[3] = (A) => C.value = A),
1164
- selected: u.parent ? [u.parent] : []
1078
+ v(Te, {
1079
+ modelValue: i.value,
1080
+ "onUpdate:modelValue": $[3] || ($[3] = (S) => i.value = S),
1081
+ selected: r.parent ? [r.parent] : []
1165
1082
  }, null, 8, ["modelValue", "selected"])
1166
1083
  ]),
1167
1084
  _: 1
@@ -1170,40 +1087,40 @@ const Ut = /* @__PURE__ */ H({
1170
1087
  _: 1
1171
1088
  }, 8, ["open", "title"]));
1172
1089
  }
1173
- }), It = /* @__PURE__ */ H({
1090
+ }), Kt = /* @__PURE__ */ K({
1174
1091
  __name: "PageMoveDialog",
1175
1092
  props: {
1176
1093
  page: {}
1177
1094
  },
1178
- setup(v) {
1179
- const u = v, { open: p, resolve: l, dismiss: i } = Fe();
1180
- G();
1181
- const t = j("webx-pages"), c = P(u.page.parent_id);
1182
- return (a, o) => (d(), x(e(Ke), {
1183
- open: e(p),
1184
- "onUpdate:open": o[3] || (o[3] = (s) => Re(p) ? p.value = s : null),
1185
- title: e(t)("page.move-title", { title: u.page.title }),
1095
+ setup(p) {
1096
+ const r = p, { open: h, resolve: l, dismiss: s } = Ne();
1097
+ H();
1098
+ const t = F("webx-pages"), u = k(r.page.parent_id);
1099
+ return (a, d) => (m(), V(e(Ae), {
1100
+ open: e(h),
1101
+ "onUpdate:open": d[3] || (d[3] = (f) => Se(h) ? h.value = f : null),
1102
+ title: e(t)("page.move-title", { title: r.page.title }),
1186
1103
  width: 460
1187
1104
  }, {
1188
1105
  footer: n(() => [
1189
- f(e(Te), { size: "sm" }, {
1106
+ v(e(_e), { size: "sm" }, {
1190
1107
  default: n(() => [
1191
- f(e(R), {
1108
+ v(e(I), {
1192
1109
  variant: "outline",
1193
- onClick: o[1] || (o[1] = (s) => e(i)())
1110
+ onClick: d[1] || (d[1] = (f) => e(s)())
1194
1111
  }, {
1195
1112
  default: n(() => [
1196
- h(g(e(t)("page.cancel")), 1)
1113
+ y(b(e(t)("page.cancel")), 1)
1197
1114
  ]),
1198
1115
  _: 1
1199
1116
  }),
1200
- f(e(R), {
1117
+ v(e(I), {
1201
1118
  type: "primary",
1202
- disabled: c.value === null || c.value === u.page.parent_id,
1203
- onClick: o[2] || (o[2] = (s) => e(l)(c.value))
1119
+ disabled: u.value === null || u.value === r.page.parent_id,
1120
+ onClick: d[2] || (d[2] = (f) => e(l)(u.value))
1204
1121
  }, {
1205
1122
  default: n(() => [
1206
- h(g(e(t)("page.move-confirm")), 1)
1123
+ y(b(e(t)("page.move-confirm")), 1)
1207
1124
  ]),
1208
1125
  _: 1
1209
1126
  }, 8, ["disabled"])
@@ -1212,21 +1129,21 @@ const Ut = /* @__PURE__ */ H({
1212
1129
  })
1213
1130
  ]),
1214
1131
  default: n(() => [
1215
- f(e(Te), {
1132
+ v(e(_e), {
1216
1133
  direction: "vertical",
1217
1134
  size: "md",
1218
1135
  fill: ""
1219
1136
  }, {
1220
1137
  default: n(() => [
1221
- f(e(Ve), {
1138
+ v(e(xe), {
1222
1139
  type: "info",
1223
1140
  variant: "soft",
1224
1141
  description: e(t)("page.move-help")
1225
1142
  }, null, 8, ["description"]),
1226
- f(Se, {
1227
- modelValue: c.value,
1228
- "onUpdate:modelValue": o[0] || (o[0] = (s) => c.value = s),
1229
- exclude: [u.page.id]
1143
+ v(Te, {
1144
+ modelValue: u.value,
1145
+ "onUpdate:modelValue": d[0] || (d[0] = (f) => u.value = f),
1146
+ exclude: [r.page.id]
1230
1147
  }, null, 8, ["modelValue", "exclude"])
1231
1148
  ]),
1232
1149
  _: 1
@@ -1235,32 +1152,32 @@ const Ut = /* @__PURE__ */ H({
1235
1152
  _: 1
1236
1153
  }, 8, ["open", "title"]));
1237
1154
  }
1238
- }), Lt = { class: "wx-pages__head" }, Ft = { class: "wx-pages__title" }, Kt = ["href"], Ee = 640, Ht = /* @__PURE__ */ H({
1155
+ }), Ft = { class: "wx-pages" }, Ht = { class: "wx-pages__title" }, jt = ["href"], Gt = /* @__PURE__ */ K({
1239
1156
  __name: "PagesPage",
1240
1157
  props: {
1241
1158
  base: { default: "/pages" }
1242
1159
  },
1243
- setup(v) {
1244
- const u = v, p = X(), l = Z(p), i = Ce();
1245
- G();
1246
- const t = j("webx-pages"), c = P(null), a = P([]), o = P(!0), s = P(""), C = P(""), k = Pe("root"), $ = Ie(k), T = V(() => $.value > 0 && $.value < Ee), y = Ae(Ut), S = Ae(It), W = V(() => p.can("pages.manage")), _ = V(() => C.value === "trashed"), A = V(() => !_.value && !T.value && s.value.trim() === ""), U = V(
1247
- () => p.state.manifest?.modules.find((r) => r.id === "pages")?.title ?? t("module.title")
1248
- ), q = V(() => [
1160
+ setup(p) {
1161
+ const r = p, h = G(), l = Z(h), s = ye();
1162
+ H();
1163
+ const t = F("webx-pages"), u = ie(), a = k(null), d = k([]), f = k(!0), i = k(""), T = k(""), x = ze(Ot), C = ze(Kt), _ = W(() => h.can("pages.manage")), c = W(() => T.value === "trashed"), M = W(() => !c.value && i.value.trim() === ""), $ = W(
1164
+ () => h.state.manifest?.modules.find((o) => o.id === "pages")?.title ?? t("module.title")
1165
+ ), S = W(() => [
1249
1166
  { value: "", label: t("page.filter-all") },
1250
1167
  { value: "draft", label: t("page.filter-draft") },
1251
1168
  { value: "published", label: t("page.filter-published") },
1252
1169
  { value: "modified", label: t("page.filter-modified") },
1253
1170
  { value: "trashed", label: t("page.bin"), icon: "trash" }
1254
- ]), ce = V(
1255
- () => A.value && c.value ? [{ ...c.value, children_count: 0 }, ...a.value] : a.value
1256
- ), I = V(() => [
1171
+ ]), le = W(
1172
+ () => M.value && a.value ? [{ ...a.value, children_count: 0 }, ...d.value] : d.value
1173
+ ), U = W(() => [
1257
1174
  { key: "title", label: t("page.column-title"), minWidth: 200 },
1258
- { key: "path", label: t("page.column-address"), width: 200 },
1175
+ { key: "path", label: t("page.column-address"), width: 200, hideBelow: 560 },
1259
1176
  // In the bin the state of a page is not what it was published as — it is off the site either
1260
1177
  // way — so the column says when it went in, which is what decides whether to bring it back.
1261
1178
  {
1262
1179
  key: "status",
1263
- label: _.value ? t("page.column-deleted") : t("page.column-status"),
1180
+ label: c.value ? t("page.column-deleted") : t("page.column-status"),
1264
1181
  align: "center",
1265
1182
  width: 130,
1266
1183
  hideBelow: 620
@@ -1270,304 +1187,282 @@ const Ut = /* @__PURE__ */ H({
1270
1187
  label: t("page.column-updated"),
1271
1188
  width: 180,
1272
1189
  hideBelow: 900,
1273
- hideOnCards: !0,
1274
- hidden: _.value
1190
+ hidden: c.value
1275
1191
  },
1276
- { key: "actions", label: "", width: 48, align: "right", hideOnCards: !0 }
1277
- ]), pe = V(
1278
- () => A.value ? {
1192
+ { key: "actions", label: "", width: 56, align: "right" }
1193
+ ]), q = W(
1194
+ () => M.value ? {
1279
1195
  childrenKey: "children",
1280
1196
  hasChildrenKey: "children_count",
1281
1197
  lazy: !0,
1282
- load: (r) => l.list({ parent: r.id }).then((b) => b.items),
1283
- draggable: W.value,
1284
- allowDrag: (r) => r.can.move,
1285
- allowDrop: ge
1198
+ load: (o) => l.list({ parent: o.id }).then((w) => w.items),
1199
+ draggable: _.value,
1200
+ allowDrag: (o) => o.can.move,
1201
+ allowDrop: ue
1286
1202
  } : void 0
1287
1203
  );
1288
- function ge(r, b, w) {
1289
- return b.is_home ? w === "inside" : r.id !== b.id;
1204
+ function ue(o, w, g) {
1205
+ return w.is_home ? g === "inside" : o.id !== w.id;
1290
1206
  }
1291
- async function L() {
1292
- o.value = !0;
1207
+ async function D() {
1208
+ f.value = !0;
1293
1209
  try {
1294
- const r = await l.list({
1295
- search: s.value.trim(),
1296
- status: _.value ? "" : C.value,
1297
- trashed: _.value,
1298
- flat: T.value
1210
+ const o = await l.list({
1211
+ search: i.value.trim(),
1212
+ status: c.value ? "" : T.value,
1213
+ trashed: c.value
1299
1214
  });
1300
- c.value = r.home, a.value = r.items;
1301
- } catch (r) {
1302
- z.danger(Y(r));
1215
+ a.value = o.home, d.value = o.items;
1216
+ } catch (o) {
1217
+ z.danger(u(o));
1303
1218
  } finally {
1304
- o.value = !1;
1219
+ f.value = !1;
1305
1220
  }
1306
1221
  }
1307
- function ee(r) {
1308
- r.search !== s.value && (s.value = r.search, L());
1222
+ function de(o) {
1223
+ o.search !== i.value && (i.value = o.search, D());
1309
1224
  }
1310
- function B(r) {
1311
- const b = `${u.base}/${r.id}`;
1312
- i.resolve(b).matched.length > 0 && i.push(b);
1225
+ function ee(o) {
1226
+ const w = `${r.base}/${o.id}`;
1227
+ s.resolve(w).matched.length > 0 && s.push(w);
1313
1228
  }
1314
- async function ne(r) {
1315
- const b = await y({ parent: r });
1316
- b && (await L(), B(b));
1229
+ async function ce(o) {
1230
+ const w = await x({ parent: o });
1231
+ w && (await D(), ee(w));
1317
1232
  }
1318
- async function se(r) {
1233
+ async function te(o) {
1319
1234
  try {
1320
- await l.duplicate(r.id), z.success(t("page.duplicated")), await L();
1321
- } catch (b) {
1322
- z.danger(Y(b));
1235
+ await l.duplicate(o.id), z.success(t("page.duplicated")), await D();
1236
+ } catch (w) {
1237
+ z.danger(u(w));
1323
1238
  }
1324
1239
  }
1325
- async function ve(r) {
1326
- const b = await S({ page: r });
1327
- b != null && await J(r, b, "inside");
1240
+ async function L(o) {
1241
+ const w = await C({ page: o });
1242
+ w != null && await ne(o, w, "inside");
1328
1243
  }
1329
- async function be(r) {
1330
- await J(r.row, r.target.id, r.zone);
1244
+ async function ge(o) {
1245
+ const w = o.zone === "inside" ? o.target.id : o.target.parent_id, g = o.row.descendants_count + 1;
1246
+ if (w !== o.row.parent_id && g > 1 && !await O({
1247
+ title: t("page.move-title", { title: o.row.title }),
1248
+ message: t("page.move-branch", { count: g }),
1249
+ confirmText: t("page.move-confirm"),
1250
+ cancelText: t("page.cancel")
1251
+ })) {
1252
+ await D();
1253
+ return;
1254
+ }
1255
+ await ne(o.row, o.target.id, o.zone);
1331
1256
  }
1332
- async function J(r, b, w) {
1257
+ async function ne(o, w, g) {
1333
1258
  try {
1334
- const m = await l.move(r.id, b, w);
1259
+ const X = await l.move(o.id, w, g);
1335
1260
  z.success(
1336
- m.addresses_changed > 1 ? t("page.moved", { count: m.addresses_changed }) : t("page.moved-one")
1261
+ X.addresses_changed > 1 ? t("page.moved", { count: X.addresses_changed }) : t("page.moved-one")
1337
1262
  );
1338
- } catch (m) {
1339
- z.danger(Y(m));
1263
+ } catch (X) {
1264
+ z.danger(u(X));
1340
1265
  } finally {
1341
- await L();
1266
+ await D();
1342
1267
  }
1343
1268
  }
1344
- async function Q(r) {
1345
- if (await le({
1346
- title: t("page.delete-title", { title: r.title }),
1269
+ async function ve(o) {
1270
+ if (await O({
1271
+ title: t("page.delete-title", { title: o.title }),
1347
1272
  message: (
1348
1273
  // The whole branch, not the level under it: a catalogue with two sections and forty
1349
1274
  // products is forty-two pages leaving the site, and "2" would be a comforting lie.
1350
- r.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: r.descendants_count })}` : t("page.delete-text")
1275
+ o.descendants_count > 0 ? `${t("page.delete-text")} ${t("page.delete-branch", { count: o.descendants_count })}` : t("page.delete-text")
1351
1276
  ),
1352
1277
  confirmText: t("page.delete"),
1353
1278
  cancelText: t("page.cancel"),
1354
1279
  tone: "danger"
1355
1280
  }))
1356
1281
  try {
1357
- await l.remove(r.id), z.success(t("page.deleted")), await L();
1358
- } catch (w) {
1359
- z.danger(Y(w));
1282
+ await l.remove(o.id), z.success(t("page.deleted")), await D();
1283
+ } catch (g) {
1284
+ z.danger(u(g));
1360
1285
  }
1361
1286
  }
1362
- async function fe(r) {
1363
- try {
1364
- await l.restore(r.id), z.success(t("page.restored")), await L();
1365
- } catch (b) {
1366
- z.danger(Y(b));
1367
- }
1287
+ async function he(o) {
1288
+ if (await O({
1289
+ title: t("page.restore-page-title", { title: o.title }),
1290
+ message: o.descendants_count > 0 ? `${t("page.restore-page-text")} ${t("page.restore-branch", { count: o.descendants_count })}` : t("page.restore-page-text"),
1291
+ confirmText: t("page.restore"),
1292
+ cancelText: t("page.cancel")
1293
+ }))
1294
+ try {
1295
+ const g = await l.restore(o.id);
1296
+ z.success(
1297
+ g > 1 ? t("page.restored-branch", { count: g }) : t("page.restored")
1298
+ ), await D();
1299
+ } catch (g) {
1300
+ z.danger(u(g));
1301
+ }
1368
1302
  }
1369
- async function he(r) {
1370
- if (r.url)
1303
+ async function J(o) {
1304
+ if (o.url)
1371
1305
  try {
1372
- await navigator.clipboard.writeText(r.url), z.success(t("page.address-copied"));
1306
+ await navigator.clipboard.writeText(o.url), z.success(t("page.address-copied"));
1373
1307
  } catch {
1374
1308
  }
1375
1309
  }
1376
- function K(r) {
1377
- return r === "published" ? "success" : r === "modified" ? "warning" : "default";
1378
- }
1379
- function me(r) {
1380
- const b = _.value ? r.deleted_at : r.updated_at;
1381
- return b ? new Date(b).toLocaleDateString() : "";
1382
- }
1383
- function Y(r) {
1384
- return r.body?.message ?? String(r);
1385
- }
1386
- function _e() {
1387
- L();
1310
+ function Q(o) {
1311
+ return o === "published" ? "success" : o === "modified" ? "warning" : "default";
1388
1312
  }
1389
1313
  return ae(T, () => {
1390
- L();
1391
- }), ye(L), (r, b) => (d(), M("div", {
1392
- ref_key: "root",
1393
- ref: k,
1394
- class: "wx-pages"
1395
- }, [
1396
- N("div", Lt, [
1397
- f(e(it), { level: 2 }, {
1398
- default: n(() => [
1399
- h(g(U.value), 1)
1400
- ]),
1401
- _: 1
1402
- }),
1403
- W.value ? (d(), x(e(R), {
1404
- key: 0,
1405
- type: "primary",
1406
- icon: "plus",
1407
- onClick: b[0] || (b[0] = (w) => ne(null))
1408
- }, {
1409
- default: n(() => [
1410
- h(g(e(t)("page.new")), 1)
1411
- ]),
1412
- _: 1
1413
- })) : D("", !0)
1414
- ]),
1415
- f(e(Oe), null, {
1416
- header: n(() => [
1417
- f(e(ut), {
1418
- modelValue: C.value,
1419
- "onUpdate:modelValue": b[1] || (b[1] = (w) => C.value = w),
1420
- options: q.value,
1421
- size: "sm",
1422
- "aria-label": e(t)("page.column-status"),
1423
- onChange: _e
1424
- }, null, 8, ["modelValue", "options", "aria-label"])
1425
- ]),
1314
+ D();
1315
+ }), pe(D), (o, w) => (m(), A("div", Ft, [
1316
+ v(e(et), {
1317
+ view: T.value,
1318
+ "onUpdate:view": w[2] || (w[2] = (g) => T.value = g),
1319
+ title: $.value,
1320
+ views: S.value
1321
+ }, Je({
1426
1322
  default: n(() => [
1427
- f(e(rt), {
1428
- data: ce.value,
1429
- columns: I.value,
1323
+ v(e(dt), {
1324
+ data: le.value,
1325
+ columns: U.value,
1430
1326
  "row-key": "id",
1431
- tree: pe.value,
1327
+ tree: q.value,
1432
1328
  searchable: "",
1433
- hover: "",
1329
+ clickable: !c.value,
1330
+ hover: !c.value,
1434
1331
  flush: "",
1435
1332
  layout: "fixed",
1436
- loading: o.value,
1437
- "cards-below": Ee,
1333
+ loading: f.value,
1334
+ "cards-below": 0,
1438
1335
  "search-placeholder": e(t)("page.search"),
1439
- "empty-text": _.value ? e(t)("page.empty-bin") : s.value ? e(t)("page.empty-search") : e(t)("page.empty"),
1440
- "aria-label": U.value,
1441
- onStateChange: ee,
1442
- onNodeDrop: be,
1443
- onRowClick: B
1336
+ "empty-text": c.value ? e(t)("page.empty-bin") : i.value ? e(t)("page.empty-search") : e(t)("page.empty"),
1337
+ "aria-label": $.value,
1338
+ onRowClick: ee,
1339
+ onStateChange: de,
1340
+ onNodeDrop: ge
1444
1341
  }, {
1445
- "cell-title": n(({ row: w }) => [
1446
- N("span", Ft, g(w.is_home ? e(t)("pages.home") : w.title), 1)
1342
+ "cell-title": n(({ row: g }) => [
1343
+ E("span", Ht, b(g.is_home ? e(t)("pages.home") : g.title), 1)
1447
1344
  ]),
1448
- "cell-path": n(({ row: w }) => [
1449
- _.value ? (d(), x(e(O), {
1345
+ "cell-path": n(({ row: g }) => [
1346
+ c.value ? (m(), V(e(R), {
1450
1347
  key: 0,
1451
1348
  size: "sm",
1452
1349
  tone: "muted"
1453
1350
  }, {
1454
- default: n(() => [...b[3] || (b[3] = [
1455
- h("—", -1)
1351
+ default: n(() => [...w[3] || (w[3] = [
1352
+ y("—", -1)
1456
1353
  ])]),
1457
1354
  _: 1
1458
- })) : w.url && w.status !== "draft" ? (d(), M("a", {
1355
+ })) : g.url && g.status !== "draft" ? (m(), A("a", {
1459
1356
  key: 1,
1460
1357
  class: "wx-pages__address",
1461
- href: w.url,
1358
+ href: g.url,
1462
1359
  target: "_blank",
1463
1360
  rel: "noopener",
1464
- onClick: b[2] || (b[2] = xe(() => {
1361
+ onClick: w[1] || (w[1] = Qe(() => {
1465
1362
  }, ["stop"]))
1466
- }, " /" + g(w.path), 9, Kt)) : w.path !== null ? (d(), x(e(O), {
1363
+ }, " /" + b(g.path), 9, jt)) : g.path !== null ? (m(), V(e(R), {
1467
1364
  key: 2,
1468
1365
  mono: "",
1469
1366
  size: "sm",
1470
1367
  tone: "muted"
1471
1368
  }, {
1472
1369
  default: n(() => [
1473
- h("/" + g(w.path), 1)
1370
+ y("/" + b(g.path), 1)
1474
1371
  ]),
1475
1372
  _: 2
1476
- }, 1024)) : (d(), x(e(O), {
1373
+ }, 1024)) : (m(), V(e(R), {
1477
1374
  key: 3,
1478
1375
  size: "sm",
1479
1376
  tone: "muted"
1480
1377
  }, {
1481
1378
  default: n(() => [
1482
- h(g(e(t)("page.no-address")), 1)
1379
+ y(b(e(t)("page.no-address")), 1)
1483
1380
  ]),
1484
1381
  _: 1
1485
1382
  }))
1486
1383
  ]),
1487
- "cell-status": n(({ row: w }) => [
1488
- _.value ? (d(), x(e(O), {
1384
+ "cell-status": n(({ row: g }) => [
1385
+ c.value ? (m(), V(e(me), {
1489
1386
  key: 0,
1490
- size: "sm",
1491
- tone: "muted"
1492
- }, {
1493
- default: n(() => [
1494
- h(g(me(w)), 1)
1495
- ]),
1496
- _: 2
1497
- }, 1024)) : (d(), x(e(We), {
1387
+ value: g.deleted_at
1388
+ }, null, 8, ["value"])) : (m(), V(e(we), {
1498
1389
  key: 1,
1499
- type: K(w.status),
1390
+ type: Q(g.status),
1500
1391
  dot: ""
1501
1392
  }, {
1502
1393
  default: n(() => [
1503
- h(g(e(t)(`page.status-${w.status}`)), 1)
1394
+ y(b(e(t)(`page.status-${g.status}`)), 1)
1504
1395
  ]),
1505
1396
  _: 2
1506
1397
  }, 1032, ["type"]))
1507
1398
  ]),
1508
- "cell-updated_at": n(({ row: w }) => [
1509
- f(e(O), {
1399
+ "cell-updated_at": n(({ row: g }) => [
1400
+ v(e(R), {
1510
1401
  size: "sm",
1511
1402
  tone: "muted"
1512
1403
  }, {
1513
1404
  default: n(() => [
1514
- h(g(me(w)), 1),
1515
- w.edited_by && !_.value ? (d(), M(F, { key: 0 }, [
1516
- h(", " + g(w.edited_by), 1)
1517
- ], 64)) : D("", !0)
1405
+ v(e(me), {
1406
+ value: g.updated_at
1407
+ }, null, 8, ["value"]),
1408
+ g.edited_by && !c.value ? (m(), A(j, { key: 0 }, [
1409
+ y(", " + b(g.edited_by), 1)
1410
+ ], 64)) : N("", !0)
1518
1411
  ]),
1519
1412
  _: 2
1520
1413
  }, 1024)
1521
1414
  ]),
1522
- "cell-actions": n(({ row: w }) => [
1523
- W.value ? (d(), x(Ne, {
1524
- key: 0,
1525
- page: w,
1526
- "in-bin": _.value,
1527
- onOpen: B,
1528
- onAdd: ne,
1529
- onDuplicate: se,
1530
- onMove: ve,
1531
- onCopy: he,
1532
- onRemove: Q,
1533
- onRestore: fe
1534
- }, null, 8, ["page", "in-bin"])) : D("", !0)
1535
- ]),
1536
- "card-actions": n(({ row: w }) => [
1537
- W.value ? (d(), x(Ne, {
1415
+ "cell-actions": n(({ row: g }) => [
1416
+ _.value ? (m(), V(Ut, {
1538
1417
  key: 0,
1539
- "menu-only": "",
1540
- page: w,
1541
- "in-bin": _.value,
1542
- onOpen: B,
1543
- onAdd: ne,
1544
- onDuplicate: se,
1545
- onMove: ve,
1546
- onCopy: he,
1547
- onRemove: Q,
1548
- onRestore: fe
1549
- }, null, 8, ["page", "in-bin"])) : D("", !0)
1418
+ page: g,
1419
+ "in-bin": c.value,
1420
+ onOpen: ee,
1421
+ onAdd: ce,
1422
+ onDuplicate: te,
1423
+ onMove: L,
1424
+ onCopy: J,
1425
+ onRemove: ve,
1426
+ onRestore: he
1427
+ }, null, 8, ["page", "in-bin"])) : N("", !0)
1550
1428
  ]),
1551
1429
  _: 1
1552
- }, 8, ["data", "columns", "tree", "loading", "search-placeholder", "empty-text", "aria-label"])
1430
+ }, 8, ["data", "columns", "tree", "clickable", "hover", "loading", "search-placeholder", "empty-text", "aria-label"])
1553
1431
  ]),
1554
- _: 1
1555
- })
1556
- ], 512));
1432
+ _: 2
1433
+ }, [
1434
+ _.value ? {
1435
+ name: "actions",
1436
+ fn: n(() => [
1437
+ v(e(I), {
1438
+ type: "primary",
1439
+ icon: "plus",
1440
+ onClick: w[0] || (w[0] = (g) => ce(null))
1441
+ }, {
1442
+ default: n(() => [
1443
+ y(b(e(t)("page.new")), 1)
1444
+ ]),
1445
+ _: 1
1446
+ })
1447
+ ]),
1448
+ key: "0"
1449
+ } : void 0
1450
+ ]), 1032, ["view", "title", "views"])
1451
+ ]));
1557
1452
  }
1558
- }), jt = /* @__PURE__ */ de(Ht, [["__scopeId", "data-v-681ec89c"]]);
1559
- function Zt(v = {}) {
1560
- const u = v.path ?? "/pages";
1453
+ }), Jt = /* @__PURE__ */ re(Gt, [["__scopeId", "data-v-6c1123b3"]]);
1454
+ function ea(p = {}) {
1455
+ const r = p.path ?? "/pages";
1561
1456
  return {
1562
1457
  id: "pages",
1563
- path: u,
1458
+ path: r,
1564
1459
  routes: [
1565
- { path: u, name: "webx.pages", component: jt, props: { base: u } },
1460
+ { path: r, name: "webx.pages", component: Jt, props: { base: r } },
1566
1461
  {
1567
- path: `${u}/:id(\\d+)`,
1462
+ path: `${r}/:id(\\d+)`,
1568
1463
  name: "webx.pages.edit",
1569
- component: Vt,
1570
- props: { base: u }
1464
+ component: Ct,
1465
+ props: { base: r }
1571
1466
  }
1572
1467
  ],
1573
1468
  /*
@@ -1579,25 +1474,25 @@ function Zt(v = {}) {
1579
1474
  * page from the editor above it rather than from the description.
1580
1475
  */
1581
1476
  types: {
1582
- "wx-page-place": { component: Et, kind: "display" },
1583
- "wx-page-danger": { component: bt, kind: "display" },
1584
- "wx-page-history": { component: At, kind: "display" }
1477
+ "wx-page-place": { component: It, kind: "display" },
1478
+ "wx-page-danger": { component: yt, kind: "display" },
1479
+ "wx-page-history": { component: Nt, kind: "display" }
1585
1480
  }
1586
1481
  };
1587
1482
  }
1588
1483
  export {
1589
- bt as WxPageDanger,
1590
- Vt as WxPageEditorPage,
1591
- At as WxPageHistory,
1592
- Se as WxPagePicker,
1593
- Et as WxPagePlace,
1594
- jt as WxPagesPage,
1484
+ yt as WxPageDanger,
1485
+ Ct as WxPageEditorPage,
1486
+ Nt as WxPageHistory,
1487
+ Te as WxPagePicker,
1488
+ It as WxPagePlace,
1489
+ Jt as WxPagesPage,
1595
1490
  Z as createPagesApi,
1596
- He as pageEditorKey,
1597
- Zt as pages,
1598
- pt as pagesMessages,
1599
- ct as providePageEditor,
1600
- Ot as slugify,
1601
- ze as usePageEditor
1491
+ Ee as pageEditorKey,
1492
+ ea as pages,
1493
+ gt as pagesMessages,
1494
+ pt as providePageEditor,
1495
+ Lt as slugify,
1496
+ ke as usePageEditor
1602
1497
  };
1603
1498
  //# sourceMappingURL=index.js.map