@webx-ui/module-inbox 0.10.0 → 0.11.1

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.
@@ -1,856 +0,0 @@
1
- import { defineComponent as D, useModel as H, computed as y, openBlock as x, createBlock as w, unref as e, withCtx as t, createVNode as l, isRef as T, createTextVNode as V, toDisplayString as _, createCommentVNode as F, mergeModels as ae, createElementBlock as N, createElementVNode as A, ref as I, onMounted as ve, Fragment as de, renderList as be, reactive as xe, watch as ye } from "vue";
2
- import { useRouter as re, useRoute as ge } from "vue-router";
3
- import { useTranslate as G, useAdmin as ne, emptyLink as se, WxLinkPicker as _e, WxRelationsField as he, useErrorText as Ve, WxScreenHead as ke } from "@webx-ui/module-admin";
4
- import { WxCard as B, WxFormItem as W, WxSwitch as pe, WxInputNumber as ue, WxSelect as le, WxText as S, WxAlert as oe, WxAction as K, WxTable as we, toast as P, WxInput as q, WxRadioGroup as $e, WxSpace as Ue, WxButton as te, WxIcon as We, WxLink as ze, confirm as Fe, useLocales as Se, localizedValue as Ce, WxSkeleton as Te, WxBadge as Ae, WxTabs as Be, WxTab as R, WxActionBar as Ie } from "@webx-ui/core";
5
- import { o as C, u as me, _ as J, a as Ne, c as ce, F as Ee } from "./index-BJ-mLCee.js";
6
- const Le = /* @__PURE__ */ D({
7
- __name: "FormAntispam",
8
- props: /* @__PURE__ */ ae({
9
- site: {}
10
- }, {
11
- modelValue: { required: !0 },
12
- modelModifiers: {}
13
- }),
14
- emits: ["update:modelValue"],
15
- setup(v) {
16
- const m = H(v, "modelValue"), u = v, o = G("webx-inbox"), k = C(m, "antispam.honeypot", !0), i = C(m, "antispam.min_seconds", 3), $ = C(m, "antispam.throttle", 5), r = C(m, "antispam.captcha", "off"), U = y(() => [
17
- { value: "off", label: o("panel.captcha-off") },
18
- { value: "recaptcha", label: o("panel.captcha-recaptcha") },
19
- { value: "turnstile", label: o("panel.captcha-turnstile") }
20
- ]), c = y(() => {
21
- const p = r.value;
22
- return p !== "recaptcha" && p !== "turnstile" ? null : { provider: p, site: u.site?.[p] ?? null };
23
- }), g = y(() => {
24
- const p = c.value?.site;
25
- return p ? o(`panel.captcha-${c.value.provider}-${p.type}`) : null;
26
- });
27
- return (p, n) => (x(), w(e(B), null, {
28
- default: t(() => [
29
- l(e(W), {
30
- help: e(o)("panel.honeypot-help")
31
- }, {
32
- default: t(() => [
33
- l(e(pe), {
34
- modelValue: e(k),
35
- "onUpdate:modelValue": n[0] || (n[0] = (h) => T(k) ? k.value = h : null),
36
- label: e(o)("panel.honeypot")
37
- }, null, 8, ["modelValue", "label"])
38
- ]),
39
- _: 1
40
- }, 8, ["help"]),
41
- l(e(W), {
42
- label: e(o)("panel.min-seconds"),
43
- help: e(o)("panel.min-seconds-help")
44
- }, {
45
- default: t(() => [
46
- l(e(ue), {
47
- modelValue: e(i),
48
- "onUpdate:modelValue": n[1] || (n[1] = (h) => T(i) ? i.value = h : null),
49
- min: 0,
50
- max: 120
51
- }, null, 8, ["modelValue"])
52
- ]),
53
- _: 1
54
- }, 8, ["label", "help"]),
55
- l(e(W), {
56
- label: e(o)("panel.throttle"),
57
- help: e(o)("panel.throttle-help")
58
- }, {
59
- default: t(() => [
60
- l(e(ue), {
61
- modelValue: e($),
62
- "onUpdate:modelValue": n[2] || (n[2] = (h) => T($) ? $.value = h : null),
63
- min: 0,
64
- max: 120
65
- }, null, 8, ["modelValue"])
66
- ]),
67
- _: 1
68
- }, 8, ["label", "help"]),
69
- l(e(W), {
70
- label: e(o)("panel.captcha"),
71
- help: e(o)("panel.captcha-keys")
72
- }, {
73
- default: t(() => [
74
- l(e(le), {
75
- modelValue: e(r),
76
- "onUpdate:modelValue": n[3] || (n[3] = (h) => T(r) ? r.value = h : null),
77
- options: U.value
78
- }, null, 8, ["modelValue", "options"])
79
- ]),
80
- _: 1
81
- }, 8, ["label", "help"]),
82
- g.value ? (x(), w(e(S), {
83
- key: 0,
84
- size: "sm",
85
- tone: "muted"
86
- }, {
87
- default: t(() => [
88
- V(_(g.value), 1)
89
- ]),
90
- _: 1
91
- })) : F("", !0),
92
- c.value?.site && !c.value.site.configured ? (x(), w(e(oe), {
93
- key: 1,
94
- type: "warning",
95
- variant: "soft",
96
- closable: !1,
97
- description: e(o)("panel.captcha-unconfigured")
98
- }, null, 8, ["description"])) : F("", !0)
99
- ]),
100
- _: 1
101
- }));
102
- }
103
- }), Me = { class: "wx-inbox-embed" }, qe = { class: "wx-inbox-embed__snippet" }, Oe = { class: "wx-inbox-embed__snippet" }, Re = { class: "wx-inbox-embed__snippet" }, Pe = /* @__PURE__ */ D({
104
- __name: "FormEmbed",
105
- props: {
106
- form: {},
107
- slug: {},
108
- fields: {}
109
- },
110
- setup(v) {
111
- const m = v;
112
- me();
113
- const u = G("webx-inbox"), o = ne(), k = y(
114
- () => o.state.manifest?.modules.some((n) => n.id === "blocks") ?? !1
115
- ), i = y(() => `<x-webx-inbox::form slug="${m.slug}" />`), $ = y(
116
- () => k.value ? i.value : `{{-- resources/views/blocks/contact.blade.php --}}
117
- <x-webx-inbox::form slug="${m.slug}" />`
118
- ), r = y(
119
- () => m.fields.find((n) => n.type === "hidden" && n.is_enabled)?.key ?? "page"
120
- ), U = y(
121
- () => `<x-webx-inbox::form slug="${m.slug}" :values="['${r.value}' => url()->current()]" />
122
- <x-webx-inbox::form slug="${m.slug}" placement="footer" />`
123
- ), c = y(() => [
124
- { key: "key", label: u("fields.name") },
125
- { key: "title", label: u("fields.title") },
126
- { key: "type", label: u("fields.type"), hideBelow: 520 }
127
- ]), g = y(() => m.fields.filter((n) => n.is_enabled));
128
- async function p(n) {
129
- try {
130
- await navigator.clipboard.writeText(n), P.success(u("panel.copied"));
131
- } catch {
132
- }
133
- }
134
- return (n, h) => (x(), N("div", Me, [
135
- l(e(B), {
136
- title: e(u)("panel.embed-blade")
137
- }, {
138
- default: t(() => [
139
- l(e(S), {
140
- size: "sm",
141
- tone: "muted"
142
- }, {
143
- default: t(() => [
144
- V(_(e(u)("panel.embed-blade-help")), 1)
145
- ]),
146
- _: 1
147
- }),
148
- A("div", qe, [
149
- A("code", null, _(i.value), 1),
150
- l(e(K), {
151
- icon: "copy",
152
- title: e(u)("panel.copy"),
153
- onClick: h[0] || (h[0] = (f) => p(i.value))
154
- }, null, 8, ["title"])
155
- ])
156
- ]),
157
- _: 1
158
- }, 8, ["title"]),
159
- l(e(B), {
160
- title: e(u)("panel.embed-block")
161
- }, {
162
- default: t(() => [
163
- l(e(S), {
164
- size: "sm",
165
- tone: "muted"
166
- }, {
167
- default: t(() => [
168
- V(_(e(u)(k.value ? "panel.embed-block-panel-help" : "panel.embed-block-help")), 1)
169
- ]),
170
- _: 1
171
- }),
172
- A("div", Oe, [
173
- A("code", null, _($.value), 1),
174
- l(e(K), {
175
- icon: "copy",
176
- title: e(u)("panel.copy"),
177
- onClick: h[1] || (h[1] = (f) => p($.value))
178
- }, null, 8, ["title"])
179
- ])
180
- ]),
181
- _: 1
182
- }, 8, ["title"]),
183
- l(e(B), {
184
- title: e(u)("panel.embed-extras")
185
- }, {
186
- default: t(() => [
187
- l(e(S), {
188
- size: "sm",
189
- tone: "muted"
190
- }, {
191
- default: t(() => [
192
- V(_(e(u)("panel.embed-extras-help")), 1)
193
- ]),
194
- _: 1
195
- }),
196
- A("div", Re, [
197
- A("code", null, _(U.value), 1),
198
- l(e(K), {
199
- icon: "copy",
200
- title: e(u)("panel.copy"),
201
- onClick: h[2] || (h[2] = (f) => p(U.value))
202
- }, null, 8, ["title"])
203
- ])
204
- ]),
205
- _: 1
206
- }, 8, ["title"]),
207
- l(e(B), {
208
- title: e(u)("panel.embed-names")
209
- }, {
210
- default: t(() => [
211
- l(e(S), {
212
- size: "sm",
213
- tone: "muted"
214
- }, {
215
- default: t(() => [
216
- V(_(e(u)("panel.embed-names-help")), 1)
217
- ]),
218
- _: 1
219
- }),
220
- l(e(we), {
221
- data: g.value,
222
- columns: c.value,
223
- "row-key": "id",
224
- flush: "",
225
- "empty-text": e(u)("fields.no-fields")
226
- }, {
227
- "cell-key": t(({ row: f }) => [
228
- l(e(S), {
229
- mono: "",
230
- size: "sm"
231
- }, {
232
- default: t(() => [
233
- V("fields[" + _(f.key) + "]", 1)
234
- ]),
235
- _: 2
236
- }, 1024)
237
- ]),
238
- "cell-title": t(({ row: f }) => [
239
- V(_(Object.values(f.title)[0] ?? f.key), 1)
240
- ]),
241
- "cell-type": t(({ row: f }) => [
242
- V(_(e(u)(`fields.type-${f.type}`)), 1)
243
- ]),
244
- _: 1
245
- }, 8, ["data", "columns", "empty-text"])
246
- ]),
247
- _: 1
248
- }, 8, ["title"])
249
- ]));
250
- }
251
- }), De = /* @__PURE__ */ J(Pe, [["__scopeId", "data-v-7f9788ed"]]), Ge = { class: "wx-inbox-general" }, Ke = /* @__PURE__ */ D({
252
- __name: "FormGeneral",
253
- props: /* @__PURE__ */ ae({
254
- errors: {}
255
- }, {
256
- settings: { required: !0 },
257
- settingsModifiers: {},
258
- options: { required: !0 },
259
- optionsModifiers: {}
260
- }),
261
- emits: ["update:settings", "update:options"],
262
- setup(v) {
263
- const m = H(
264
- v,
265
- "settings"
266
- ), u = H(v, "options"), o = G("webx-inbox"), k = C(u, "description", {}), i = C(u, "thank-you.heading", {}), $ = C(u, "thank-you.text", {}), r = C(u, "design.submit-text", {}), U = C(u, "redirect", null), c = y({
267
- get: () => {
268
- const g = U.value;
269
- return typeof g == "string" ? { ...se(), target: "url", url: g } : g ?? { ...se(), target: "none" };
270
- },
271
- set: (g) => {
272
- U.value = g === null || g.target === "none" ? null : g;
273
- }
274
- });
275
- return (g, p) => (x(), N("div", Ge, [
276
- l(e(B), null, {
277
- default: t(() => [
278
- l(e(W), {
279
- label: e(o)("panel.title"),
280
- error: v.errors.title?.[0],
281
- required: ""
282
- }, {
283
- default: t(() => [
284
- l(e(q), {
285
- modelValue: m.value.title,
286
- "onUpdate:modelValue": p[0] || (p[0] = (n) => m.value.title = n),
287
- localized: ""
288
- }, null, 8, ["modelValue"])
289
- ]),
290
- _: 1
291
- }, 8, ["label", "error"]),
292
- l(e(W), {
293
- label: e(o)("panel.description"),
294
- help: e(o)("panel.description-help")
295
- }, {
296
- default: t(() => [
297
- l(e(q), {
298
- modelValue: e(k),
299
- "onUpdate:modelValue": p[1] || (p[1] = (n) => T(k) ? k.value = n : null),
300
- localized: ""
301
- }, null, 8, ["modelValue"])
302
- ]),
303
- _: 1
304
- }, 8, ["label", "help"]),
305
- l(e(W), {
306
- label: e(o)("panel.slug"),
307
- help: e(o)("panel.slug-help"),
308
- error: v.errors.slug?.[0],
309
- required: ""
310
- }, {
311
- default: t(() => [
312
- l(e(q), {
313
- modelValue: m.value.slug,
314
- "onUpdate:modelValue": p[2] || (p[2] = (n) => m.value.slug = n),
315
- placeholder: "contact"
316
- }, null, 8, ["modelValue"])
317
- ]),
318
- _: 1
319
- }, 8, ["label", "help", "error"]),
320
- l(e(W), {
321
- help: e(o)("panel.is-enabled-help")
322
- }, {
323
- default: t(() => [
324
- l(e(pe), {
325
- modelValue: m.value.is_enabled,
326
- "onUpdate:modelValue": p[3] || (p[3] = (n) => m.value.is_enabled = n),
327
- label: e(o)("panel.is-enabled")
328
- }, null, 8, ["modelValue", "label"])
329
- ]),
330
- _: 1
331
- }, 8, ["help"])
332
- ]),
333
- _: 1
334
- }),
335
- l(e(B), {
336
- title: e(o)("panel.after-sending")
337
- }, {
338
- default: t(() => [
339
- l(e(W), {
340
- label: e(o)("panel.submit-text")
341
- }, {
342
- default: t(() => [
343
- l(e(q), {
344
- modelValue: e(r),
345
- "onUpdate:modelValue": p[4] || (p[4] = (n) => T(r) ? r.value = n : null),
346
- localized: ""
347
- }, null, 8, ["modelValue"])
348
- ]),
349
- _: 1
350
- }, 8, ["label"]),
351
- l(e(W), {
352
- label: e(o)("panel.thank-you-heading")
353
- }, {
354
- default: t(() => [
355
- l(e(q), {
356
- modelValue: e(i),
357
- "onUpdate:modelValue": p[5] || (p[5] = (n) => T(i) ? i.value = n : null),
358
- localized: ""
359
- }, null, 8, ["modelValue"])
360
- ]),
361
- _: 1
362
- }, 8, ["label"]),
363
- l(e(W), {
364
- label: e(o)("panel.thank-you-text")
365
- }, {
366
- default: t(() => [
367
- l(Ne, {
368
- modelValue: e($),
369
- "onUpdate:modelValue": p[6] || (p[6] = (n) => T($) ? $.value = n : null)
370
- }, null, 8, ["modelValue"])
371
- ]),
372
- _: 1
373
- }, 8, ["label"]),
374
- l(e(W), {
375
- label: e(o)("panel.redirect"),
376
- help: e(o)("panel.redirect-help"),
377
- error: v.errors["options.redirect"]?.[0]
378
- }, {
379
- default: t(() => [
380
- l(e(_e), {
381
- modelValue: c.value,
382
- "onUpdate:modelValue": p[7] || (p[7] = (n) => c.value = n),
383
- attributes: !1
384
- }, null, 8, ["modelValue"])
385
- ]),
386
- _: 1
387
- }, 8, ["label", "help", "error"])
388
- ]),
389
- _: 1
390
- }, 8, ["title"])
391
- ]));
392
- }
393
- }), je = /* @__PURE__ */ J(Ke, [["__scopeId", "data-v-1065e341"]]), He = /^[^\s@]+@[^\s@]+$/;
394
- function j(v) {
395
- return "admin_id" in v;
396
- }
397
- function fe(v, m = []) {
398
- return j(v) ? m.find(
399
- (o) => o.type === "admin" && o.admin_id === v.admin_id
400
- )?.problem ?? null : He.test((v.email ?? "").trim()) ? null : "invalid_email";
401
- }
402
- function Je(v, m = []) {
403
- return (v ?? []).some((u) => fe(u, m) === null);
404
- }
405
- const Qe = {
406
- key: 1,
407
- class: "wx-inbox-notifications__way",
408
- "data-way": "email"
409
- }, Xe = { class: "wx-inbox-recipients" }, Ye = { class: "wx-inbox-recipients__row" }, Ze = {
410
- key: 2,
411
- class: "wx-inbox-notifications__way",
412
- "data-way": "channels"
413
- }, el = { class: "wx-inbox-channels" }, ll = /* @__PURE__ */ D({
414
- __name: "FormNotifications",
415
- props: /* @__PURE__ */ ae({
416
- fields: {},
417
- errors: {},
418
- reported: {},
419
- notifications: { type: Boolean },
420
- via: {}
421
- }, {
422
- modelValue: { required: !0 },
423
- modelModifiers: {}
424
- }),
425
- emits: ["update:modelValue"],
426
- setup(v) {
427
- const m = v, u = H(v, "modelValue"), o = ne(), k = ce(o), i = G("webx-inbox"), $ = I([]), r = C(u, "recipients", []), U = C(u, "email_field", ""), c = C(u, "notify_channels", []), g = y({
428
- get: () => u.value.notify_via ?? m.via ?? "email",
429
- set: (d) => {
430
- u.value = { ...u.value, notify_via: d };
431
- }
432
- }), p = y(() => [
433
- { value: "email", label: i("panel.via-email") },
434
- { value: "channels", label: i("panel.via-channels") }
435
- ]), n = y(() => !m.notifications || g.value === "email"), h = re(), f = y(() => o.can("notifications.manage")), z = y(() => `${o.basePath}/notifications`.replace(/\/{2,}/g, "/"));
436
- function ie(d) {
437
- d.metaKey || d.ctrlKey || d.shiftKey || d.button !== 0 || (d.preventDefault(), h.push("/notifications"));
438
- }
439
- ve(async () => {
440
- try {
441
- $.value = await k.recipients();
442
- } catch {
443
- }
444
- });
445
- const L = y(
446
- () => $.value.map((d) => ({ value: d.id, label: `${d.name} · ${d.email}` }))
447
- ), Q = y(() => [
448
- { value: "", label: i("panel.no-email-field") },
449
- ...m.fields.filter((d) => d.type === "email").map((d) => ({ value: d.key, label: X(d) }))
450
- ]);
451
- function X(d) {
452
- const a = Object.values(d.title ?? {}).find(
453
- (s) => typeof s == "string" && s.trim() !== ""
454
- );
455
- return a === void 0 ? d.name ?? d.key : d.name ? `${a} · ${d.name}` : a;
456
- }
457
- function O(d) {
458
- if (!j(d)) return null;
459
- const a = fe(d, m.reported);
460
- return a === null ? null : i(`panel.recipient-${a}`);
461
- }
462
- function E(d) {
463
- r.value = [...r.value, d];
464
- }
465
- async function Y(d) {
466
- const a = r.value[d];
467
- a !== void 0 && (j(a) || (a.email ?? "").trim() !== "") && !await Fe({
468
- title: i("panel.remove-recipient-title"),
469
- message: i("panel.remove-recipient-text"),
470
- confirmText: i("panel.remove"),
471
- cancelText: i("panel.cancel"),
472
- tone: "danger"
473
- }) || (r.value = r.value.filter((b, M) => M !== d));
474
- }
475
- function Z(d, a) {
476
- r.value = r.value.map((s, b) => b === d ? { admin_id: a } : s);
477
- }
478
- function ee(d, a) {
479
- r.value = r.value.map((s, b) => b === d ? { email: a } : s);
480
- }
481
- return (d, a) => (x(), w(e(B), {
482
- class: "wx-inbox-notifications",
483
- title: m.notifications ? void 0 : e(i)("panel.recipients")
484
- }, {
485
- default: t(() => [
486
- l(e(W), {
487
- label: e(i)("panel.email-field"),
488
- help: m.notifications ? e(i)("panel.email-field-help-channels") : e(i)("panel.email-field-help"),
489
- error: v.errors["options.email_field"]?.[0]
490
- }, {
491
- default: t(() => [
492
- l(e(le), {
493
- modelValue: e(U),
494
- "onUpdate:modelValue": a[0] || (a[0] = (s) => T(U) ? U.value = s : null),
495
- options: Q.value
496
- }, null, 8, ["modelValue", "options"])
497
- ]),
498
- _: 1
499
- }, 8, ["label", "help", "error"]),
500
- m.notifications ? (x(), w(e(W), {
501
- key: 0,
502
- label: e(i)("panel.notify-via")
503
- }, {
504
- default: t(() => [
505
- l(e($e), {
506
- modelValue: g.value,
507
- "onUpdate:modelValue": a[1] || (a[1] = (s) => g.value = s),
508
- options: p.value,
509
- inline: ""
510
- }, null, 8, ["modelValue", "options"])
511
- ]),
512
- _: 1
513
- }, 8, ["label"])) : F("", !0),
514
- n.value ? (x(), N("section", Qe, [
515
- m.notifications ? (x(), w(e(S), {
516
- key: 0,
517
- weight: "medium"
518
- }, {
519
- default: t(() => [
520
- V(_(e(i)("panel.recipients")), 1)
521
- ]),
522
- _: 1
523
- })) : F("", !0),
524
- l(e(S), {
525
- size: "sm",
526
- tone: "muted"
527
- }, {
528
- default: t(() => [
529
- V(_(e(i)("panel.recipients-help")), 1)
530
- ]),
531
- _: 1
532
- }),
533
- v.errors["options.recipients"] ? (x(), w(e(oe), {
534
- key: 1,
535
- type: "danger",
536
- variant: "soft",
537
- description: v.errors["options.recipients"]?.[0]
538
- }, null, 8, ["description"])) : F("", !0),
539
- A("div", Xe, [
540
- e(r).length === 0 ? (x(), w(e(S), {
541
- key: 0,
542
- size: "sm",
543
- tone: "placeholder"
544
- }, {
545
- default: t(() => [
546
- V(_(e(i)("panel.no-recipients")), 1)
547
- ]),
548
- _: 1
549
- })) : F("", !0),
550
- (x(!0), N(de, null, be(e(r), (s, b) => (x(), N("div", {
551
- key: b,
552
- class: "wx-inbox-recipients__item"
553
- }, [
554
- A("div", Ye, [
555
- e(j)(s) ? (x(), w(e(le), {
556
- key: 0,
557
- "model-value": s.admin_id,
558
- options: L.value,
559
- "onUpdate:modelValue": (M) => Z(b, Number(M))
560
- }, null, 8, ["model-value", "options", "onUpdate:modelValue"])) : (x(), w(e(q), {
561
- key: 1,
562
- "model-value": s.email,
563
- type: "email",
564
- placeholder: "sales@example.com",
565
- "onUpdate:modelValue": (M) => ee(b, String(M))
566
- }, null, 8, ["model-value", "onUpdate:modelValue"])),
567
- l(e(K), {
568
- icon: "trash",
569
- tone: "danger",
570
- title: e(i)("panel.remove"),
571
- onClick: (M) => Y(b)
572
- }, null, 8, ["title", "onClick"])
573
- ]),
574
- O(s) ? (x(), w(e(S), {
575
- key: 0,
576
- size: "sm",
577
- tone: "danger"
578
- }, {
579
- default: t(() => [
580
- V(_(O(s)), 1)
581
- ]),
582
- _: 2
583
- }, 1024)) : F("", !0)
584
- ]))), 128))
585
- ]),
586
- l(e(Ue), { size: "sm" }, {
587
- default: t(() => [
588
- l(e(te), {
589
- variant: "outline",
590
- icon: "user",
591
- disabled: L.value.length === 0,
592
- onClick: a[2] || (a[2] = (s) => E({ admin_id: Number(L.value[0]?.value) }))
593
- }, {
594
- default: t(() => [
595
- V(_(e(i)("panel.add-admin")), 1)
596
- ]),
597
- _: 1
598
- }, 8, ["disabled"]),
599
- l(e(te), {
600
- variant: "outline",
601
- onClick: a[3] || (a[3] = (s) => E({ email: "" }))
602
- }, {
603
- icon: t(() => [
604
- l(e(We), { name: "mail" })
605
- ]),
606
- default: t(() => [
607
- V(" " + _(e(i)("panel.add-email")), 1)
608
- ]),
609
- _: 1
610
- })
611
- ]),
612
- _: 1
613
- })
614
- ])) : (x(), N("section", Ze, [
615
- l(e(S), { weight: "medium" }, {
616
- default: t(() => [
617
- V(_(e(i)("panel.notify-through")), 1)
618
- ]),
619
- _: 1
620
- }),
621
- l(e(S), {
622
- size: "sm",
623
- tone: "muted"
624
- }, {
625
- default: t(() => [
626
- V(_(e(i)("panel.notify-through-help")), 1)
627
- ]),
628
- _: 1
629
- }),
630
- A("div", el, [
631
- l(e(he), {
632
- modelValue: e(c),
633
- "onUpdate:modelValue": a[4] || (a[4] = (s) => T(c) ? c.value = s : null),
634
- target: "notify-inbox-submission",
635
- sortable: !1,
636
- "add-text": e(i)("panel.pick-channels"),
637
- "empty-text": e(i)("panel.no-channels"),
638
- "none-text": e(i)("panel.no-channels-yet")
639
- }, null, 8, ["modelValue", "add-text", "empty-text", "none-text"]),
640
- f.value ? (x(), w(e(ze), {
641
- key: 0,
642
- href: z.value,
643
- size: "sm",
644
- onClick: ie
645
- }, {
646
- default: t(() => [
647
- V(_(e(i)("panel.set-up-channels")), 1)
648
- ]),
649
- _: 1
650
- }, 8, ["href"])) : F("", !0)
651
- ])
652
- ]))
653
- ]),
654
- _: 1
655
- }, 8, ["title"]));
656
- }
657
- }), tl = /* @__PURE__ */ J(ll, [["__scopeId", "data-v-bbb57f10"]]), al = { class: "wx-inbox-editor" }, nl = /* @__PURE__ */ D({
658
- __name: "FormEditorPage",
659
- props: {
660
- base: { default: "/inbox" }
661
- },
662
- setup(v) {
663
- const m = v, u = ne(), o = ce(u), k = ge(), i = re(), $ = Se();
664
- me();
665
- const r = G("webx-inbox"), U = Ve(), c = I(null), g = I([]), p = I(!0), n = I(!1), h = I({});
666
- let f = xe({
667
- slug: "",
668
- title: {},
669
- is_enabled: !0
670
- });
671
- const z = I({}), L = I(["general", "fields", "notifications", "antispam", "embed"].includes(String(k.query.tab)) ? String(k.query.tab) : "general"), Q = y(
672
- () => f.is_enabled && !Je(z.value.recipients, c.value?.recipients) && !X.value
673
- ), X = y(() => {
674
- if (c.value?.notifications !== !0) return !1;
675
- const a = c.value.channels ?? [];
676
- return (z.value.notify_channels ?? []).some(
677
- (s) => a.find((b) => b.id === s)?.sends ?? !0
678
- );
679
- }), O = y(() => u.can("inbox.manage")), E = y(() => Number(k.params.id)), Y = y(
680
- () => c.value === null ? "" : Ce(f.title, $.active.value, f.slug)
681
- ), Z = y(() => `${m.base}?form=${E.value}`);
682
- async function ee() {
683
- p.value = !0;
684
- try {
685
- const a = await o.form(E.value);
686
- c.value = a, g.value = a.fields ?? [], f.slug = a.slug, f.title = { ...a.title }, f.is_enabled = a.is_enabled, z.value = { ...a.options };
687
- } catch (a) {
688
- P.danger(U(a)), i.replace(m.base);
689
- } finally {
690
- p.value = !1;
691
- }
692
- }
693
- ye(E, () => {
694
- ee();
695
- }, { immediate: !0 });
696
- async function d() {
697
- n.value = !0, h.value = {};
698
- try {
699
- const a = await o.saveForm(E.value, {
700
- slug: f.slug.trim(),
701
- title: f.title,
702
- is_enabled: f.is_enabled,
703
- options: z.value
704
- });
705
- c.value = a, P.success(r("panel.saved"));
706
- } catch (a) {
707
- const s = a.body;
708
- s?.errors ? (h.value = s.errors, P.danger(r("panel.failed"))) : P.danger(U(a));
709
- } finally {
710
- n.value = !1;
711
- }
712
- }
713
- return (a, s) => (x(), N("div", al, [
714
- p.value ? (x(), w(e(B), { key: 0 }, {
715
- default: t(() => [
716
- l(e(Te), {
717
- title: "",
718
- rows: 8
719
- })
720
- ]),
721
- _: 1
722
- })) : c.value ? (x(), N(de, { key: 1 }, [
723
- l(e(ke), {
724
- class: "wx-inbox-editor__head",
725
- title: Y.value,
726
- subtitle: c.value.slug,
727
- back: Z.value,
728
- "back-label": e(r)("panel.forms")
729
- }, {
730
- "title-after": t(() => [
731
- e(f).is_enabled ? F("", !0) : (x(), w(e(Ae), {
732
- key: 0,
733
- type: "default"
734
- }, {
735
- default: t(() => [
736
- V(_(e(r)("panel.off")), 1)
737
- ]),
738
- _: 1
739
- }))
740
- ]),
741
- _: 1
742
- }, 8, ["title", "subtitle", "back", "back-label"]),
743
- Q.value ? (x(), w(e(oe), {
744
- key: 0,
745
- class: "wx-inbox-editor__silent",
746
- type: "warning",
747
- variant: "soft",
748
- closable: !1,
749
- title: e(r)("panel.notifies-nobody"),
750
- description: e(r)("panel.notifies-nobody-text")
751
- }, null, 8, ["title", "description"])) : F("", !0),
752
- l(e(Be), {
753
- modelValue: L.value,
754
- "onUpdate:modelValue": s[5] || (s[5] = (b) => L.value = b),
755
- class: "wx-inbox-editor__tabs",
756
- "keep-alive": ""
757
- }, {
758
- default: t(() => [
759
- l(e(R), {
760
- value: "general",
761
- label: e(r)("panel.tab-general")
762
- }, {
763
- default: t(() => [
764
- l(je, {
765
- settings: e(f),
766
- "onUpdate:settings": s[0] || (s[0] = (b) => T(f) ? f.value = b : f = b),
767
- options: z.value,
768
- "onUpdate:options": s[1] || (s[1] = (b) => z.value = b),
769
- errors: h.value
770
- }, null, 8, ["settings", "options", "errors"])
771
- ]),
772
- _: 1
773
- }, 8, ["label"]),
774
- l(e(R), {
775
- value: "fields",
776
- label: e(r)("panel.tab-fields")
777
- }, {
778
- default: t(() => [
779
- l(Ee, {
780
- modelValue: g.value,
781
- "onUpdate:modelValue": s[2] || (s[2] = (b) => g.value = b),
782
- form: c.value,
783
- "can-manage": O.value
784
- }, null, 8, ["modelValue", "form", "can-manage"])
785
- ]),
786
- _: 1
787
- }, 8, ["label"]),
788
- l(e(R), {
789
- value: "notifications",
790
- label: e(r)("panel.tab-notifications")
791
- }, {
792
- default: t(() => [
793
- l(tl, {
794
- modelValue: z.value,
795
- "onUpdate:modelValue": s[3] || (s[3] = (b) => z.value = b),
796
- fields: g.value,
797
- errors: h.value,
798
- reported: c.value.recipients,
799
- notifications: c.value.notifications,
800
- via: c.value.notify_via
801
- }, null, 8, ["modelValue", "fields", "errors", "reported", "notifications", "via"])
802
- ]),
803
- _: 1
804
- }, 8, ["label"]),
805
- l(e(R), {
806
- value: "antispam",
807
- label: e(r)("panel.tab-antispam")
808
- }, {
809
- default: t(() => [
810
- l(Le, {
811
- modelValue: z.value,
812
- "onUpdate:modelValue": s[4] || (s[4] = (b) => z.value = b),
813
- site: c.value.captcha
814
- }, null, 8, ["modelValue", "site"])
815
- ]),
816
- _: 1
817
- }, 8, ["label"]),
818
- l(e(R), {
819
- value: "embed",
820
- label: e(r)("panel.tab-embed")
821
- }, {
822
- default: t(() => [
823
- l(De, {
824
- form: c.value,
825
- slug: e(f).slug,
826
- fields: g.value
827
- }, null, 8, ["form", "slug", "fields"])
828
- ]),
829
- _: 1
830
- }, 8, ["label"])
831
- ]),
832
- _: 1
833
- }, 8, ["modelValue"]),
834
- O.value ? (x(), w(e(Ie), { key: 1 }, {
835
- default: t(() => [
836
- l(e(te), {
837
- type: "primary",
838
- loading: n.value,
839
- onClick: d
840
- }, {
841
- default: t(() => [
842
- V(_(e(r)("panel.save")), 1)
843
- ]),
844
- _: 1
845
- }, 8, ["loading"])
846
- ]),
847
- _: 1
848
- })) : F("", !0)
849
- ], 64)) : F("", !0)
850
- ]));
851
- }
852
- }), rl = /* @__PURE__ */ J(nl, [["__scopeId", "data-v-e9102f38"]]);
853
- export {
854
- rl as default
855
- };
856
- //# sourceMappingURL=FormEditorPage-CXYnpKAh.js.map