@webx-ui/module-inbox 0.6.8 → 0.8.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,3517 +1,18 @@
1
- import { defineComponent as se, useModel as Se, computed as C, unref as e, openBlock as i, createBlock as g, withCtx as a, createVNode as t, mergeModels as Fe, inject as gl, ref as W, watch as Ue, isRef as oe, createElementVNode as H, createElementBlock as G, Fragment as ee, createCommentVNode as M, createTextVNode as A, toDisplayString as x, renderList as ye, createSlots as De, onMounted as xl, reactive as _l, useTemplateRef as ml, normalizeClass as il } from "vue";
2
- import { useRoute as Re, useRouter as He } from "vue-router";
3
- import { useAdmin as ie, i18nKey as wl, useTranslate as ae, useErrorText as be, WxRowMenu as We, WxScreenHead as al, rowMenuWidth as kl, WxDate as Le, WxFilterChips as Vl, WxListScreen as vl, WxNotes as $l } from "@webx-ui/module-admin";
4
- import { useLocales as ke, WxLocales as Tl, WxRichText as ul, localizedValue as we, useModal as Xe, WxDialog as Ge, WxFormItem as X, WxSelect as fe, WxInput as le, WxText as Y, WxAction as xe, WxButton as te, WxIcon as _e, WxInputNumber as Ve, WxDatePicker as tl, WxTagsInput as Sl, WxCheckbox as he, WxSpace as Ie, toast as O, createModal as je, WxCard as ne, WxEmpty as Ye, WxSortableList as nl, WxBadge as $e, confirm as Ae, WxSwitch as fl, WxAlert as Ce, WxTable as bl, WxSkeleton as Ne, WxTabs as sl, WxTab as ge, WxActionBar as Cl, WxTextarea as Ul, WxRadioGroup as Al, WxCheckboxGroup as zl, useElementWidth as ql, WxEntityCard as Wl, WxAvatar as rl, WxTooltip as Nl, WxListDetail as Fl, WxIndicator as dl, WxDescriptions as cl, WxDescriptionsItem as Me, WxFileCard as Il, WxTimeline as El, WxTimelineItem as Pl } from "@webx-ui/core";
5
- const hl = /* @__PURE__ */ se({
6
- __name: "LocalizedRichText",
7
- props: /* @__PURE__ */ Fe({
8
- placeholder: { default: void 0 },
9
- minHeight: { default: "160px" }
10
- }, {
11
- modelValue: { default: "" },
12
- modelModifiers: {}
13
- }),
14
- emits: ["update:modelValue"],
15
- setup(s) {
16
- const o = Se(s, "modelValue"), d = s, u = ke(), m = C(() => {
17
- const n = u.active.value;
18
- return u.list.value.some((V) => V.code === n) ? n : u.list.value[0]?.code ?? "";
19
- }), T = C({
20
- get: () => {
21
- const n = o.value;
22
- return typeof n == "string" ? m.value === "" || m.value === u.list.value[0]?.code ? n : "" : n[m.value] ?? "";
23
- },
24
- set: (n) => {
25
- if (m.value === "") {
26
- o.value = n;
27
- return;
28
- }
29
- const l = typeof o.value == "string" ? { [m.value]: o.value } : o.value;
30
- o.value = { ...l, [m.value]: n };
31
- }
32
- });
33
- return (n, l) => e(u).list.value.length > 0 ? (i(), g(e(Tl), { key: 0 }, {
34
- default: a(() => [
35
- t(e(ul), {
36
- modelValue: T.value,
37
- "onUpdate:modelValue": l[0] || (l[0] = (V) => T.value = V),
38
- placeholder: d.placeholder,
39
- "min-height": d.minHeight
40
- }, null, 8, ["modelValue", "placeholder", "min-height"])
41
- ]),
42
- _: 1
43
- })) : (i(), g(e(ul), {
44
- key: 1,
45
- modelValue: T.value,
46
- "onUpdate:modelValue": l[1] || (l[1] = (V) => T.value = V),
47
- placeholder: d.placeholder,
48
- "min-height": d.minHeight
49
- }, null, 8, ["modelValue", "placeholder", "min-height"]));
50
- }
51
- }), Oe = /* @__PURE__ */ new WeakMap();
52
- function ce(s) {
53
- const o = `${s.apiPath}/inbox`, d = (n) => n.data, u = () => {
54
- }, m = (n) => (Oe.delete(s.http), n);
55
- function T() {
56
- const n = Oe.get(s.http);
57
- if (n !== void 0)
58
- return n.then((V) => [...V]);
59
- const l = s.http.get(`${o}/statuses`).then(d);
60
- return Oe.set(s.http, l), l.catch(() => Oe.delete(s.http)), l.then((V) => [...V]);
61
- }
62
- return {
63
- forms: () => s.http.get(`${o}/forms`).then(d),
64
- form: (n) => s.http.get(`${o}/forms/${n}`).then(d),
65
- createForm: (n) => s.http.post(`${o}/forms`, n).then(d),
66
- saveForm: (n, l) => s.http.put(`${o}/forms/${n}`, l).then(d),
67
- removeForm: (n) => s.http.delete(`${o}/forms/${n}`).then(u),
68
- duplicateForm: (n) => s.http.post(`${o}/forms/${n}/duplicate`, {}).then(d),
69
- sortForms: (n) => s.http.post(`${o}/forms/sorting`, { ids: n }).then(u),
70
- fields: (n) => s.http.get(`${o}/forms/${n}/fields`).then(d),
71
- createField: (n, l) => s.http.post(`${o}/forms/${n}/fields`, l).then(d),
72
- saveField: (n, l) => s.http.put(`${o}/fields/${n}`, l).then(d),
73
- removeField: (n) => s.http.delete(`${o}/fields/${n}`).then(u),
74
- sortFields: (n, l) => s.http.post(`${o}/forms/${n}/fields/sorting`, { ids: l }).then(u),
75
- statuses: T,
76
- createStatus: (n) => s.http.post(`${o}/statuses`, n).then(d).then(m),
77
- saveStatus: (n, l) => s.http.put(`${o}/statuses/${n}`, l).then(d).then(m),
78
- removeStatus: (n) => s.http.delete(`${o}/statuses/${n}`).then(u).then(m),
79
- sortStatuses: (n) => s.http.post(`${o}/statuses/sorting`, { ids: n }).then(u).then(m),
80
- recipients: () => s.http.get(`${o}/recipients`).then(d),
81
- submissions: (n, l = {}) => s.http.get(`${o}/forms/${n}/submissions`, { query: ll(l) }).then((V) => ({
82
- ...V.meta,
83
- data: V.data,
84
- columns: V.columns,
85
- counts: V.counts,
86
- // Optional on the wire: a server from before placements answers without them.
87
- placements: V.placements ?? []
88
- })),
89
- submission: (n, l = {}) => s.http.get(`${o}/submissions/${n}`, { query: ll(l) }).then(d),
90
- createSubmission: (n, l) => s.http.post(`${o}/forms/${n}/submissions`, { fields: l }).then(d),
91
- saveSubmission: (n, l) => s.http.put(`${o}/submissions/${n}`, l).then(d),
92
- removeSubmission: (n) => s.http.delete(`${o}/submissions/${n}`).then(u),
93
- notifySubmission: (n) => s.http.post(`${o}/submissions/${n}/notify`).then(d),
94
- massSubmissions: (n) => s.http.post(`${o}/submissions/mass`, n).then(d),
95
- exportUrl: (n, l = {}) => {
96
- const V = new URLSearchParams();
97
- for (const [p, U] of Object.entries(ll(l)))
98
- U != null && U !== "" && V.set(p, String(U));
99
- const b = V.toString();
100
- return `${o}/forms/${n}/submissions/export${b === "" ? "" : `?${b}`}`;
101
- }
102
- };
103
- }
104
- function ll(s) {
105
- return {
106
- view: s.view === void 0 || s.view === "" ? void 0 : s.view,
107
- search: s.search === void 0 || s.search === "" ? void 0 : s.search,
108
- assignee: s.assignee ?? void 0,
109
- placement: s.placement ?? void 0,
110
- sort: s.sort ?? void 0,
111
- page: s.page,
112
- per_page: s.per_page
113
- };
114
- }
115
- const Ml = {
116
- module: {
117
- title: "Inbox"
118
- },
119
- panel: {
120
- forms: "Forms",
121
- "new-form": "New form",
122
- "no-forms": "No forms yet.",
123
- "no-forms-help": "A form is a few questions and a list of who hears the answers.",
124
- unread: "Unread",
125
- submissions: "Submissions in all",
126
- off: "Off",
127
- settings: "Settings",
128
- duplicate: "Duplicate",
129
- delete: "Delete",
130
- "delete-form-title": "Delete “:form”?",
131
- "delete-form-text": "The form and its questions go. This cannot be undone.",
132
- cancel: "Cancel",
133
- save: "Save",
134
- saved: "Saved.",
135
- deleted: "Deleted.",
136
- duplicated: "A copy was made.",
137
- failed: "Some values were not accepted. Check the highlighted fields.",
138
- "reorder-failed": "The new order could not be saved.",
139
- reorder: "Reorder",
140
- "new-form-title": "New form",
141
- title: "Title",
142
- slug: "Address",
143
- "slug-help": "What the form is called on the site and where it posts.",
144
- "is-enabled": "Active",
145
- "is-enabled-help": "A form that is off is neither drawn nor accepted.",
146
- "tab-general": "General",
147
- "tab-fields": "Fields",
148
- "tab-notifications": "Notifications",
149
- "tab-antispam": "Antispam",
150
- "tab-embed": "Embedding",
151
- "after-sending": "After sending",
152
- "thank-you-heading": "Heading",
153
- "thank-you-text": "Text",
154
- "submit-text": "Text on the button",
155
- redirect: "Go to this address instead",
156
- "redirect-help": "Left empty, the thank-you takes the form’s place on the page.",
157
- recipients: "Who is written to",
158
- "recipients-help": "Nobody here means nobody is told. The submission is kept either way.",
159
- "no-recipients": "Nobody yet.",
160
- "add-admin": "Add an administrator",
161
- "add-email": "Add an address",
162
- remove: "Remove",
163
- "remove-recipient-title": "Remove this recipient?",
164
- "remove-recipient-text": "They stop being told when something arrives.",
165
- "email-field": "The field holding the sender’s address",
166
- "email-field-help": "A reply to the notification then goes to whoever wrote in.",
167
- "no-email-field": "None",
168
- honeypot: "Hidden field",
169
- "honeypot-help": "A field nobody sees and a robot fills in.",
170
- "min-seconds": "Fastest a person could send it, in seconds",
171
- "min-seconds-help": "Zero switches the check off.",
172
- throttle: "Sends a minute from one address",
173
- "throttle-help": "Zero switches the limit off.",
174
- captcha: "Captcha",
175
- "captcha-keys": "The keys are not set in the panel but in the site’s .env: WEBX_INBOX_RECAPTCHA_KEY / WEBX_INBOX_RECAPTCHA_SECRET for reCAPTCHA, WEBX_INBOX_TURNSTILE_KEY / WEBX_INBOX_TURNSTILE_SECRET for Turnstile.",
176
- "captcha-off": "Off",
177
- "captcha-recaptcha": "reCAPTCHA",
178
- "captcha-turnstile": "Turnstile",
179
- "captcha-unconfigured": "The site has no keys for this captcha yet, so the form refuses every submission until they are in its .env.",
180
- "captcha-recaptcha-checkbox": "This site draws reCAPTCHA as the “I’m not a robot” checkbox, so its keys must be v2 Checkbox keys. To run it invisibly, create v2 Invisible keys and set WEBX_INBOX_RECAPTCHA_TYPE=invisible.",
181
- "captcha-recaptcha-invisible": "This site runs reCAPTCHA invisibly when the form is sent, so its keys must be v2 Invisible keys (WEBX_INBOX_RECAPTCHA_TYPE=invisible).",
182
- "captcha-recaptcha-v3": "This site runs reCAPTCHA v3: no widget, only a score checked when the form is sent, so its keys must be v3 keys (WEBX_INBOX_RECAPTCHA_TYPE=v3).",
183
- "captcha-turnstile-checkbox": "This site draws Turnstile when the page opens, and a Managed widget shows visitors “Verify you are human”. To run it invisibly, set WEBX_INBOX_TURNSTILE_MODE=invisible and the widget mode to Invisible in Cloudflare.",
184
- "captcha-turnstile-invisible": "This site runs Turnstile invisibly when the form is sent. Set the widget mode to Invisible in Cloudflare: a Managed widget still shows a challenge when it decides one is needed.",
185
- "embed-blade": "On a page of the site",
186
- "embed-blade-help": "Put the tag where the form belongs. The markup is published and rewritten by the site.",
187
- "embed-block": "In the block builder",
188
- "embed-block-help": "A block type prints the same tag, so an editor drops the form in without touching a template.",
189
- "embed-block-panel-help": "On this site block templates are written in the panel, in Blocks: put the same tag into the template of a block there.",
190
- "embed-extras": "Filled in and placed",
191
- "embed-extras-help": ":values fills the hidden fields by their name; placement names where the form stands, so the submission remembers it and the site can style each place.",
192
- loading: "Loading…",
193
- "embed-names": "Names of the fields",
194
- "embed-names-help": "A hidden field is filled in by the page: the address it was sent from, a product, a campaign.",
195
- copy: "Copy",
196
- copied: "Copied.",
197
- statuses: "Statuses",
198
- "new-status": "New status",
199
- "status-key": "Key",
200
- "status-color": "Colour",
201
- "status-default": "Given to a new submission",
202
- "status-spam": "Spam",
203
- "status-closed": "Nothing further expected",
204
- "in-use": "In use",
205
- "delete-status-title": "Delete “:status”?",
206
- "delete-status-text": "Only a status nothing is in can go.",
207
- "no-statuses": "No statuses yet.",
208
- "color-default": "Grey",
209
- "color-primary": "Blue",
210
- "color-success": "Green",
211
- "color-warning": "Amber",
212
- "color-info": "Cyan",
213
- "color-danger": "Red",
214
- // The submissions: the list on the right of the section, and one of them opened.
215
- id: "ID",
216
- received: "Received",
217
- status: "Status",
218
- assignee: "Assignee",
219
- unassigned: "Nobody",
220
- "submissions-empty": "Nothing has come in through this form yet.",
221
- "search-submissions": "Search the answers",
222
- "view-all": "All",
223
- "view-unread": "Unread",
224
- export: "Export",
225
- "new-submission": "New submission",
226
- "new-submission-title": "A submission by hand",
227
- "new-submission-help": "For one that came by telephone or on paper. It is written the same way and lands in the same list.",
228
- created: "Added.",
229
- submission: "Submission :id",
230
- previous: "Previous",
231
- next: "Next",
232
- "mark-read": "Mark as read",
233
- "mark-unread": "Mark as unread",
234
- "delete-submission-title": "Delete this submission?",
235
- "delete-submission-text": "It goes with its attachments. This cannot be undone.",
236
- selected: ":count selected",
237
- "move-to": "Move to",
238
- "delete-selected-title": "Delete :count submissions?",
239
- answers: "Answers",
240
- attachments: "Attachments",
241
- details: "Details",
242
- "meta-page": "Page",
243
- "meta-placement": "Placement",
244
- "any-placement": "Any placement",
245
- "placement-none": "Not specified",
246
- "meta-referrer": "Came from",
247
- "meta-ip": "Address",
248
- "meta-agent": "Browser",
249
- "meta-locale": "Language",
250
- "meta-source": "How it arrived",
251
- "source-web": "From the site",
252
- "source-panel": "Typed in",
253
- notified: "The notification went out",
254
- "not-notified": "No notification was sent",
255
- "notify-failed": "The notification could not be sent",
256
- reply: "Reply by mail",
257
- log: "What has happened",
258
- "event-created": "Arrived",
259
- "event-status": "Status: :to",
260
- "event-assignee": "Given to :to",
261
- "event-unassigned": "Left to nobody",
262
- "event-note": "A note was added",
263
- "event-notified": "The notification went out",
264
- "event-handled": "Handed to :name",
265
- "event-handler-error": ":name failed: :error",
266
- system: "System",
267
- "no-answers": "Nothing was filled in.",
268
- download: "Download",
269
- "no-files-by-hand": "A file cannot be attached by hand: the files a submission carries are what was posted with it.",
270
- "submissions-none": "Nothing here under this filter.",
271
- "notifies-nobody": "Nobody is told about this form",
272
- "notifies-nobody-text": "Every submission is kept here, but no letter goes out. Add a recipient on the Notifications tab.",
273
- "notifies-nobody-short": "Nobody is told",
274
- "recipient-admin_deleted": "This administrator no longer exists and gets no letter.",
275
- "recipient-admin_inactive": "This administrator is switched off and gets no letter.",
276
- "recipient-invalid_email": "This is not an e-mail address.",
277
- "event-no-recipients": "Nobody was told: the form names no recipients",
278
- "notified-nobody": "No notification: the form names nobody to tell",
279
- "notify-queued": "The notification is waiting in the queue",
280
- "notify-again": "Send the notification again",
281
- "notify-sent-again": "The notification has been sent again",
282
- "notify-recipient-queued": "waiting",
283
- "notify-recipient-delivered": "sent",
284
- "notify-recipient-failed": "failed",
285
- "event-notify-queued": "The notification was queued",
286
- "event-notify-failed": "The notification to :to failed",
287
- "event-value": "Answer “:field” corrected: “:from” → “:to”"
288
- },
289
- fields: {
290
- field: "Field",
291
- "new-field": "New field",
292
- "edit-field": "Field",
293
- edit: "Edit",
294
- "no-fields": "No questions yet.",
295
- "no-fields-help": "A form with no fields draws nothing on the page.",
296
- "save-first": "Save the form first, then write its questions.",
297
- delete: "Delete",
298
- "delete-title": "Delete “:field”?",
299
- "delete-text": "It stops being asked. Answers already given keep it.",
300
- cancel: "Cancel",
301
- save: "Save",
302
- name: "Name",
303
- "name-help": "What the field is called in the HTML. Left empty, it answers to f17.",
304
- type: "Type",
305
- title: "Label",
306
- placeholder: "Placeholder",
307
- help: "Hint under the field",
308
- "is-enabled": "Shown",
309
- "is-required": "Required",
310
- "is-fullsize": "Full width",
311
- "in-table": "A column in the list",
312
- choices: "Choices",
313
- "choice-value": "Value",
314
- "choice-label": "Label",
315
- "add-choice": "Add a choice",
316
- "no-choices": "No choices yet. A field with none accepts nothing.",
317
- maxlength: "Longest answer, in characters",
318
- rows: "Height, in lines",
319
- pattern: "Pattern the answer has to match",
320
- "pattern-help": "The browser’s own, written without delimiters: [0-9+ ()-]{6,}",
321
- earliest: "Earliest date",
322
- latest: "Latest date",
323
- "min-choices": "Fewest ticks",
324
- "max-choices": "Most ticks",
325
- "consent-text": "The sentence beside the tick",
326
- "consent-text-help": "A link is allowed here: it is printed as written.",
327
- "max-size": "Largest file, in kilobytes",
328
- extensions: "Extensions allowed",
329
- "extensions-help": "Comma separated. Empty means the list the site allows.",
330
- multiple: "Several files at once",
331
- "type-text": "Text",
332
- "type-email": "E-mail",
333
- "type-tel": "Telephone",
334
- "type-textarea": "Long text",
335
- "type-select": "Drop-down",
336
- "type-radio": "One of several",
337
- "type-checkbox": "Several of several",
338
- "type-consent": "Consent",
339
- "type-date": "Date",
340
- "type-file": "File",
341
- "type-hidden": "Hidden"
342
- }
343
- }, pl = /* @__PURE__ */ new WeakSet();
344
- function pe() {
345
- try {
346
- const { i18n: s } = ie();
347
- pl.has(s) || (s.defaults("webx-inbox", Ml), pl.add(s));
348
- } catch {
349
- }
350
- }
351
- function ol() {
352
- const s = gl(wl, null), o = ke();
353
- return (d) => {
354
- const u = s?.state.locale;
355
- return (u === void 0 ? void 0 : d.title[u]) || we(d.title, o.active.value, d.key);
356
- };
357
- }
358
- const Ol = [
359
- "text",
360
- "email",
361
- "tel",
362
- "textarea",
363
- "select",
364
- "radio",
365
- "checkbox",
366
- "consent",
367
- "date",
368
- "file",
369
- "hidden"
370
- ], Bl = ["default", "primary", "success", "warning", "info", "danger"], Dl = { class: "wx-inbox-field-form" }, Ll = { class: "wx-inbox-field-form__row" }, Rl = {
371
- key: 2,
372
- class: "wx-inbox-choices"
373
- }, Hl = { class: "wx-inbox-field-form__row" }, Xl = { class: "wx-inbox-field-form__checks" }, Gl = /* @__PURE__ */ se({
374
- __name: "FieldDialog",
375
- props: {
376
- field: {},
377
- form: {}
378
- },
379
- setup(s) {
380
- const o = s, { resolve: d, dismiss: u, open: m } = Xe(), T = ie(), n = ce(T);
381
- pe();
382
- const l = ae("webx-inbox"), V = be(), b = W(!1), p = W({}), U = W(""), _ = W("text"), $ = W({}), c = W({}), N = W({}), v = W({}), y = W(!0), S = W(!1), z = W(!0), q = W(!1);
383
- Ue(
384
- () => o.field,
385
- (I) => {
386
- U.value = I?.name ?? "", _.value = I?.type ?? "text", $.value = { ...I?.title ?? {} }, c.value = { ...I?.placeholder ?? {} }, N.value = { ...I?.help ?? {} }, v.value = { ...I?.options ?? {} }, y.value = I?.is_enabled ?? !0, S.value = I?.is_required ?? !1, z.value = I?.is_fullsize ?? !0, q.value = I?.in_table ?? !1, p.value = {};
387
- },
388
- { immediate: !0 }
389
- );
390
- const D = C(
391
- () => Ol.map((I) => ({ value: I, label: l(`fields.type-${I}`) }))
392
- ), j = C(() => ["select", "radio", "checkbox"].includes(_.value)), L = C(
393
- () => Array.isArray(v.value.choices) ? v.value.choices : []
394
- ), R = C({
395
- get: () => Array.isArray(v.value.extensions) ? v.value.extensions : [],
396
- set: (I) => r(
397
- "extensions",
398
- I.map((w) => w.replace(/^\./, ""))
399
- )
400
- });
401
- function r(I, w) {
402
- v.value = { ...v.value, [I]: w };
403
- }
404
- function B() {
405
- r("choices", [...L.value, { value: "", label: {} }]);
406
- }
407
- function Q(I) {
408
- r(
409
- "choices",
410
- L.value.filter((w, h) => h !== I)
411
- );
412
- }
413
- function me(I, w) {
414
- r(
415
- "choices",
416
- L.value.map((h, re) => re === I ? { ...h, ...w } : h)
417
- );
418
- }
419
- function F(I) {
420
- return p.value[I]?.[0];
421
- }
422
- async function J() {
423
- b.value = !0, p.value = {};
424
- const I = {
425
- name: U.value.trim() === "" ? null : U.value.trim(),
426
- type: _.value,
427
- title: $.value,
428
- placeholder: c.value,
429
- help: N.value,
430
- options: v.value,
431
- is_enabled: y.value,
432
- is_required: S.value,
433
- is_fullsize: z.value,
434
- in_table: q.value
435
- };
436
- try {
437
- d(
438
- o.field === null ? await n.createField(o.form.id, I) : await n.saveField(o.field.id, I)
439
- );
440
- } catch (w) {
441
- const h = w.body;
442
- h?.errors ? (p.value = h.errors, O.danger(l("panel.failed"))) : O.danger(V(w));
443
- } finally {
444
- b.value = !1;
445
- }
446
- }
447
- return (I, w) => (i(), g(e(Ge), {
448
- open: e(m),
449
- "onUpdate:open": w[21] || (w[21] = (h) => oe(m) ? m.value = h : null),
450
- title: s.field ? e(l)("fields.edit-field") : e(l)("fields.new-field"),
451
- width: 720
452
- }, {
453
- footer: a(() => [
454
- t(e(Ie), { size: "sm" }, {
455
- default: a(() => [
456
- t(e(te), {
457
- variant: "outline",
458
- onClick: w[20] || (w[20] = (h) => e(u)())
459
- }, {
460
- default: a(() => [
461
- A(x(e(l)("fields.cancel")), 1)
462
- ]),
463
- _: 1
464
- }),
465
- t(e(te), {
466
- type: "primary",
467
- loading: b.value,
468
- onClick: J
469
- }, {
470
- default: a(() => [
471
- A(x(e(l)("fields.save")), 1)
472
- ]),
473
- _: 1
474
- }, 8, ["loading"])
475
- ]),
476
- _: 1
477
- })
478
- ]),
479
- default: a(() => [
480
- H("div", Dl, [
481
- H("div", Ll, [
482
- t(e(X), {
483
- label: e(l)("fields.type")
484
- }, {
485
- default: a(() => [
486
- t(e(fe), {
487
- modelValue: _.value,
488
- "onUpdate:modelValue": w[0] || (w[0] = (h) => _.value = h),
489
- options: D.value
490
- }, null, 8, ["modelValue", "options"])
491
- ]),
492
- _: 1
493
- }, 8, ["label"]),
494
- t(e(X), {
495
- label: e(l)("fields.name"),
496
- help: e(l)("fields.name-help"),
497
- error: F("name")
498
- }, {
499
- default: a(() => [
500
- t(e(le), {
501
- modelValue: U.value,
502
- "onUpdate:modelValue": w[1] || (w[1] = (h) => U.value = h),
503
- placeholder: "email"
504
- }, null, 8, ["modelValue"])
505
- ]),
506
- _: 1
507
- }, 8, ["label", "help", "error"])
508
- ]),
509
- t(e(X), {
510
- label: e(l)("fields.title"),
511
- error: F("title"),
512
- required: ""
513
- }, {
514
- default: a(() => [
515
- t(e(le), {
516
- modelValue: $.value,
517
- "onUpdate:modelValue": w[2] || (w[2] = (h) => $.value = h),
518
- localized: ""
519
- }, null, 8, ["modelValue"])
520
- ]),
521
- _: 1
522
- }, 8, ["label", "error"]),
523
- _.value !== "hidden" ? (i(), G(ee, { key: 0 }, [
524
- _.value !== "consent" ? (i(), g(e(X), {
525
- key: 0,
526
- label: e(l)("fields.placeholder")
527
- }, {
528
- default: a(() => [
529
- t(e(le), {
530
- modelValue: c.value,
531
- "onUpdate:modelValue": w[3] || (w[3] = (h) => c.value = h),
532
- localized: ""
533
- }, null, 8, ["modelValue"])
534
- ]),
535
- _: 1
536
- }, 8, ["label"])) : M("", !0),
537
- t(e(X), {
538
- label: e(l)("fields.help")
539
- }, {
540
- default: a(() => [
541
- t(e(le), {
542
- modelValue: N.value,
543
- "onUpdate:modelValue": w[4] || (w[4] = (h) => N.value = h),
544
- localized: ""
545
- }, null, 8, ["modelValue"])
546
- ]),
547
- _: 1
548
- }, 8, ["label"])
549
- ], 64)) : M("", !0),
550
- _.value === "consent" ? (i(), g(e(X), {
551
- key: 1,
552
- label: e(l)("fields.consent-text"),
553
- help: e(l)("fields.consent-text-help")
554
- }, {
555
- default: a(() => [
556
- t(hl, {
557
- "model-value": v.value.text ?? {},
558
- "min-height": "100px",
559
- "onUpdate:modelValue": w[5] || (w[5] = (h) => r("text", h))
560
- }, null, 8, ["model-value"])
561
- ]),
562
- _: 1
563
- }, 8, ["label", "help"])) : M("", !0),
564
- j.value ? (i(), G("div", Rl, [
565
- t(e(Y), {
566
- size: "sm",
567
- weight: "medium"
568
- }, {
569
- default: a(() => [
570
- A(x(e(l)("fields.choices")), 1)
571
- ]),
572
- _: 1
573
- }),
574
- L.value.length === 0 ? (i(), g(e(Y), {
575
- key: 0,
576
- size: "sm",
577
- tone: "placeholder"
578
- }, {
579
- default: a(() => [
580
- A(x(e(l)("fields.no-choices")), 1)
581
- ]),
582
- _: 1
583
- })) : M("", !0),
584
- (i(!0), G(ee, null, ye(L.value, (h, re) => (i(), G("div", {
585
- key: re,
586
- class: "wx-inbox-choices__row"
587
- }, [
588
- t(e(le), {
589
- "model-value": h.value,
590
- placeholder: e(l)("fields.choice-value"),
591
- "onUpdate:modelValue": (de) => me(re, { value: String(de) })
592
- }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"]),
593
- t(e(le), {
594
- "model-value": h.label,
595
- localized: "",
596
- placeholder: e(l)("fields.choice-label"),
597
- "onUpdate:modelValue": (de) => me(re, { label: de })
598
- }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"]),
599
- t(e(xe), {
600
- icon: "trash",
601
- title: e(l)("fields.delete"),
602
- onClick: (de) => Q(re)
603
- }, null, 8, ["title", "onClick"])
604
- ]))), 128)),
605
- t(e(te), {
606
- variant: "outline",
607
- size: "sm",
608
- onClick: B
609
- }, {
610
- icon: a(() => [
611
- t(e(_e), { name: "plus" })
612
- ]),
613
- default: a(() => [
614
- A(" " + x(e(l)("fields.add-choice")), 1)
615
- ]),
616
- _: 1
617
- }),
618
- F("options.choices") ? (i(), g(e(Y), {
619
- key: 1,
620
- size: "sm",
621
- tone: "danger"
622
- }, {
623
- default: a(() => [
624
- A(x(F("options.choices")), 1)
625
- ]),
626
- _: 1
627
- })) : M("", !0)
628
- ])) : M("", !0),
629
- H("div", Hl, [
630
- _.value === "textarea" ? (i(), g(e(X), {
631
- key: 0,
632
- label: e(l)("fields.rows")
633
- }, {
634
- default: a(() => [
635
- t(e(Ve), {
636
- "model-value": v.value.rows ?? 5,
637
- min: 2,
638
- max: 30,
639
- "onUpdate:modelValue": w[6] || (w[6] = (h) => r("rows", h))
640
- }, null, 8, ["model-value"])
641
- ]),
642
- _: 1
643
- }, 8, ["label"])) : M("", !0),
644
- ["text", "email", "textarea"].includes(_.value) ? (i(), g(e(X), {
645
- key: 1,
646
- label: e(l)("fields.maxlength")
647
- }, {
648
- default: a(() => [
649
- t(e(Ve), {
650
- "model-value": v.value.maxlength ?? null,
651
- min: 1,
652
- max: 2e4,
653
- "onUpdate:modelValue": w[7] || (w[7] = (h) => r("maxlength", h))
654
- }, null, 8, ["model-value"])
655
- ]),
656
- _: 1
657
- }, 8, ["label"])) : M("", !0),
658
- _.value === "tel" ? (i(), g(e(X), {
659
- key: 2,
660
- label: e(l)("fields.pattern"),
661
- help: e(l)("fields.pattern-help")
662
- }, {
663
- default: a(() => [
664
- t(e(le), {
665
- "model-value": v.value.pattern ?? "",
666
- "onUpdate:modelValue": w[8] || (w[8] = (h) => r("pattern", h))
667
- }, null, 8, ["model-value"])
668
- ]),
669
- _: 1
670
- }, 8, ["label", "help"])) : M("", !0),
671
- _.value === "date" ? (i(), G(ee, { key: 3 }, [
672
- t(e(X), {
673
- label: e(l)("fields.earliest")
674
- }, {
675
- default: a(() => [
676
- t(e(tl), {
677
- clearable: "",
678
- "model-value": v.value.min ?? null,
679
- "onUpdate:modelValue": w[9] || (w[9] = (h) => r("min", h))
680
- }, null, 8, ["model-value"])
681
- ]),
682
- _: 1
683
- }, 8, ["label"]),
684
- t(e(X), {
685
- label: e(l)("fields.latest")
686
- }, {
687
- default: a(() => [
688
- t(e(tl), {
689
- clearable: "",
690
- "model-value": v.value.max ?? null,
691
- "onUpdate:modelValue": w[10] || (w[10] = (h) => r("max", h))
692
- }, null, 8, ["model-value"])
693
- ]),
694
- _: 1
695
- }, 8, ["label"])
696
- ], 64)) : M("", !0),
697
- _.value === "checkbox" ? (i(), G(ee, { key: 4 }, [
698
- t(e(X), {
699
- label: e(l)("fields.min-choices")
700
- }, {
701
- default: a(() => [
702
- t(e(Ve), {
703
- "model-value": v.value.min ?? null,
704
- min: 0,
705
- "onUpdate:modelValue": w[11] || (w[11] = (h) => r("min", h))
706
- }, null, 8, ["model-value"])
707
- ]),
708
- _: 1
709
- }, 8, ["label"]),
710
- t(e(X), {
711
- label: e(l)("fields.max-choices")
712
- }, {
713
- default: a(() => [
714
- t(e(Ve), {
715
- "model-value": v.value.max ?? null,
716
- min: 0,
717
- "onUpdate:modelValue": w[12] || (w[12] = (h) => r("max", h))
718
- }, null, 8, ["model-value"])
719
- ]),
720
- _: 1
721
- }, 8, ["label"])
722
- ], 64)) : M("", !0),
723
- _.value === "file" ? (i(), g(e(X), {
724
- key: 5,
725
- label: e(l)("fields.max-size")
726
- }, {
727
- default: a(() => [
728
- t(e(Ve), {
729
- "model-value": v.value.max_size ?? null,
730
- min: 1,
731
- "onUpdate:modelValue": w[13] || (w[13] = (h) => r("max_size", h))
732
- }, null, 8, ["model-value"])
733
- ]),
734
- _: 1
735
- }, 8, ["label"])) : M("", !0)
736
- ]),
737
- _.value === "file" ? (i(), G(ee, { key: 3 }, [
738
- t(e(X), {
739
- label: e(l)("fields.extensions"),
740
- help: e(l)("fields.extensions-help")
741
- }, {
742
- default: a(() => [
743
- t(e(Sl), {
744
- modelValue: R.value,
745
- "onUpdate:modelValue": w[14] || (w[14] = (h) => R.value = h)
746
- }, null, 8, ["modelValue"])
747
- ]),
748
- _: 1
749
- }, 8, ["label", "help"]),
750
- t(e(he), {
751
- "model-value": !!v.value.multiple,
752
- label: e(l)("fields.multiple"),
753
- "onUpdate:modelValue": w[15] || (w[15] = (h) => r("multiple", h))
754
- }, null, 8, ["model-value", "label"])
755
- ], 64)) : M("", !0),
756
- H("div", Xl, [
757
- t(e(he), {
758
- modelValue: y.value,
759
- "onUpdate:modelValue": w[16] || (w[16] = (h) => y.value = h),
760
- label: e(l)("fields.is-enabled")
761
- }, null, 8, ["modelValue", "label"]),
762
- t(e(he), {
763
- modelValue: S.value,
764
- "onUpdate:modelValue": w[17] || (w[17] = (h) => S.value = h),
765
- label: e(l)("fields.is-required")
766
- }, null, 8, ["modelValue", "label"]),
767
- _.value !== "hidden" ? (i(), g(e(he), {
768
- key: 0,
769
- modelValue: z.value,
770
- "onUpdate:modelValue": w[18] || (w[18] = (h) => z.value = h),
771
- label: e(l)("fields.is-fullsize")
772
- }, null, 8, ["modelValue", "label"])) : M("", !0),
773
- t(e(he), {
774
- modelValue: q.value,
775
- "onUpdate:modelValue": w[19] || (w[19] = (h) => q.value = h),
776
- label: e(l)("fields.in-table")
777
- }, null, 8, ["modelValue", "label"])
778
- ])
779
- ])
780
- ]),
781
- _: 1
782
- }, 8, ["open", "title"]));
783
- }
784
- }), ue = (s, o) => {
785
- const d = s.__vccOpts || s;
786
- for (const [u, m] of o)
787
- d[u] = m;
788
- return d;
789
- }, jl = /* @__PURE__ */ ue(Gl, [["__scopeId", "data-v-a3de6c60"]]), Yl = { class: "wx-inbox-field" }, Kl = { class: "wx-inbox-field__name" }, Zl = /* @__PURE__ */ se({
790
- __name: "FieldList",
791
- props: /* @__PURE__ */ Fe({
792
- form: {},
793
- canManage: { type: Boolean }
794
- }, {
795
- modelValue: { required: !0 },
796
- modelModifiers: {}
797
- }),
798
- emits: ["update:modelValue"],
799
- setup(s) {
800
- const o = s, d = Se(s, "modelValue"), u = ie(), m = ce(u), T = ke();
801
- pe();
802
- const n = ae("webx-inbox"), l = be(), V = je(jl);
803
- function b(v) {
804
- return we(v.title, T.active.value, v.key);
805
- }
806
- function p(v) {
807
- return [
808
- n(`fields.type-${v.type}`),
809
- ...v.is_required ? [n("fields.is-required")] : [],
810
- ...v.in_table ? [n("fields.in-table")] : [],
811
- ...v.is_fullsize ? [] : [n("fields.is-fullsize")]
812
- ];
813
- }
814
- const U = C(() => d.value.length === 0);
815
- async function _(v) {
816
- const y = await V({ field: v, form: o.form });
817
- y && (d.value = v === null ? [...d.value, y] : d.value.map((S) => S.id === y.id ? y : S));
818
- }
819
- async function $(v) {
820
- if (await Ae({
821
- title: n("fields.delete-title", { field: b(v) }),
822
- message: n("fields.delete-text"),
823
- confirmText: n("fields.delete"),
824
- cancelText: n("fields.cancel"),
825
- tone: "danger"
826
- }))
827
- try {
828
- await m.removeField(v.id), d.value = d.value.filter((S) => S.id !== v.id), O.success(n("panel.deleted"));
829
- } catch (S) {
830
- O.danger(l(S));
831
- }
832
- }
833
- function c(v) {
834
- return o.canManage ? [
835
- { key: "edit", icon: "edit", label: n("fields.edit"), run: () => {
836
- _(v);
837
- } },
838
- {
839
- key: "delete",
840
- icon: "trash",
841
- label: n("fields.delete"),
842
- danger: !0,
843
- run: () => {
844
- $(v);
845
- }
846
- }
847
- ] : [];
848
- }
849
- async function N() {
850
- try {
851
- await m.sortFields(
852
- o.form.id,
853
- d.value.map((v) => v.id)
854
- );
855
- } catch (v) {
856
- O.danger(l(v, n("panel.reorder-failed")));
857
- }
858
- }
859
- return (v, y) => (i(), g(e(ne), {
860
- title: e(n)("panel.tab-fields")
861
- }, De({
862
- default: a(() => [
863
- U.value ? (i(), g(e(Ye), {
864
- key: 0,
865
- title: e(n)("fields.no-fields"),
866
- description: e(n)("fields.no-fields-help")
867
- }, null, 8, ["title", "description"])) : (i(), g(e(nl), {
868
- key: 1,
869
- modelValue: d.value,
870
- "onUpdate:modelValue": y[1] || (y[1] = (S) => d.value = S),
871
- plain: "",
872
- "item-key": "id",
873
- "item-label": b,
874
- "drag-label": e(n)("panel.reorder"),
875
- disabled: !s.canManage,
876
- "aria-label": e(n)("panel.tab-fields"),
877
- onMove: N
878
- }, {
879
- default: a(({ item: S }) => [
880
- H("div", Yl, [
881
- H("div", Kl, [
882
- t(e(Y), {
883
- weight: "medium",
884
- truncate: ""
885
- }, {
886
- default: a(() => [
887
- A(x(b(S)), 1)
888
- ]),
889
- _: 2
890
- }, 1024),
891
- S.is_enabled ? M("", !0) : (i(), g(e($e), {
892
- key: 0,
893
- type: "default"
894
- }, {
895
- default: a(() => [
896
- A(x(e(n)("panel.off")), 1)
897
- ]),
898
- _: 1
899
- }))
900
- ]),
901
- t(e(Y), {
902
- size: "sm",
903
- tone: "muted",
904
- truncate: ""
905
- }, {
906
- default: a(() => [
907
- H("code", null, "fields[" + x(S.key) + "]", 1),
908
- A(" · " + x(p(S).join(" · ")), 1)
909
- ]),
910
- _: 2
911
- }, 1024)
912
- ])
913
- ]),
914
- actions: a(({ item: S }) => [
915
- t(e(We), {
916
- actions: c(S),
917
- label: b(S)
918
- }, null, 8, ["actions", "label"])
919
- ]),
920
- _: 1
921
- }, 8, ["modelValue", "drag-label", "disabled", "aria-label"]))
922
- ]),
923
- _: 2
924
- }, [
925
- s.canManage ? {
926
- name: "extra",
927
- fn: a(() => [
928
- t(e(te), {
929
- type: "primary",
930
- size: "sm",
931
- onClick: y[0] || (y[0] = (S) => _(null))
932
- }, {
933
- icon: a(() => [
934
- t(e(_e), { name: "plus" })
935
- ]),
936
- default: a(() => [
937
- A(" " + x(e(n)("fields.new-field")), 1)
938
- ]),
939
- _: 1
940
- })
941
- ]),
942
- key: "0"
943
- } : void 0
944
- ]), 1032, ["title"]));
945
- }
946
- }), Ql = /* @__PURE__ */ ue(Zl, [["__scopeId", "data-v-db38e823"]]);
947
- function ve(s, o, d) {
948
- return C({
949
- get: () => s.value[o] ?? d,
950
- set: (u) => {
951
- const m = { ...s.value };
952
- u === "" || u === null || u === void 0 ? delete m[o] : m[o] = u, s.value = m;
953
- }
954
- });
955
- }
956
- const Jl = /* @__PURE__ */ se({
957
- __name: "FormAntispam",
958
- props: /* @__PURE__ */ Fe({
959
- site: {}
960
- }, {
961
- modelValue: { required: !0 },
962
- modelModifiers: {}
963
- }),
964
- emits: ["update:modelValue"],
965
- setup(s) {
966
- const o = Se(s, "modelValue"), d = s, u = ae("webx-inbox"), m = ve(o, "antispam.honeypot", !0), T = ve(o, "antispam.min_seconds", 3), n = ve(o, "antispam.throttle", 5), l = ve(o, "antispam.captcha", "off"), V = C(() => [
967
- { value: "off", label: u("panel.captcha-off") },
968
- { value: "recaptcha", label: u("panel.captcha-recaptcha") },
969
- { value: "turnstile", label: u("panel.captcha-turnstile") }
970
- ]), b = C(() => {
971
- const U = l.value;
972
- return U !== "recaptcha" && U !== "turnstile" ? null : { provider: U, site: d.site?.[U] ?? null };
973
- }), p = C(() => {
974
- const U = b.value?.site;
975
- return U ? u(`panel.captcha-${b.value.provider}-${U.type}`) : null;
976
- });
977
- return (U, _) => (i(), g(e(ne), null, {
978
- default: a(() => [
979
- t(e(X), {
980
- help: e(u)("panel.honeypot-help")
981
- }, {
982
- default: a(() => [
983
- t(e(fl), {
984
- modelValue: e(m),
985
- "onUpdate:modelValue": _[0] || (_[0] = ($) => oe(m) ? m.value = $ : null),
986
- label: e(u)("panel.honeypot")
987
- }, null, 8, ["modelValue", "label"])
988
- ]),
989
- _: 1
990
- }, 8, ["help"]),
991
- t(e(X), {
992
- label: e(u)("panel.min-seconds"),
993
- help: e(u)("panel.min-seconds-help")
994
- }, {
995
- default: a(() => [
996
- t(e(Ve), {
997
- modelValue: e(T),
998
- "onUpdate:modelValue": _[1] || (_[1] = ($) => oe(T) ? T.value = $ : null),
999
- min: 0,
1000
- max: 120
1001
- }, null, 8, ["modelValue"])
1002
- ]),
1003
- _: 1
1004
- }, 8, ["label", "help"]),
1005
- t(e(X), {
1006
- label: e(u)("panel.throttle"),
1007
- help: e(u)("panel.throttle-help")
1008
- }, {
1009
- default: a(() => [
1010
- t(e(Ve), {
1011
- modelValue: e(n),
1012
- "onUpdate:modelValue": _[2] || (_[2] = ($) => oe(n) ? n.value = $ : null),
1013
- min: 0,
1014
- max: 120
1015
- }, null, 8, ["modelValue"])
1016
- ]),
1017
- _: 1
1018
- }, 8, ["label", "help"]),
1019
- t(e(X), {
1020
- label: e(u)("panel.captcha"),
1021
- help: e(u)("panel.captcha-keys")
1022
- }, {
1023
- default: a(() => [
1024
- t(e(fe), {
1025
- modelValue: e(l),
1026
- "onUpdate:modelValue": _[3] || (_[3] = ($) => oe(l) ? l.value = $ : null),
1027
- options: V.value
1028
- }, null, 8, ["modelValue", "options"])
1029
- ]),
1030
- _: 1
1031
- }, 8, ["label", "help"]),
1032
- p.value ? (i(), g(e(Y), {
1033
- key: 0,
1034
- size: "sm",
1035
- tone: "muted"
1036
- }, {
1037
- default: a(() => [
1038
- A(x(p.value), 1)
1039
- ]),
1040
- _: 1
1041
- })) : M("", !0),
1042
- b.value?.site && !b.value.site.configured ? (i(), g(e(Ce), {
1043
- key: 1,
1044
- type: "warning",
1045
- variant: "soft",
1046
- closable: !1,
1047
- description: e(u)("panel.captcha-unconfigured")
1048
- }, null, 8, ["description"])) : M("", !0)
1049
- ]),
1050
- _: 1
1051
- }));
1052
- }
1053
- }), et = { class: "wx-inbox-embed" }, lt = { class: "wx-inbox-embed__snippet" }, tt = { class: "wx-inbox-embed__snippet" }, at = { class: "wx-inbox-embed__snippet" }, nt = /* @__PURE__ */ se({
1054
- __name: "FormEmbed",
1055
- props: {
1056
- form: {},
1057
- slug: {},
1058
- fields: {}
1059
- },
1060
- setup(s) {
1061
- const o = s;
1062
- pe();
1063
- const d = ae("webx-inbox"), u = ie(), m = C(
1064
- () => u.state.manifest?.modules.some((_) => _.id === "blocks") ?? !1
1065
- ), T = C(() => `<x-webx-inbox::form slug="${o.slug}" />`), n = C(
1066
- () => m.value ? T.value : `{{-- resources/views/blocks/contact.blade.php --}}
1067
- <x-webx-inbox::form slug="${o.slug}" />`
1068
- ), l = C(
1069
- () => o.fields.find((_) => _.type === "hidden" && _.is_enabled)?.key ?? "page"
1070
- ), V = C(
1071
- () => `<x-webx-inbox::form slug="${o.slug}" :values="['${l.value}' => url()->current()]" />
1072
- <x-webx-inbox::form slug="${o.slug}" placement="footer" />`
1073
- ), b = C(() => [
1074
- { key: "key", label: d("fields.name") },
1075
- { key: "title", label: d("fields.title") },
1076
- { key: "type", label: d("fields.type"), hideBelow: 520 }
1077
- ]), p = C(() => o.fields.filter((_) => _.is_enabled));
1078
- async function U(_) {
1079
- try {
1080
- await navigator.clipboard.writeText(_), O.success(d("panel.copied"));
1081
- } catch {
1082
- }
1083
- }
1084
- return (_, $) => (i(), G("div", et, [
1085
- t(e(ne), {
1086
- title: e(d)("panel.embed-blade")
1087
- }, {
1088
- default: a(() => [
1089
- t(e(Y), {
1090
- size: "sm",
1091
- tone: "muted"
1092
- }, {
1093
- default: a(() => [
1094
- A(x(e(d)("panel.embed-blade-help")), 1)
1095
- ]),
1096
- _: 1
1097
- }),
1098
- H("div", lt, [
1099
- H("code", null, x(T.value), 1),
1100
- t(e(xe), {
1101
- icon: "copy",
1102
- title: e(d)("panel.copy"),
1103
- onClick: $[0] || ($[0] = (c) => U(T.value))
1104
- }, null, 8, ["title"])
1105
- ])
1106
- ]),
1107
- _: 1
1108
- }, 8, ["title"]),
1109
- t(e(ne), {
1110
- title: e(d)("panel.embed-block")
1111
- }, {
1112
- default: a(() => [
1113
- t(e(Y), {
1114
- size: "sm",
1115
- tone: "muted"
1116
- }, {
1117
- default: a(() => [
1118
- A(x(e(d)(m.value ? "panel.embed-block-panel-help" : "panel.embed-block-help")), 1)
1119
- ]),
1120
- _: 1
1121
- }),
1122
- H("div", tt, [
1123
- H("code", null, x(n.value), 1),
1124
- t(e(xe), {
1125
- icon: "copy",
1126
- title: e(d)("panel.copy"),
1127
- onClick: $[1] || ($[1] = (c) => U(n.value))
1128
- }, null, 8, ["title"])
1129
- ])
1130
- ]),
1131
- _: 1
1132
- }, 8, ["title"]),
1133
- t(e(ne), {
1134
- title: e(d)("panel.embed-extras")
1135
- }, {
1136
- default: a(() => [
1137
- t(e(Y), {
1138
- size: "sm",
1139
- tone: "muted"
1140
- }, {
1141
- default: a(() => [
1142
- A(x(e(d)("panel.embed-extras-help")), 1)
1143
- ]),
1144
- _: 1
1145
- }),
1146
- H("div", at, [
1147
- H("code", null, x(V.value), 1),
1148
- t(e(xe), {
1149
- icon: "copy",
1150
- title: e(d)("panel.copy"),
1151
- onClick: $[2] || ($[2] = (c) => U(V.value))
1152
- }, null, 8, ["title"])
1153
- ])
1154
- ]),
1155
- _: 1
1156
- }, 8, ["title"]),
1157
- t(e(ne), {
1158
- title: e(d)("panel.embed-names")
1159
- }, {
1160
- default: a(() => [
1161
- t(e(Y), {
1162
- size: "sm",
1163
- tone: "muted"
1164
- }, {
1165
- default: a(() => [
1166
- A(x(e(d)("panel.embed-names-help")), 1)
1167
- ]),
1168
- _: 1
1169
- }),
1170
- t(e(bl), {
1171
- data: p.value,
1172
- columns: b.value,
1173
- "row-key": "id",
1174
- flush: "",
1175
- "empty-text": e(d)("fields.no-fields")
1176
- }, {
1177
- "cell-key": a(({ row: c }) => [
1178
- t(e(Y), {
1179
- mono: "",
1180
- size: "sm"
1181
- }, {
1182
- default: a(() => [
1183
- A("fields[" + x(c.key) + "]", 1)
1184
- ]),
1185
- _: 2
1186
- }, 1024)
1187
- ]),
1188
- "cell-title": a(({ row: c }) => [
1189
- A(x(Object.values(c.title)[0] ?? c.key), 1)
1190
- ]),
1191
- "cell-type": a(({ row: c }) => [
1192
- A(x(e(d)(`fields.type-${c.type}`)), 1)
1193
- ]),
1194
- _: 1
1195
- }, 8, ["data", "columns", "empty-text"])
1196
- ]),
1197
- _: 1
1198
- }, 8, ["title"])
1199
- ]));
1200
- }
1201
- }), st = /* @__PURE__ */ ue(nt, [["__scopeId", "data-v-7f9788ed"]]), ot = { class: "wx-inbox-general" }, it = /* @__PURE__ */ se({
1202
- __name: "FormGeneral",
1203
- props: /* @__PURE__ */ Fe({
1204
- errors: {}
1205
- }, {
1206
- settings: { required: !0 },
1207
- settingsModifiers: {},
1208
- options: { required: !0 },
1209
- optionsModifiers: {}
1210
- }),
1211
- emits: ["update:settings", "update:options"],
1212
- setup(s) {
1213
- const o = Se(
1214
- s,
1215
- "settings"
1216
- ), d = Se(s, "options"), u = ae("webx-inbox"), m = ve(d, "thank-you.heading", {}), T = ve(d, "thank-you.text", {}), n = ve(d, "design.submit-text", {}), l = ve(d, "redirect", "");
1217
- return (V, b) => (i(), G("div", ot, [
1218
- t(e(ne), null, {
1219
- default: a(() => [
1220
- t(e(X), {
1221
- label: e(u)("panel.title"),
1222
- error: s.errors.title?.[0],
1223
- required: ""
1224
- }, {
1225
- default: a(() => [
1226
- t(e(le), {
1227
- modelValue: o.value.title,
1228
- "onUpdate:modelValue": b[0] || (b[0] = (p) => o.value.title = p),
1229
- localized: ""
1230
- }, null, 8, ["modelValue"])
1231
- ]),
1232
- _: 1
1233
- }, 8, ["label", "error"]),
1234
- t(e(X), {
1235
- label: e(u)("panel.slug"),
1236
- help: e(u)("panel.slug-help"),
1237
- error: s.errors.slug?.[0],
1238
- required: ""
1239
- }, {
1240
- default: a(() => [
1241
- t(e(le), {
1242
- modelValue: o.value.slug,
1243
- "onUpdate:modelValue": b[1] || (b[1] = (p) => o.value.slug = p),
1244
- placeholder: "contact"
1245
- }, null, 8, ["modelValue"])
1246
- ]),
1247
- _: 1
1248
- }, 8, ["label", "help", "error"]),
1249
- t(e(X), {
1250
- help: e(u)("panel.is-enabled-help")
1251
- }, {
1252
- default: a(() => [
1253
- t(e(fl), {
1254
- modelValue: o.value.is_enabled,
1255
- "onUpdate:modelValue": b[2] || (b[2] = (p) => o.value.is_enabled = p),
1256
- label: e(u)("panel.is-enabled")
1257
- }, null, 8, ["modelValue", "label"])
1258
- ]),
1259
- _: 1
1260
- }, 8, ["help"])
1261
- ]),
1262
- _: 1
1263
- }),
1264
- t(e(ne), {
1265
- title: e(u)("panel.after-sending")
1266
- }, {
1267
- default: a(() => [
1268
- t(e(X), {
1269
- label: e(u)("panel.submit-text")
1270
- }, {
1271
- default: a(() => [
1272
- t(e(le), {
1273
- modelValue: e(n),
1274
- "onUpdate:modelValue": b[3] || (b[3] = (p) => oe(n) ? n.value = p : null),
1275
- localized: ""
1276
- }, null, 8, ["modelValue"])
1277
- ]),
1278
- _: 1
1279
- }, 8, ["label"]),
1280
- t(e(X), {
1281
- label: e(u)("panel.thank-you-heading")
1282
- }, {
1283
- default: a(() => [
1284
- t(e(le), {
1285
- modelValue: e(m),
1286
- "onUpdate:modelValue": b[4] || (b[4] = (p) => oe(m) ? m.value = p : null),
1287
- localized: ""
1288
- }, null, 8, ["modelValue"])
1289
- ]),
1290
- _: 1
1291
- }, 8, ["label"]),
1292
- t(e(X), {
1293
- label: e(u)("panel.thank-you-text")
1294
- }, {
1295
- default: a(() => [
1296
- t(hl, {
1297
- modelValue: e(T),
1298
- "onUpdate:modelValue": b[5] || (b[5] = (p) => oe(T) ? T.value = p : null)
1299
- }, null, 8, ["modelValue"])
1300
- ]),
1301
- _: 1
1302
- }, 8, ["label"]),
1303
- t(e(X), {
1304
- label: e(u)("panel.redirect"),
1305
- help: e(u)("panel.redirect-help")
1306
- }, {
1307
- default: a(() => [
1308
- t(e(le), {
1309
- modelValue: e(l),
1310
- "onUpdate:modelValue": b[6] || (b[6] = (p) => oe(l) ? l.value = p : null),
1311
- placeholder: "/thank-you"
1312
- }, null, 8, ["modelValue"])
1313
- ]),
1314
- _: 1
1315
- }, 8, ["label", "help"])
1316
- ]),
1317
- _: 1
1318
- }, 8, ["title"])
1319
- ]));
1320
- }
1321
- }), ut = /* @__PURE__ */ ue(it, [["__scopeId", "data-v-1932aefe"]]), rt = /^[^\s@]+@[^\s@]+$/;
1322
- function Be(s) {
1323
- return "admin_id" in s;
1324
- }
1325
- function yl(s, o = []) {
1326
- return Be(s) ? o.find(
1327
- (u) => u.type === "admin" && u.admin_id === s.admin_id
1328
- )?.problem ?? null : rt.test((s.email ?? "").trim()) ? null : "invalid_email";
1329
- }
1330
- function dt(s, o = []) {
1331
- return (s ?? []).some((d) => yl(d, o) === null);
1332
- }
1333
- const ct = { class: "wx-inbox-recipients" }, pt = { class: "wx-inbox-recipients__row" }, mt = /* @__PURE__ */ se({
1334
- __name: "FormNotifications",
1335
- props: /* @__PURE__ */ Fe({
1336
- fields: {},
1337
- errors: {},
1338
- reported: {}
1339
- }, {
1340
- modelValue: { required: !0 },
1341
- modelModifiers: {}
1342
- }),
1343
- emits: ["update:modelValue"],
1344
- setup(s) {
1345
- const o = s, d = Se(s, "modelValue"), u = ie(), m = ce(u), T = ae("webx-inbox"), n = W([]), l = ve(d, "recipients", []), V = ve(d, "email_field", "");
1346
- xl(async () => {
1347
- try {
1348
- n.value = await m.recipients();
1349
- } catch {
1350
- }
1351
- });
1352
- const b = C(
1353
- () => n.value.map((v) => ({ value: v.id, label: `${v.name} · ${v.email}` }))
1354
- ), p = C(() => [
1355
- { value: "", label: T("panel.no-email-field") },
1356
- ...o.fields.filter((v) => v.type === "email").map((v) => ({ value: v.key, label: v.key }))
1357
- ]);
1358
- function U(v) {
1359
- if (!Be(v)) return null;
1360
- const y = yl(v, o.reported);
1361
- return y === null ? null : T(`panel.recipient-${y}`);
1362
- }
1363
- function _(v) {
1364
- l.value = [...l.value, v];
1365
- }
1366
- async function $(v) {
1367
- const y = l.value[v];
1368
- y !== void 0 && (Be(y) || (y.email ?? "").trim() !== "") && !await Ae({
1369
- title: T("panel.remove-recipient-title"),
1370
- message: T("panel.remove-recipient-text"),
1371
- confirmText: T("panel.remove"),
1372
- cancelText: T("panel.cancel"),
1373
- tone: "danger"
1374
- }) || (l.value = l.value.filter((z, q) => q !== v));
1375
- }
1376
- function c(v, y) {
1377
- l.value = l.value.map((S, z) => z === v ? { admin_id: y } : S);
1378
- }
1379
- function N(v, y) {
1380
- l.value = l.value.map((S, z) => z === v ? { email: y } : S);
1381
- }
1382
- return (v, y) => (i(), g(e(ne), {
1383
- title: e(T)("panel.recipients")
1384
- }, {
1385
- default: a(() => [
1386
- t(e(Y), {
1387
- size: "sm",
1388
- tone: "muted"
1389
- }, {
1390
- default: a(() => [
1391
- A(x(e(T)("panel.recipients-help")), 1)
1392
- ]),
1393
- _: 1
1394
- }),
1395
- s.errors["options.recipients"] ? (i(), g(e(Ce), {
1396
- key: 0,
1397
- type: "danger",
1398
- variant: "soft",
1399
- description: s.errors["options.recipients"]?.[0]
1400
- }, null, 8, ["description"])) : M("", !0),
1401
- H("div", ct, [
1402
- e(l).length === 0 ? (i(), g(e(Y), {
1403
- key: 0,
1404
- size: "sm",
1405
- tone: "placeholder"
1406
- }, {
1407
- default: a(() => [
1408
- A(x(e(T)("panel.no-recipients")), 1)
1409
- ]),
1410
- _: 1
1411
- })) : M("", !0),
1412
- (i(!0), G(ee, null, ye(e(l), (S, z) => (i(), G("div", {
1413
- key: z,
1414
- class: "wx-inbox-recipients__item"
1415
- }, [
1416
- H("div", pt, [
1417
- e(Be)(S) ? (i(), g(e(fe), {
1418
- key: 0,
1419
- "model-value": S.admin_id,
1420
- options: b.value,
1421
- "onUpdate:modelValue": (q) => c(z, Number(q))
1422
- }, null, 8, ["model-value", "options", "onUpdate:modelValue"])) : (i(), g(e(le), {
1423
- key: 1,
1424
- "model-value": S.email,
1425
- type: "email",
1426
- placeholder: "sales@example.com",
1427
- "onUpdate:modelValue": (q) => N(z, String(q))
1428
- }, null, 8, ["model-value", "onUpdate:modelValue"])),
1429
- t(e(xe), {
1430
- icon: "trash",
1431
- tone: "danger",
1432
- title: e(T)("panel.remove"),
1433
- onClick: (q) => $(z)
1434
- }, null, 8, ["title", "onClick"])
1435
- ]),
1436
- U(S) ? (i(), g(e(Y), {
1437
- key: 0,
1438
- size: "sm",
1439
- tone: "danger"
1440
- }, {
1441
- default: a(() => [
1442
- A(x(U(S)), 1)
1443
- ]),
1444
- _: 2
1445
- }, 1024)) : M("", !0)
1446
- ]))), 128))
1447
- ]),
1448
- t(e(Ie), { size: "sm" }, {
1449
- default: a(() => [
1450
- t(e(te), {
1451
- variant: "outline",
1452
- icon: "user",
1453
- disabled: b.value.length === 0,
1454
- onClick: y[0] || (y[0] = (S) => _({ admin_id: Number(b.value[0]?.value) }))
1455
- }, {
1456
- default: a(() => [
1457
- A(x(e(T)("panel.add-admin")), 1)
1458
- ]),
1459
- _: 1
1460
- }, 8, ["disabled"]),
1461
- t(e(te), {
1462
- variant: "outline",
1463
- onClick: y[1] || (y[1] = (S) => _({ email: "" }))
1464
- }, {
1465
- icon: a(() => [
1466
- t(e(_e), { name: "mail" })
1467
- ]),
1468
- default: a(() => [
1469
- A(" " + x(e(T)("panel.add-email")), 1)
1470
- ]),
1471
- _: 1
1472
- })
1473
- ]),
1474
- _: 1
1475
- }),
1476
- t(e(X), {
1477
- label: e(T)("panel.email-field"),
1478
- help: e(T)("panel.email-field-help"),
1479
- error: s.errors["options.email_field"]?.[0]
1480
- }, {
1481
- default: a(() => [
1482
- t(e(fe), {
1483
- modelValue: e(V),
1484
- "onUpdate:modelValue": y[2] || (y[2] = (S) => oe(V) ? V.value = S : null),
1485
- options: p.value
1486
- }, null, 8, ["modelValue", "options"])
1487
- ]),
1488
- _: 1
1489
- }, 8, ["label", "help", "error"])
1490
- ]),
1491
- _: 1
1492
- }, 8, ["title"]));
1493
- }
1494
- }), vt = /* @__PURE__ */ ue(mt, [["__scopeId", "data-v-caf2e49f"]]), ft = { class: "wx-inbox-editor" }, bt = /* @__PURE__ */ se({
1495
- __name: "FormEditorPage",
1496
- props: {
1497
- base: { default: "/inbox" }
1498
- },
1499
- setup(s) {
1500
- const o = s, d = ie(), u = ce(d), m = Re(), T = He(), n = ke();
1501
- pe();
1502
- const l = ae("webx-inbox"), V = be(), b = W(null), p = W([]), U = W(!0), _ = W(!1), $ = W({});
1503
- let c = _l({
1504
- slug: "",
1505
- title: {},
1506
- is_enabled: !0
1507
- });
1508
- const N = W({}), y = W(["general", "fields", "notifications", "antispam", "embed"].includes(String(m.query.tab)) ? String(m.query.tab) : "general"), S = C(
1509
- () => c.is_enabled && !dt(N.value.recipients, b.value?.recipients)
1510
- ), z = C(() => d.can("inbox.manage")), q = C(() => Number(m.params.id)), D = C(
1511
- () => b.value === null ? "" : we(c.title, n.active.value, c.slug)
1512
- ), j = C(() => `${o.base}?form=${q.value}`);
1513
- async function L() {
1514
- U.value = !0;
1515
- try {
1516
- const r = await u.form(q.value);
1517
- b.value = r, p.value = r.fields ?? [], c.slug = r.slug, c.title = { ...r.title }, c.is_enabled = r.is_enabled, N.value = { ...r.options };
1518
- } catch (r) {
1519
- O.danger(V(r)), T.replace(o.base);
1520
- } finally {
1521
- U.value = !1;
1522
- }
1523
- }
1524
- Ue(q, () => {
1525
- L();
1526
- }, { immediate: !0 });
1527
- async function R() {
1528
- _.value = !0, $.value = {};
1529
- try {
1530
- const r = await u.saveForm(q.value, {
1531
- slug: c.slug.trim(),
1532
- title: c.title,
1533
- is_enabled: c.is_enabled,
1534
- options: N.value
1535
- });
1536
- b.value = r, O.success(l("panel.saved"));
1537
- } catch (r) {
1538
- const B = r.body;
1539
- B?.errors ? ($.value = B.errors, O.danger(l("panel.failed"))) : O.danger(V(r));
1540
- } finally {
1541
- _.value = !1;
1542
- }
1543
- }
1544
- return (r, B) => (i(), G("div", ft, [
1545
- U.value ? (i(), g(e(ne), { key: 0 }, {
1546
- default: a(() => [
1547
- t(e(Ne), {
1548
- title: "",
1549
- rows: 8
1550
- })
1551
- ]),
1552
- _: 1
1553
- })) : b.value ? (i(), G(ee, { key: 1 }, [
1554
- t(e(al), {
1555
- class: "wx-inbox-editor__head",
1556
- title: D.value,
1557
- subtitle: b.value.slug,
1558
- back: j.value,
1559
- "back-label": e(l)("panel.forms")
1560
- }, {
1561
- "title-after": a(() => [
1562
- e(c).is_enabled ? M("", !0) : (i(), g(e($e), {
1563
- key: 0,
1564
- type: "default"
1565
- }, {
1566
- default: a(() => [
1567
- A(x(e(l)("panel.off")), 1)
1568
- ]),
1569
- _: 1
1570
- }))
1571
- ]),
1572
- _: 1
1573
- }, 8, ["title", "subtitle", "back", "back-label"]),
1574
- S.value ? (i(), g(e(Ce), {
1575
- key: 0,
1576
- class: "wx-inbox-editor__silent",
1577
- type: "warning",
1578
- variant: "soft",
1579
- closable: !1,
1580
- title: e(l)("panel.notifies-nobody"),
1581
- description: e(l)("panel.notifies-nobody-text")
1582
- }, null, 8, ["title", "description"])) : M("", !0),
1583
- t(e(sl), {
1584
- modelValue: y.value,
1585
- "onUpdate:modelValue": B[5] || (B[5] = (Q) => y.value = Q),
1586
- class: "wx-inbox-editor__tabs",
1587
- "keep-alive": ""
1588
- }, {
1589
- default: a(() => [
1590
- t(e(ge), {
1591
- value: "general",
1592
- label: e(l)("panel.tab-general")
1593
- }, {
1594
- default: a(() => [
1595
- t(ut, {
1596
- settings: e(c),
1597
- "onUpdate:settings": B[0] || (B[0] = (Q) => oe(c) ? c.value = Q : c = Q),
1598
- options: N.value,
1599
- "onUpdate:options": B[1] || (B[1] = (Q) => N.value = Q),
1600
- errors: $.value
1601
- }, null, 8, ["settings", "options", "errors"])
1602
- ]),
1603
- _: 1
1604
- }, 8, ["label"]),
1605
- t(e(ge), {
1606
- value: "fields",
1607
- label: e(l)("panel.tab-fields")
1608
- }, {
1609
- default: a(() => [
1610
- t(Ql, {
1611
- modelValue: p.value,
1612
- "onUpdate:modelValue": B[2] || (B[2] = (Q) => p.value = Q),
1613
- form: b.value,
1614
- "can-manage": z.value
1615
- }, null, 8, ["modelValue", "form", "can-manage"])
1616
- ]),
1617
- _: 1
1618
- }, 8, ["label"]),
1619
- t(e(ge), {
1620
- value: "notifications",
1621
- label: e(l)("panel.tab-notifications")
1622
- }, {
1623
- default: a(() => [
1624
- t(vt, {
1625
- modelValue: N.value,
1626
- "onUpdate:modelValue": B[3] || (B[3] = (Q) => N.value = Q),
1627
- fields: p.value,
1628
- errors: $.value,
1629
- reported: b.value.recipients
1630
- }, null, 8, ["modelValue", "fields", "errors", "reported"])
1631
- ]),
1632
- _: 1
1633
- }, 8, ["label"]),
1634
- t(e(ge), {
1635
- value: "antispam",
1636
- label: e(l)("panel.tab-antispam")
1637
- }, {
1638
- default: a(() => [
1639
- t(Jl, {
1640
- modelValue: N.value,
1641
- "onUpdate:modelValue": B[4] || (B[4] = (Q) => N.value = Q),
1642
- site: b.value.captcha
1643
- }, null, 8, ["modelValue", "site"])
1644
- ]),
1645
- _: 1
1646
- }, 8, ["label"]),
1647
- t(e(ge), {
1648
- value: "embed",
1649
- label: e(l)("panel.tab-embed")
1650
- }, {
1651
- default: a(() => [
1652
- t(st, {
1653
- form: b.value,
1654
- slug: e(c).slug,
1655
- fields: p.value
1656
- }, null, 8, ["form", "slug", "fields"])
1657
- ]),
1658
- _: 1
1659
- }, 8, ["label"])
1660
- ]),
1661
- _: 1
1662
- }, 8, ["modelValue"]),
1663
- z.value ? (i(), g(e(Cl), { key: 1 }, {
1664
- default: a(() => [
1665
- t(e(te), {
1666
- type: "primary",
1667
- loading: _.value,
1668
- onClick: R
1669
- }, {
1670
- default: a(() => [
1671
- A(x(e(l)("panel.save")), 1)
1672
- ]),
1673
- _: 1
1674
- }, 8, ["loading"])
1675
- ]),
1676
- _: 1
1677
- })) : M("", !0)
1678
- ], 64)) : M("", !0)
1679
- ]));
1680
- }
1681
- }), ht = /* @__PURE__ */ ue(bt, [["__scopeId", "data-v-f7f9e6f4"]]), yt = { class: "wx-inbox-create" }, gt = /* @__PURE__ */ se({
1682
- __name: "FormCreateDialog",
1683
- setup(s) {
1684
- const { resolve: o, dismiss: d, open: u } = Xe(), m = ie(), T = ce(m);
1685
- pe();
1686
- const n = ae("webx-inbox"), l = be(), V = W({}), b = W(""), p = W(!1), U = W({});
1687
- function _(c) {
1688
- return U.value[c]?.[0];
1689
- }
1690
- async function $() {
1691
- p.value = !0, U.value = {};
1692
- try {
1693
- o(
1694
- await T.createForm({
1695
- title: V.value,
1696
- slug: b.value.trim(),
1697
- is_enabled: !0,
1698
- options: {}
1699
- })
1700
- );
1701
- } catch (c) {
1702
- const N = c.body;
1703
- N?.errors ? (U.value = N.errors, O.danger(n("panel.failed"))) : O.danger(l(c));
1704
- } finally {
1705
- p.value = !1;
1706
- }
1707
- }
1708
- return (c, N) => (i(), g(e(Ge), {
1709
- open: e(u),
1710
- "onUpdate:open": N[3] || (N[3] = (v) => oe(u) ? u.value = v : null),
1711
- title: e(n)("panel.new-form-title"),
1712
- width: 520
1713
- }, {
1714
- footer: a(() => [
1715
- t(e(Ie), { size: "sm" }, {
1716
- default: a(() => [
1717
- t(e(te), {
1718
- variant: "outline",
1719
- onClick: N[2] || (N[2] = (v) => e(d)())
1720
- }, {
1721
- default: a(() => [
1722
- A(x(e(n)("panel.cancel")), 1)
1723
- ]),
1724
- _: 1
1725
- }),
1726
- t(e(te), {
1727
- type: "primary",
1728
- loading: p.value,
1729
- onClick: $
1730
- }, {
1731
- default: a(() => [
1732
- A(x(e(n)("panel.save")), 1)
1733
- ]),
1734
- _: 1
1735
- }, 8, ["loading"])
1736
- ]),
1737
- _: 1
1738
- })
1739
- ]),
1740
- default: a(() => [
1741
- H("div", yt, [
1742
- t(e(X), {
1743
- label: e(n)("panel.title"),
1744
- error: _("title"),
1745
- required: ""
1746
- }, {
1747
- default: a(() => [
1748
- t(e(le), {
1749
- modelValue: V.value,
1750
- "onUpdate:modelValue": N[0] || (N[0] = (v) => V.value = v),
1751
- localized: "",
1752
- autofocus: ""
1753
- }, null, 8, ["modelValue"])
1754
- ]),
1755
- _: 1
1756
- }, 8, ["label", "error"]),
1757
- t(e(X), {
1758
- label: e(n)("panel.slug"),
1759
- help: e(n)("panel.slug-help"),
1760
- error: _("slug")
1761
- }, {
1762
- default: a(() => [
1763
- t(e(le), {
1764
- modelValue: b.value,
1765
- "onUpdate:modelValue": N[1] || (N[1] = (v) => b.value = v),
1766
- placeholder: "contact"
1767
- }, null, 8, ["modelValue"])
1768
- ]),
1769
- _: 1
1770
- }, 8, ["label", "help", "error"])
1771
- ])
1772
- ]),
1773
- _: 1
1774
- }, 8, ["open", "title"]));
1775
- }
1776
- }), xt = /* @__PURE__ */ ue(gt, [["__scopeId", "data-v-55fb40d8"]]), _t = { class: "wx-inbox-by-hand" }, wt = /* @__PURE__ */ se({
1777
- __name: "SubmissionCreateDialog",
1778
- props: {
1779
- form: {}
1780
- },
1781
- setup(s) {
1782
- const o = s, { resolve: d, dismiss: u, open: m } = Xe(), T = ie(), n = ce(T), l = ke();
1783
- pe();
1784
- const V = ae("webx-inbox"), b = be(), p = W([]), U = W(!0), _ = W(!1), $ = W({}), c = W({}), N = C(() => p.value.filter((L) => L.type !== "file")), v = C(() => p.value.some((L) => L.type === "file"));
1785
- function y(L) {
1786
- return c.value[`fields.${L.key}`]?.[0];
1787
- }
1788
- function S(L) {
1789
- return we(L.title, l.active.value, L.key);
1790
- }
1791
- function z(L, R = "") {
1792
- return we(
1793
- L,
1794
- l.active.value,
1795
- R
1796
- );
1797
- }
1798
- function q(L) {
1799
- return (L.options.choices ?? []).map((R) => ({
1800
- value: R.value,
1801
- label: z(R.label, R.value)
1802
- }));
1803
- }
1804
- async function D() {
1805
- try {
1806
- const L = await n.form(o.form.id);
1807
- p.value = (L.fields ?? []).filter((R) => R.is_enabled);
1808
- for (const R of p.value)
1809
- $.value[R.key] = R.type === "checkbox" ? [] : R.type === "consent" ? !1 : "";
1810
- } catch (L) {
1811
- O.danger(b(L));
1812
- } finally {
1813
- U.value = !1;
1814
- }
1815
- }
1816
- D();
1817
- async function j() {
1818
- _.value = !0, c.value = {};
1819
- try {
1820
- d(await n.createSubmission(o.form.id, $.value));
1821
- } catch (L) {
1822
- const R = L.body;
1823
- R?.errors ? (c.value = R.errors, O.danger(V("panel.failed"))) : O.danger(b(L));
1824
- } finally {
1825
- _.value = !1;
1826
- }
1827
- }
1828
- return (L, R) => (i(), g(e(Ge), {
1829
- open: e(m),
1830
- "onUpdate:open": R[1] || (R[1] = (r) => oe(m) ? m.value = r : null),
1831
- title: e(V)("panel.new-submission-title"),
1832
- width: 560
1833
- }, {
1834
- footer: a(() => [
1835
- t(e(Ie), { size: "sm" }, {
1836
- default: a(() => [
1837
- t(e(te), {
1838
- variant: "outline",
1839
- onClick: R[0] || (R[0] = (r) => e(u)())
1840
- }, {
1841
- default: a(() => [
1842
- A(x(e(V)("panel.cancel")), 1)
1843
- ]),
1844
- _: 1
1845
- }),
1846
- t(e(te), {
1847
- type: "primary",
1848
- loading: _.value,
1849
- disabled: U.value,
1850
- onClick: j
1851
- }, {
1852
- default: a(() => [
1853
- A(x(e(V)("panel.save")), 1)
1854
- ]),
1855
- _: 1
1856
- }, 8, ["loading", "disabled"])
1857
- ]),
1858
- _: 1
1859
- })
1860
- ]),
1861
- default: a(() => [
1862
- H("div", _t, [
1863
- t(e(Ce), {
1864
- type: "info",
1865
- closable: !1
1866
- }, {
1867
- default: a(() => [
1868
- A(x(e(V)("panel.new-submission-help")), 1)
1869
- ]),
1870
- _: 1
1871
- }),
1872
- U.value ? (i(), g(e(Ne), {
1873
- key: 0,
1874
- rows: 4
1875
- })) : (i(), G(ee, { key: 1 }, [
1876
- (i(!0), G(ee, null, ye(N.value, (r) => (i(), g(e(X), {
1877
- key: r.id,
1878
- label: S(r),
1879
- help: z(r.help),
1880
- error: y(r),
1881
- required: r.is_required
1882
- }, {
1883
- default: a(() => [
1884
- r.type === "textarea" ? (i(), g(e(Ul), {
1885
- key: 0,
1886
- modelValue: $.value[r.key],
1887
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1888
- rows: r.options.rows ?? 4,
1889
- placeholder: z(r.placeholder)
1890
- }, null, 8, ["modelValue", "onUpdate:modelValue", "rows", "placeholder"])) : r.type === "select" ? (i(), g(e(fe), {
1891
- key: 1,
1892
- modelValue: $.value[r.key],
1893
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1894
- options: q(r),
1895
- clearable: "",
1896
- placeholder: z(r.placeholder)
1897
- }, null, 8, ["modelValue", "onUpdate:modelValue", "options", "placeholder"])) : r.type === "radio" ? (i(), g(e(Al), {
1898
- key: 2,
1899
- modelValue: $.value[r.key],
1900
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1901
- options: q(r)
1902
- }, null, 8, ["modelValue", "onUpdate:modelValue", "options"])) : r.type === "checkbox" ? (i(), g(e(zl), {
1903
- key: 3,
1904
- modelValue: $.value[r.key],
1905
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1906
- options: q(r)
1907
- }, null, 8, ["modelValue", "onUpdate:modelValue", "options"])) : r.type === "consent" ? (i(), g(e(he), {
1908
- key: 4,
1909
- modelValue: $.value[r.key],
1910
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1911
- label: z(r.options.text, S(r))
1912
- }, null, 8, ["modelValue", "onUpdate:modelValue", "label"])) : r.type === "date" ? (i(), g(e(tl), {
1913
- key: 5,
1914
- modelValue: $.value[r.key],
1915
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1916
- placeholder: z(r.placeholder)
1917
- }, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])) : (i(), g(e(le), {
1918
- key: 6,
1919
- modelValue: $.value[r.key],
1920
- "onUpdate:modelValue": (B) => $.value[r.key] = B,
1921
- type: r.type === "email" ? "email" : r.type === "tel" ? "tel" : "text",
1922
- placeholder: z(r.placeholder),
1923
- maxlength: r.options.maxlength
1924
- }, null, 8, ["modelValue", "onUpdate:modelValue", "type", "placeholder", "maxlength"]))
1925
- ]),
1926
- _: 2
1927
- }, 1032, ["label", "help", "error", "required"]))), 128)),
1928
- v.value ? (i(), g(e(Ce), {
1929
- key: 0,
1930
- type: "warning",
1931
- closable: !1
1932
- }, {
1933
- default: a(() => [
1934
- A(x(e(V)("panel.no-files-by-hand")), 1)
1935
- ]),
1936
- _: 1
1937
- })) : M("", !0)
1938
- ], 64))
1939
- ])
1940
- ]),
1941
- _: 1
1942
- }, 8, ["open", "title"]));
1943
- }
1944
- }), kt = /* @__PURE__ */ ue(wt, [["__scopeId", "data-v-72006299"]]), Vt = { class: "wx-submissions__mass" }, $t = { class: "wx-submissions__state" }, Tt = 640, St = /* @__PURE__ */ se({
1945
- __name: "SubmissionList",
1946
- props: {
1947
- form: {},
1948
- base: { default: "/inbox" }
1949
- },
1950
- emits: ["changed"],
1951
- setup(s, { expose: o, emit: d }) {
1952
- const u = s, m = d, T = ie(), n = ce(T), l = Re(), V = He(), b = ke();
1953
- pe();
1954
- const p = ml("root"), U = ql(p), _ = C(() => U.value > 0 && U.value < Tt), $ = C(() => _.value ? Number.POSITIVE_INFINITY : 0), c = ae("webx-inbox"), N = ae("webx-admin"), v = be(), y = W(null), S = W([]), z = W(!1), q = W([]), D = W(!1), j = C(() => T.can("inbox.update")), L = je(kt), R = C({
1955
- get: () => typeof l.query.view == "string" && l.query.view !== "" ? l.query.view : "all",
1956
- set: (k) => {
1957
- V.replace({
1958
- query: { ...l.query, view: k === "all" ? void 0 : k, page: void 0 }
1959
- });
1960
- }
1961
- }), r = C(() => ({
1962
- view: R.value,
1963
- search: typeof l.query.search == "string" ? l.query.search : "",
1964
- assignee: typeof l.query.assignee == "string" ? l.query.assignee : null,
1965
- placement: typeof l.query.placement == "string" ? l.query.placement : null,
1966
- sort: typeof l.query.sort == "string" ? l.query.sort : null,
1967
- page: Number(l.query.page ?? 1) || 1
1968
- })), B = C(
1969
- () => (y.value?.placements ?? []).map(
1970
- (k) => k === null ? { value: "none", label: c("panel.placement-none") } : { value: k, label: k }
1971
- )
1972
- ), Q = C(
1973
- () => B.value.length > 1 || r.value.placement !== null
1974
- ), me = C(() => {
1975
- const k = r.value.placement;
1976
- if (k === null) return [];
1977
- const K = B.value.find((E) => E.value === k)?.label ?? (k === "none" ? c("panel.placement-none") : k);
1978
- return [
1979
- {
1980
- key: "placement",
1981
- label: `${c("panel.meta-placement")}: ${K}`,
1982
- clear: () => F(void 0)
1983
- }
1984
- ];
1985
- });
1986
- function F(k) {
1987
- V.replace({
1988
- query: {
1989
- ...l.query,
1990
- placement: typeof k == "string" && k !== "" ? k : void 0,
1991
- page: void 0
1992
- }
1993
- });
1994
- }
1995
- const J = C(() => {
1996
- const k = y.value?.counts, K = [
1997
- { value: "all", label: c("panel.view-all"), badge: k?.all || void 0 },
1998
- { value: "unread", label: c("panel.view-unread"), badge: k?.unread || void 0 }
1999
- ];
2000
- for (const E of S.value)
2001
- K.push({
2002
- value: E.key,
2003
- label: de(E),
2004
- badge: k?.statuses[E.key] || void 0
2005
- });
2006
- return K;
2007
- });
2008
- function I(k, K) {
2009
- const E = y.value?.columns?.[K];
2010
- return E ? k.values[E.key] ?? "" : "";
2011
- }
2012
- const w = C(() => {
2013
- const k = y.value?.columns ?? [];
2014
- return _.value ? [{ key: "card", label: "" }] : [
2015
- ...k.map((K, E) => ({
2016
- key: `values.${K.key}`,
2017
- label: K.label,
2018
- sortable: !0,
2019
- // The first answer is what the row is recognised by and stays at any width; every one
2020
- // after it is worth less than the room it takes, so it goes a step sooner. The steps are
2021
- // wide — 640, 960 — because an answer is a sentence and not a number: two of them plus
2022
- // the status and the date is already what a 755px pane holds without scrolling sideways,
2023
- // which is what the pane beside the forms actually is on a 1280 screen (§11).
2024
- hideBelow: E === 0 ? void 0 : 320 + E * 320
2025
- })),
2026
- // A floor rather than a width: the cell holds a badge, sometimes an avatar and sometimes
2027
- // a paperclip, and a fixed width that any of them overflows makes the whole table scroll
2028
- // sideways by two pixels.
2029
- { key: "status", label: c("panel.status"), minWidth: 100 },
2030
- {
2031
- key: "created_at",
2032
- label: c("panel.received"),
2033
- sortable: !0,
2034
- width: 120,
2035
- // "today at 16:22" is three words the table will break over two lines given half a
2036
- // chance, and a date read down a column has to be one line to be read at all.
2037
- cellClass: "wx-submissions__when",
2038
- hideBelow: 520
2039
- // Kept on the card, unlike most dates: "when did this come in" is one of the two
2040
- // questions a submission is looked at for, and the other one is who sent it.
2041
- },
2042
- { key: "actions", label: "", width: kl, align: "right", hideOnCards: !0 }
2043
- ];
2044
- }), h = C(
2045
- () => r.value.view === "all" && r.value.search === "" && r.value.assignee === null && r.value.placement === null ? c("panel.submissions-empty") : c("panel.submissions-none")
2046
- ), re = C(
2047
- () => S.value.map((k) => ({ value: k.id, label: de(k) }))
2048
- ), de = ol();
2049
- function Ee() {
2050
- return we(u.form.title, b.active.value, u.form.slug);
2051
- }
2052
- async function Te(k) {
2053
- z.value = !0;
2054
- try {
2055
- y.value = await n.submissions(u.form.id, {
2056
- view: r.value.view,
2057
- search: k?.search ?? r.value.search,
2058
- assignee: r.value.assignee,
2059
- placement: r.value.placement,
2060
- sort: k?.sort ? `${k.sort.order === "desc" ? "-" : ""}${k.sort.key}` : null,
2061
- page: k?.page ?? r.value.page,
2062
- per_page: k?.perPage
2063
- });
2064
- } catch (K) {
2065
- O.danger(v(K));
2066
- } finally {
2067
- z.value = !1;
2068
- }
2069
- }
2070
- function Ke(k) {
2071
- const K = {
2072
- ...l.query,
2073
- search: k.search === "" ? void 0 : k.search,
2074
- sort: k.sort === null ? void 0 : `${k.sort.order === "desc" ? "-" : ""}${k.sort.key}`,
2075
- page: k.page === 1 ? void 0 : String(k.page)
2076
- };
2077
- V.replace({ query: K }), Te(k);
2078
- }
2079
- Ue([() => u.form.id, R, () => r.value.assignee, () => r.value.placement], () => {
2080
- q.value = [], Te();
2081
- }), Ze();
2082
- async function Ze() {
2083
- try {
2084
- S.value = await n.statuses();
2085
- } catch (k) {
2086
- O.danger(v(k));
2087
- }
2088
- }
2089
- function Qe(k) {
2090
- V.push({ path: `${u.base}/submissions/${k.id}`, query: { ...l.query } });
2091
- }
2092
- function ze(k) {
2093
- return j.value ? [
2094
- {
2095
- key: "read",
2096
- icon: k.is_read ? "eye-off" : "eye",
2097
- label: k.is_read ? c("panel.mark-unread") : c("panel.mark-read"),
2098
- run: () => {
2099
- f([k.id], k.is_read ? "unread" : "read");
2100
- }
2101
- },
2102
- {
2103
- key: "delete",
2104
- icon: "trash",
2105
- label: c("panel.delete"),
2106
- danger: !0,
2107
- run: () => {
2108
- Pe([k.id]);
2109
- }
2110
- }
2111
- ] : [];
2112
- }
2113
- async function Je(k) {
2114
- typeof k == "number" && (D.value = !0, await f(
2115
- q.value.map((K) => K.id),
2116
- "status",
2117
- k
2118
- ), D.value = !1);
2119
- }
2120
- async function Pe(k) {
2121
- await Ae({
2122
- title: k.length === 1 ? c("panel.delete-submission-title") : c("panel.delete-selected-title", { count: k.length }),
2123
- message: c("panel.delete-submission-text"),
2124
- confirmText: c("panel.delete"),
2125
- cancelText: c("panel.cancel"),
2126
- tone: "danger"
2127
- }) && await f(k, "delete");
2128
- }
2129
- async function f(k, K, E) {
2130
- if (k.length !== 0)
2131
- try {
2132
- await n.massSubmissions({ ids: k, action: K, status_id: E }), q.value = [], await Te(), m("changed");
2133
- } catch (qe) {
2134
- O.danger(v(qe));
2135
- }
2136
- }
2137
- async function Z() {
2138
- const k = await L({ form: u.form });
2139
- k && (O.success(c("panel.created")), await Te(), m("changed"), V.push({ path: `${u.base}/submissions/${k.id}`, query: { ...l.query } }));
2140
- }
2141
- const P = C(
2142
- () => n.exportUrl(u.form.id, {
2143
- view: r.value.view,
2144
- search: r.value.search,
2145
- assignee: r.value.assignee,
2146
- placement: r.value.placement,
2147
- sort: r.value.sort
2148
- })
2149
- ), el = C(() => [
2150
- { key: "export", label: c("panel.export"), icon: "download", href: P.value }
2151
- ]);
2152
- return o({ create: Z }), (k, K) => (i(), G("div", {
2153
- ref_key: "root",
2154
- ref: p,
2155
- class: "wx-submissions"
2156
- }, [
2157
- t(e(al), {
2158
- class: "wx-submissions__head",
2159
- level: 3,
2160
- title: Ee(),
2161
- subtitle: s.form.slug,
2162
- actions: el.value
2163
- }, null, 8, ["title", "subtitle", "actions"]),
2164
- t(e(sl), {
2165
- modelValue: R.value,
2166
- "onUpdate:modelValue": K[2] || (K[2] = (E) => R.value = E),
2167
- class: "wx-submissions__views",
2168
- items: J.value,
2169
- "collapse-below": 560,
2170
- "aria-label": e(c)("panel.status")
2171
- }, {
2172
- default: a(() => [
2173
- t(e(bl), {
2174
- data: y.value,
2175
- columns: w.value,
2176
- "row-key": "id",
2177
- searchable: "",
2178
- clickable: "",
2179
- hover: "",
2180
- flush: "",
2181
- loading: z.value,
2182
- "loading-text": e(c)("panel.loading"),
2183
- selectable: j.value,
2184
- "select-row-label": e(N)("filters.select-row"),
2185
- "select-all-label": e(N)("filters.select-all"),
2186
- "row-class": (E) => E.is_read ? void 0 : "is-unread",
2187
- "search-placeholder": e(c)("panel.search-submissions"),
2188
- "empty-text": h.value,
2189
- "cards-below": $.value,
2190
- "filters-count": me.value.length,
2191
- onRowClick: Qe,
2192
- onStateChange: Ke,
2193
- onSelectionChange: K[1] || (K[1] = (E, qe) => q.value = qe)
2194
- }, De({
2195
- "cell-status": a(({ row: E }) => [
2196
- H("div", $t, [
2197
- E.status ? (i(), g(e($e), {
2198
- key: 0,
2199
- type: E.status.color
2200
- }, {
2201
- default: a(() => [
2202
- A(x(e(de)(E.status)), 1)
2203
- ]),
2204
- _: 2
2205
- }, 1032, ["type"])) : M("", !0),
2206
- E.assignee ? (i(), g(e(rl), {
2207
- key: 1,
2208
- name: E.assignee.name,
2209
- title: E.assignee.name,
2210
- size: "xs",
2211
- tone: "auto"
2212
- }, null, 8, ["name", "title"])) : M("", !0),
2213
- E.files_count > 0 ? (i(), g(e(Nl), {
2214
- key: 2,
2215
- content: e(c)("panel.attachments")
2216
- }, {
2217
- default: a(() => [
2218
- t(e(_e), {
2219
- name: "file",
2220
- size: "sm"
2221
- })
2222
- ]),
2223
- _: 1
2224
- }, 8, ["content"])) : M("", !0)
2225
- ])
2226
- ]),
2227
- "cell-created_at": a(({ row: E }) => [
2228
- t(e(Le), {
2229
- value: E.created_at,
2230
- compact: ""
2231
- }, null, 8, ["value"])
2232
- ]),
2233
- "cell-card": a(({ row: E }) => [
2234
- t(e(Wl), {
2235
- variant: "plain",
2236
- shape: "circle",
2237
- title: I(E, 0)
2238
- }, {
2239
- subtitle: a(() => [
2240
- A(x(I(E, 1)), 1)
2241
- ]),
2242
- meta: a(() => [
2243
- E.status ? (i(), g(e($e), {
2244
- key: 0,
2245
- type: E.status.color,
2246
- size: "sm"
2247
- }, {
2248
- default: a(() => [
2249
- A(x(e(de)(E.status)), 1)
2250
- ]),
2251
- _: 2
2252
- }, 1032, ["type"])) : M("", !0),
2253
- E.assignee ? (i(), g(e(rl), {
2254
- key: 1,
2255
- name: E.assignee.name,
2256
- title: E.assignee.name,
2257
- size: "xs",
2258
- tone: "auto"
2259
- }, null, 8, ["name", "title"])) : M("", !0),
2260
- E.files_count > 0 ? (i(), g(e(_e), {
2261
- key: 2,
2262
- name: "file",
2263
- size: "sm"
2264
- })) : M("", !0),
2265
- t(e(Le), {
2266
- value: E.created_at
2267
- }, null, 8, ["value"])
2268
- ]),
2269
- _: 2
2270
- }, 1032, ["title"])
2271
- ]),
2272
- "card-actions": a(({ row: E }) => [
2273
- t(e(We), {
2274
- actions: ze(E),
2275
- label: String(E.id)
2276
- }, null, 8, ["actions", "label"])
2277
- ]),
2278
- "cell-actions": a(({ row: E }) => [
2279
- t(e(We), {
2280
- actions: ze(E),
2281
- label: String(E.id)
2282
- }, null, 8, ["actions", "label"])
2283
- ]),
2284
- _: 2
2285
- }, [
2286
- q.value.length > 0 ? {
2287
- name: "actions",
2288
- fn: a(() => [
2289
- H("div", Vt, [
2290
- t(e(Y), {
2291
- size: "sm",
2292
- weight: "medium"
2293
- }, {
2294
- default: a(() => [
2295
- A(x(e(c)("panel.selected", { count: q.value.length })), 1)
2296
- ]),
2297
- _: 1
2298
- }),
2299
- t(e(fe), {
2300
- "model-value": null,
2301
- options: re.value,
2302
- placeholder: e(c)("panel.move-to"),
2303
- disabled: D.value,
2304
- size: "sm",
2305
- style: { width: "180px" },
2306
- "onUpdate:modelValue": Je
2307
- }, null, 8, ["options", "placeholder", "disabled"]),
2308
- t(e(te), {
2309
- size: "sm",
2310
- variant: "outline",
2311
- type: "danger",
2312
- icon: "trash",
2313
- onClick: K[0] || (K[0] = (E) => Pe(q.value.map((qe) => qe.id)))
2314
- }, {
2315
- default: a(() => [
2316
- A(x(e(c)("panel.delete")), 1)
2317
- ]),
2318
- _: 1
2319
- })
2320
- ])
2321
- ]),
2322
- key: "0"
2323
- } : void 0,
2324
- Q.value ? {
2325
- name: "filters",
2326
- fn: a(() => [
2327
- t(e(X), {
2328
- label: e(c)("panel.meta-placement")
2329
- }, {
2330
- default: a(() => [
2331
- t(e(fe), {
2332
- "model-value": r.value.placement,
2333
- options: B.value,
2334
- placeholder: e(c)("panel.any-placement"),
2335
- clearable: "",
2336
- size: "sm",
2337
- "onUpdate:modelValue": F
2338
- }, null, 8, ["model-value", "options", "placeholder"])
2339
- ]),
2340
- _: 1
2341
- }, 8, ["label"])
2342
- ]),
2343
- key: "1"
2344
- } : void 0,
2345
- me.value.length > 0 ? {
2346
- name: "applied",
2347
- fn: a(() => [
2348
- t(e(Vl), { filters: me.value }, null, 8, ["filters"])
2349
- ]),
2350
- key: "2"
2351
- } : void 0
2352
- ]), 1032, ["data", "columns", "loading", "loading-text", "selectable", "select-row-label", "select-all-label", "row-class", "search-placeholder", "empty-text", "cards-below", "filters-count"])
2353
- ]),
2354
- _: 1
2355
- }, 8, ["modelValue", "items", "aria-label"])
2356
- ], 512));
2357
- }
2358
- }), Ct = /* @__PURE__ */ ue(St, [["__scopeId", "data-v-b23e9ac8"]]), Ut = ["onClick"], At = { class: "wx-inbox-form__name" }, zt = /* @__PURE__ */ se({
2359
- __name: "InboxPage",
2360
- props: {
2361
- base: { default: "/inbox" }
2362
- },
2363
- setup(s) {
2364
- const o = s, d = ie(), u = ce(d), m = Re(), T = He(), n = ke();
2365
- pe();
2366
- const l = ae("webx-inbox"), V = be(), b = W([]), p = W(!0), U = ml("pane"), _ = W(!0), $ = W(!1), c = C(() => d.can("inbox.manage")), N = je(xt), v = C(
2367
- () => d.state.manifest?.modules.find((F) => F.id === "inbox")?.title ?? l("module.title")
2368
- ), y = C(() => {
2369
- const F = m.query.form;
2370
- return typeof F == "string" && F !== "" ? Number(F) : null;
2371
- }), S = C(() => b.value.find((F) => F.id === y.value) ?? null);
2372
- function z(F) {
2373
- return we(F.title, n.active.value, F.slug);
2374
- }
2375
- async function q() {
2376
- p.value = !0;
2377
- try {
2378
- b.value = await u.forms();
2379
- } catch (F) {
2380
- O.danger(V(F));
2381
- } finally {
2382
- p.value = !1;
2383
- }
2384
- }
2385
- q(), Ue([b, S], () => {
2386
- b.value.length === 0 || S.value !== null || T.replace({ query: { ...m.query, form: String(b.value[0].id) } });
2387
- });
2388
- function D(F, J) {
2389
- T.replace({ query: { ...m.query, form: String(F.id) } }), J();
2390
- }
2391
- function j(F) {
2392
- T.push(`${o.base}/forms/${F.id}`);
2393
- }
2394
- function L(F) {
2395
- return c.value ? [
2396
- { key: "settings", icon: "settings", label: l("panel.settings"), run: () => j(F) },
2397
- { key: "duplicate", icon: "copy", label: l("panel.duplicate"), run: () => r(F) },
2398
- // A form that has taken submissions is switched off, never deleted (§2.4). The line is
2399
- // left out rather than greyed: a menu is a list of what is possible.
2400
- ...F.submissions_count === 0 ? [
2401
- {
2402
- key: "delete",
2403
- icon: "trash",
2404
- label: l("panel.delete"),
2405
- danger: !0,
2406
- run: () => B(F)
2407
- }
2408
- ] : []
2409
- ] : [];
2410
- }
2411
- async function R() {
2412
- const F = await N({});
2413
- F && (await q(), j(F));
2414
- }
2415
- async function r(F) {
2416
- try {
2417
- const J = await u.duplicateForm(F.id);
2418
- O.success(l("panel.duplicated")), await q(), j(J);
2419
- } catch (J) {
2420
- O.danger(V(J));
2421
- }
2422
- }
2423
- async function B(F) {
2424
- if (await Ae({
2425
- title: l("panel.delete-form-title", { form: z(F) }),
2426
- message: l("panel.delete-form-text"),
2427
- confirmText: l("panel.delete"),
2428
- cancelText: l("panel.cancel"),
2429
- tone: "danger"
2430
- }))
2431
- try {
2432
- if (await u.removeForm(F.id), O.success(l("panel.deleted")), y.value === F.id) {
2433
- const I = { ...m.query };
2434
- delete I.form, T.replace({ query: I });
2435
- }
2436
- await q();
2437
- } catch (I) {
2438
- O.danger(V(I));
2439
- }
2440
- }
2441
- async function Q() {
2442
- try {
2443
- await u.sortForms(b.value.map((F) => F.id));
2444
- } catch (F) {
2445
- O.danger(V(F, l("panel.reorder-failed"))), await q();
2446
- }
2447
- }
2448
- const me = C(() => {
2449
- const F = [];
2450
- return c.value && F.push({
2451
- key: "statuses",
2452
- label: l("panel.statuses"),
2453
- icon: "tag",
2454
- run: () => {
2455
- T.push(`${o.base}/statuses`);
2456
- }
2457
- }), d.can("inbox.update") && S.value !== null && F.push({
2458
- key: "new-submission",
2459
- label: l("panel.new-submission"),
2460
- icon: "plus",
2461
- primary: !0,
2462
- run: () => {
2463
- U.value?.create();
2464
- }
2465
- }), F;
2466
- });
2467
- return (F, J) => (i(), g(e(vl), {
2468
- title: v.value,
2469
- actions: me.value,
2470
- card: !1
2471
- }, De({
2472
- default: a(() => [
2473
- t(e(ne), {
2474
- class: "wx-inbox",
2475
- padding: "none"
2476
- }, {
2477
- default: a(() => [
2478
- t(e(Fl), {
2479
- "filters-open": $.value,
2480
- "onUpdate:filtersOpen": J[2] || (J[2] = (I) => $.value = I),
2481
- class: "wx-inbox__panes",
2482
- "filters-width": 270,
2483
- "detail-min": 420,
2484
- "filters-title": e(l)("panel.forms"),
2485
- onFiltersInline: J[3] || (J[3] = (I) => _.value = I)
2486
- }, {
2487
- filters: a(({ inline: I, close: w }) => [
2488
- p.value ? (i(), g(e(Ne), {
2489
- key: 0,
2490
- class: "wx-inbox__loading",
2491
- rows: 5
2492
- })) : (i(), G(ee, { key: 1 }, [
2493
- !I && c.value ? (i(), g(e(te), {
2494
- key: 0,
2495
- class: "wx-inbox__new-form",
2496
- variant: "outline",
2497
- block: "",
2498
- onClick: R
2499
- }, {
2500
- icon: a(() => [
2501
- t(e(_e), { name: "plus" })
2502
- ]),
2503
- default: a(() => [
2504
- A(" " + x(e(l)("panel.new-form")), 1)
2505
- ]),
2506
- _: 1
2507
- })) : M("", !0),
2508
- t(e(nl), {
2509
- modelValue: b.value,
2510
- "onUpdate:modelValue": J[1] || (J[1] = (h) => b.value = h),
2511
- class: il(["wx-inbox__forms", { "is-panel": !I }]),
2512
- plain: "",
2513
- size: "sm",
2514
- "item-key": "id",
2515
- "item-label": z,
2516
- "drag-label": e(l)("panel.reorder"),
2517
- disabled: !c.value,
2518
- title: I ? e(l)("panel.forms") : void 0,
2519
- onMove: Q
2520
- }, De({
2521
- default: a(({ item: h }) => [
2522
- H("button", {
2523
- type: "button",
2524
- class: il(["wx-inbox-form", { "is-current": h.id === y.value, "is-off": !h.is_enabled }]),
2525
- onClick: (re) => D(h, w)
2526
- }, [
2527
- H("span", At, [
2528
- t(e(Y), {
2529
- truncate: "",
2530
- weight: "medium",
2531
- tone: h.is_enabled ? "default" : "muted"
2532
- }, {
2533
- default: a(() => [
2534
- A(x(z(h)), 1)
2535
- ]),
2536
- _: 2
2537
- }, 1032, ["tone"]),
2538
- h.is_enabled && h.notifies === !1 ? (i(), g(e(_e), {
2539
- key: 0,
2540
- class: "wx-inbox-form__silent",
2541
- name: "warning",
2542
- label: e(l)("panel.notifies-nobody-short"),
2543
- title: e(l)("panel.notifies-nobody-short")
2544
- }, null, 8, ["label", "title"])) : M("", !0),
2545
- h.unread_count ? (i(), g(e(dl), {
2546
- key: 1,
2547
- class: "wx-inbox-form__count",
2548
- type: "primary",
2549
- value: h.unread_count,
2550
- label: e(l)("panel.unread")
2551
- }, null, 8, ["value", "label"])) : h.submissions_count ? (i(), g(e(dl), {
2552
- key: 2,
2553
- class: "wx-inbox-form__count",
2554
- type: "neutral",
2555
- value: h.submissions_count,
2556
- label: e(l)("panel.submissions")
2557
- }, null, 8, ["value", "label"])) : M("", !0)
2558
- ]),
2559
- t(e(Y), {
2560
- size: "sm",
2561
- tone: "muted",
2562
- truncate: ""
2563
- }, {
2564
- default: a(() => [
2565
- A(x(h.slug), 1)
2566
- ]),
2567
- _: 2
2568
- }, 1024)
2569
- ], 10, Ut)
2570
- ]),
2571
- actions: a(({ item: h }) => [
2572
- t(e(We), {
2573
- actions: L(h),
2574
- label: z(h)
2575
- }, null, 8, ["actions", "label"])
2576
- ]),
2577
- _: 2
2578
- }, [
2579
- I && c.value ? {
2580
- name: "extra",
2581
- fn: a(() => [
2582
- t(e(xe), {
2583
- icon: "plus",
2584
- size: "sm",
2585
- title: e(l)("panel.new-form"),
2586
- onClick: R
2587
- }, null, 8, ["title"])
2588
- ]),
2589
- key: "0"
2590
- } : void 0
2591
- ]), 1032, ["modelValue", "class", "drag-label", "disabled", "title"])
2592
- ], 64))
2593
- ]),
2594
- list: a(() => [
2595
- p.value ? (i(), g(e(Ne), {
2596
- key: 0,
2597
- class: "wx-inbox__loading",
2598
- rows: 6
2599
- })) : S.value ? (i(), g(Ct, {
2600
- ref_key: "pane",
2601
- ref: U,
2602
- key: S.value.id,
2603
- form: S.value,
2604
- base: o.base,
2605
- onChanged: q
2606
- }, null, 8, ["form", "base"])) : (i(), g(e(Ye), {
2607
- key: 2,
2608
- title: e(l)("panel.no-forms"),
2609
- description: e(l)("panel.no-forms-help")
2610
- }, null, 8, ["title", "description"]))
2611
- ]),
2612
- _: 1
2613
- }, 8, ["filters-open", "filters-title"])
2614
- ]),
2615
- _: 1
2616
- })
2617
- ]),
2618
- _: 2
2619
- }, [
2620
- _.value ? void 0 : {
2621
- name: "actions",
2622
- fn: a(() => [
2623
- t(e(te), {
2624
- variant: "outline",
2625
- onClick: J[0] || (J[0] = (I) => $.value = !0)
2626
- }, {
2627
- icon: a(() => [
2628
- t(e(_e), { name: "list" })
2629
- ]),
2630
- default: a(() => [
2631
- A(" " + x(e(l)("panel.forms")), 1)
2632
- ]),
2633
- _: 1
2634
- })
2635
- ]),
2636
- key: "0"
2637
- }
2638
- ]), 1032, ["title", "actions"]));
2639
- }
2640
- }), qt = { class: "wx-inbox-status-form" }, Wt = { class: "wx-inbox-status-form__checks" }, Nt = /* @__PURE__ */ se({
2641
- __name: "StatusDialog",
2642
- props: {
2643
- status: {}
2644
- },
2645
- setup(s) {
2646
- const o = s, { resolve: d, dismiss: u, open: m } = Xe(), T = ie(), n = ce(T);
2647
- pe();
2648
- const l = ae("webx-inbox"), V = be(), b = W(""), p = W({}), U = W("default"), _ = W(!1), $ = W(!1), c = W(!1), N = W(!1), v = W({});
2649
- Ue(
2650
- () => o.status,
2651
- (q) => {
2652
- b.value = q?.key ?? "", p.value = { ...q?.title ?? {} }, U.value = q?.color ?? "default", _.value = q?.is_default ?? !1, $.value = q?.is_spam ?? !1, c.value = q?.is_closed ?? !1, v.value = {};
2653
- },
2654
- { immediate: !0 }
2655
- );
2656
- const y = C(
2657
- () => Bl.map((q) => ({ value: q, label: l(`panel.color-${q}`) }))
2658
- );
2659
- function S(q) {
2660
- return v.value[q]?.[0];
2661
- }
2662
- async function z() {
2663
- N.value = !0, v.value = {};
2664
- const q = {
2665
- key: b.value.trim(),
2666
- title: p.value,
2667
- color: U.value,
2668
- is_default: _.value,
2669
- is_spam: $.value,
2670
- is_closed: c.value
2671
- };
2672
- try {
2673
- d(
2674
- o.status === null ? await n.createStatus(q) : await n.saveStatus(o.status.id, q)
2675
- );
2676
- } catch (D) {
2677
- const j = D.body;
2678
- j?.errors ? (v.value = j.errors, O.danger(l("panel.failed"))) : O.danger(V(D));
2679
- } finally {
2680
- N.value = !1;
2681
- }
2682
- }
2683
- return (q, D) => (i(), g(e(Ge), {
2684
- open: e(m),
2685
- "onUpdate:open": D[7] || (D[7] = (j) => oe(m) ? m.value = j : null),
2686
- title: s.status ? e(l)("panel.settings") : e(l)("panel.new-status"),
2687
- width: 520
2688
- }, {
2689
- footer: a(() => [
2690
- t(e(Ie), { size: "sm" }, {
2691
- default: a(() => [
2692
- t(e(te), {
2693
- variant: "outline",
2694
- onClick: D[6] || (D[6] = (j) => e(u)())
2695
- }, {
2696
- default: a(() => [
2697
- A(x(e(l)("panel.cancel")), 1)
2698
- ]),
2699
- _: 1
2700
- }),
2701
- t(e(te), {
2702
- type: "primary",
2703
- loading: N.value,
2704
- onClick: z
2705
- }, {
2706
- default: a(() => [
2707
- A(x(e(l)("panel.save")), 1)
2708
- ]),
2709
- _: 1
2710
- }, 8, ["loading"])
2711
- ]),
2712
- _: 1
2713
- })
2714
- ]),
2715
- default: a(() => [
2716
- H("div", qt, [
2717
- t(e(X), {
2718
- label: e(l)("panel.title"),
2719
- error: S("title"),
2720
- required: ""
2721
- }, {
2722
- default: a(() => [
2723
- t(e(le), {
2724
- modelValue: p.value,
2725
- "onUpdate:modelValue": D[0] || (D[0] = (j) => p.value = j),
2726
- localized: ""
2727
- }, null, 8, ["modelValue"])
2728
- ]),
2729
- _: 1
2730
- }, 8, ["label", "error"]),
2731
- t(e(X), {
2732
- label: e(l)("panel.status-key"),
2733
- error: S("key"),
2734
- required: ""
2735
- }, {
2736
- default: a(() => [
2737
- t(e(le), {
2738
- modelValue: b.value,
2739
- "onUpdate:modelValue": D[1] || (D[1] = (j) => b.value = j),
2740
- placeholder: "in-progress"
2741
- }, null, 8, ["modelValue"])
2742
- ]),
2743
- _: 1
2744
- }, 8, ["label", "error"]),
2745
- t(e(X), {
2746
- label: e(l)("panel.status-color"),
2747
- error: S("color")
2748
- }, {
2749
- default: a(() => [
2750
- t(e(fe), {
2751
- modelValue: U.value,
2752
- "onUpdate:modelValue": D[2] || (D[2] = (j) => U.value = j),
2753
- options: y.value
2754
- }, null, 8, ["modelValue", "options"])
2755
- ]),
2756
- _: 1
2757
- }, 8, ["label", "error"]),
2758
- H("div", Wt, [
2759
- t(e(he), {
2760
- modelValue: _.value,
2761
- "onUpdate:modelValue": D[3] || (D[3] = (j) => _.value = j),
2762
- label: e(l)("panel.status-default")
2763
- }, null, 8, ["modelValue", "label"]),
2764
- t(e(he), {
2765
- modelValue: $.value,
2766
- "onUpdate:modelValue": D[4] || (D[4] = (j) => $.value = j),
2767
- label: e(l)("panel.status-spam")
2768
- }, null, 8, ["modelValue", "label"]),
2769
- t(e(he), {
2770
- modelValue: c.value,
2771
- "onUpdate:modelValue": D[5] || (D[5] = (j) => c.value = j),
2772
- disabled: $.value,
2773
- label: e(l)("panel.status-closed")
2774
- }, null, 8, ["modelValue", "disabled", "label"])
2775
- ])
2776
- ])
2777
- ]),
2778
- _: 1
2779
- }, 8, ["open", "title"]));
2780
- }
2781
- }), Ft = /* @__PURE__ */ ue(Nt, [["__scopeId", "data-v-b520b53b"]]), It = { class: "wx-inbox-statuses" }, Et = { class: "wx-inbox-status" }, Pt = /* @__PURE__ */ se({
2782
- __name: "StatusesPage",
2783
- props: {
2784
- base: { default: "/inbox" }
2785
- },
2786
- setup(s) {
2787
- const o = s, d = ie(), u = ce(d);
2788
- pe();
2789
- const m = ae("webx-inbox"), T = be(), n = W([]), l = W(!0), V = d.can("inbox.manage"), b = je(Ft), p = ol();
2790
- async function U() {
2791
- l.value = !0;
2792
- try {
2793
- n.value = await u.statuses();
2794
- } catch (y) {
2795
- O.danger(T(y));
2796
- } finally {
2797
- l.value = !1;
2798
- }
2799
- }
2800
- U();
2801
- async function _(y) {
2802
- await b({ status: y }) && await U();
2803
- }
2804
- async function $(y) {
2805
- if (await Ae({
2806
- title: m("panel.delete-status-title", { status: p(y) }),
2807
- message: m("panel.delete-status-text"),
2808
- confirmText: m("panel.delete"),
2809
- cancelText: m("panel.cancel"),
2810
- tone: "danger"
2811
- }))
2812
- try {
2813
- await u.removeStatus(y.id), O.success(m("panel.deleted")), await U();
2814
- } catch (z) {
2815
- O.danger(T(z));
2816
- }
2817
- }
2818
- function c(y) {
2819
- return V ? [
2820
- { key: "edit", icon: "edit", label: m("panel.settings"), run: () => {
2821
- _(y);
2822
- } },
2823
- // A status with submissions in them cannot go: they would have nothing to be in. The
2824
- // line is left out rather than greyed, the way every list of the panel does it.
2825
- ...y.submissions_count === 0 ? [
2826
- {
2827
- key: "delete",
2828
- icon: "trash",
2829
- label: m("panel.delete"),
2830
- danger: !0,
2831
- run: () => {
2832
- $(y);
2833
- }
2834
- }
2835
- ] : []
2836
- ] : [];
2837
- }
2838
- const N = C(
2839
- () => V ? [
2840
- {
2841
- key: "new",
2842
- label: m("panel.new-status"),
2843
- icon: "plus",
2844
- primary: !0,
2845
- run: () => {
2846
- _(null);
2847
- }
2848
- }
2849
- ] : []
2850
- );
2851
- async function v() {
2852
- try {
2853
- await u.sortStatuses(n.value.map((y) => y.id));
2854
- } catch (y) {
2855
- O.danger(T(y, m("panel.reorder-failed"))), await U();
2856
- }
2857
- }
2858
- return (y, S) => (i(), G("div", It, [
2859
- t(e(vl), {
2860
- title: e(m)("panel.statuses"),
2861
- back: o.base,
2862
- "back-label": e(m)("panel.forms"),
2863
- actions: N.value
2864
- }, {
2865
- default: a(() => [
2866
- !l.value && n.value.length === 0 ? (i(), g(e(Ye), {
2867
- key: 0,
2868
- title: e(m)("panel.no-statuses")
2869
- }, null, 8, ["title"])) : (i(), g(e(nl), {
2870
- key: 1,
2871
- modelValue: n.value,
2872
- "onUpdate:modelValue": S[0] || (S[0] = (z) => n.value = z),
2873
- plain: "",
2874
- "item-key": "id",
2875
- "item-label": e(p),
2876
- "drag-label": e(m)("panel.reorder"),
2877
- disabled: !e(V),
2878
- "aria-label": e(m)("panel.statuses"),
2879
- onMove: v
2880
- }, {
2881
- default: a(({ item: z }) => [
2882
- H("div", Et, [
2883
- t(e($e), {
2884
- type: z.color
2885
- }, {
2886
- default: a(() => [
2887
- A(x(e(p)(z)), 1)
2888
- ]),
2889
- _: 2
2890
- }, 1032, ["type"]),
2891
- t(e(Y), {
2892
- size: "sm",
2893
- tone: "muted",
2894
- truncate: ""
2895
- }, {
2896
- default: a(() => [
2897
- H("code", null, x(z.key), 1),
2898
- z.is_default ? (i(), G(ee, { key: 0 }, [
2899
- A(" · " + x(e(m)("panel.status-default")), 1)
2900
- ], 64)) : M("", !0),
2901
- z.is_spam ? (i(), G(ee, { key: 1 }, [
2902
- A(" · " + x(e(m)("panel.status-spam")), 1)
2903
- ], 64)) : z.is_closed ? (i(), G(ee, { key: 2 }, [
2904
- A(" · " + x(e(m)("panel.status-closed")), 1)
2905
- ], 64)) : M("", !0),
2906
- z.submissions_count ? (i(), G(ee, { key: 3 }, [
2907
- A(" · " + x(e(m)("panel.in-use")) + " (" + x(z.submissions_count) + ") ", 1)
2908
- ], 64)) : M("", !0)
2909
- ]),
2910
- _: 2
2911
- }, 1024)
2912
- ])
2913
- ]),
2914
- actions: a(({ item: z }) => [
2915
- t(e(We), {
2916
- actions: c(z),
2917
- label: e(p)(z)
2918
- }, null, 8, ["actions", "label"])
2919
- ]),
2920
- _: 1
2921
- }, 8, ["modelValue", "item-label", "drag-label", "disabled", "aria-label"]))
2922
- ]),
2923
- _: 1
2924
- }, 8, ["title", "back", "back-label", "actions"])
2925
- ]));
2926
- }
2927
- }), Mt = /* @__PURE__ */ ue(Pt, [["__scopeId", "data-v-ba548af9"]]), Ot = { class: "wx-submission" }, Bt = {
2928
- key: 1,
2929
- class: "wx-submission__panes"
2930
- }, Dt = { class: "wx-submission__main" }, Lt = { class: "wx-submission__value" }, Rt = { class: "wx-submission__files" }, Ht = { class: "wx-submission__by" }, Xt = { class: "wx-submission__fields" }, Gt = ["href"], jt = {
2931
- key: 1,
2932
- class: "wx-submission__detail"
2933
- }, Yt = { class: "wx-submission__detail" }, Kt = {
2934
- key: 5,
2935
- class: "wx-submission__recipients"
2936
- }, Zt = { key: 6 }, Qt = { class: "wx-submission__aside" }, Jt = { class: "wx-submission__fields" }, ea = { class: "wx-submission__field" }, la = { class: "wx-submission__field" }, ta = /* @__PURE__ */ se({
2937
- __name: "SubmissionPage",
2938
- props: {
2939
- base: { default: "/inbox" }
2940
- },
2941
- setup(s) {
2942
- const o = s, d = ie(), u = ce(d), m = Re(), T = He(), n = ke();
2943
- pe();
2944
- const l = ae("webx-inbox"), V = ae("webx-admin"), b = be(), p = W(null), U = W([]), _ = W([]), $ = W(!0), c = C(() => d.can("inbox.update")), N = C(() => Number(m.params.id)), v = C(() => ({
2945
- view: typeof m.query.view == "string" ? m.query.view : void 0,
2946
- search: typeof m.query.search == "string" ? m.query.search : void 0,
2947
- assignee: typeof m.query.assignee == "string" ? m.query.assignee : void 0
2948
- })), y = C(() => ({ path: o.base, query: { ...m.query } })), S = C(
2949
- () => U.value.map((f) => ({ value: f.id, label: q(f) }))
2950
- ), z = C(
2951
- () => _.value.map((f) => ({ value: f.id, label: f.name }))
2952
- ), q = ol(), D = C(() => l("panel.submission", { id: String(N.value) })), j = C(() => {
2953
- const f = p.value?.form;
2954
- return f === void 0 ? "" : we(f.title ?? {}, n.active.value, f.slug ?? "");
2955
- }), L = C(() => (p.value?.values ?? []).find((P) => P.type === "email" && (P.value ?? "") !== "")?.value ?? null), R = C(() => {
2956
- if (L.value === null) return null;
2957
- const f = encodeURIComponent(`${j.value} — ${D.value}`);
2958
- return `mailto:${L.value}?subject=${f}`;
2959
- });
2960
- async function r() {
2961
- $.value = !0;
2962
- try {
2963
- p.value = await u.submission(N.value, v.value);
2964
- } catch (f) {
2965
- O.danger(b(f)), T.replace(y.value);
2966
- } finally {
2967
- $.value = !1;
2968
- }
2969
- }
2970
- async function B() {
2971
- try {
2972
- U.value = await u.statuses(), c.value && (_.value = await u.recipients());
2973
- } catch (f) {
2974
- O.danger(b(f));
2975
- }
2976
- }
2977
- Ue(N, () => {
2978
- r();
2979
- }, { immediate: !0 }), B();
2980
- async function Q(f) {
2981
- try {
2982
- p.value = await u.saveSubmission(N.value, f), O.success(l("panel.saved"));
2983
- } catch (Z) {
2984
- O.danger(b(Z)), await r();
2985
- }
2986
- }
2987
- function me(f) {
2988
- typeof f == "number" && Q({ status_id: f });
2989
- }
2990
- function F(f) {
2991
- Q({ assignee_id: typeof f == "number" ? f : null });
2992
- }
2993
- const J = C(() => {
2994
- const f = [];
2995
- return R.value && f.push({
2996
- key: "reply",
2997
- label: l("panel.reply"),
2998
- icon: "mail",
2999
- primary: !0,
3000
- href: R.value,
3001
- target: "_self"
3002
- }), c.value && p.value !== null && f.push(
3003
- {
3004
- key: "unread",
3005
- icon: "eye-off",
3006
- label: l("panel.mark-unread"),
3007
- menu: !0,
3008
- run: () => {
3009
- re();
3010
- }
3011
- },
3012
- {
3013
- key: "notify",
3014
- icon: "mail",
3015
- label: l("panel.notify-again"),
3016
- menu: !0,
3017
- run: () => {
3018
- I();
3019
- }
3020
- },
3021
- {
3022
- key: "delete",
3023
- icon: "trash",
3024
- label: l("panel.delete"),
3025
- danger: !0,
3026
- run: () => {
3027
- de();
3028
- }
3029
- }
3030
- ), f;
3031
- });
3032
- async function I() {
3033
- try {
3034
- p.value = await u.notifySubmission(N.value), O.success(l("panel.notify-sent-again"));
3035
- } catch (f) {
3036
- O.danger(b(f));
3037
- }
3038
- }
3039
- const w = C(() => p.value?.notification ?? null);
3040
- function h(f) {
3041
- return l(`panel.notify-recipient-${f}`);
3042
- }
3043
- async function re() {
3044
- try {
3045
- await u.massSubmissions({ ids: [N.value], action: "unread" }), T.push(y.value);
3046
- } catch (f) {
3047
- O.danger(b(f));
3048
- }
3049
- }
3050
- async function de() {
3051
- if (await Ae({
3052
- title: l("panel.delete-submission-title"),
3053
- message: l("panel.delete-submission-text"),
3054
- confirmText: l("panel.delete"),
3055
- cancelText: l("panel.cancel"),
3056
- tone: "danger"
3057
- }))
3058
- try {
3059
- await u.removeSubmission(N.value), O.success(l("panel.deleted")), T.push(y.value);
3060
- } catch (Z) {
3061
- O.danger(b(Z));
3062
- }
3063
- }
3064
- function Ee(f) {
3065
- f !== null && T.push({ path: `${o.base}/submissions/${f}`, query: { ...m.query } });
3066
- }
3067
- function Te(f) {
3068
- const Z = U.value.find((P) => P.key === f);
3069
- return Z === void 0 ? f : q(Z);
3070
- }
3071
- const Ke = C(
3072
- () => p.value?.events?.some((f) => f.type === "no_recipients") ?? !1
3073
- );
3074
- function Ze(f) {
3075
- switch (f.type) {
3076
- case "created":
3077
- return l("panel.event-created");
3078
- case "status":
3079
- return l("panel.event-status", { to: Te(f.to ?? "") });
3080
- case "assignee":
3081
- return f.to === null || f.to === "" ? l("panel.event-unassigned") : l("panel.event-assignee", { to: f.to });
3082
- case "note":
3083
- return l("panel.event-note");
3084
- case "notified":
3085
- return l("panel.event-notified");
3086
- // A handler of `webx-inbox.handlers`: `from` is its class, shown by its own short name.
3087
- case "handled":
3088
- return l("panel.event-handled", { name: ze(f.from) });
3089
- case "handler_error":
3090
- return l("panel.event-handler-error", {
3091
- name: ze(f.from),
3092
- error: f.to ?? ""
3093
- });
3094
- case "no_recipients":
3095
- return l("panel.event-no-recipients");
3096
- case "notify_queued":
3097
- return l("panel.event-notify-queued");
3098
- case "notify_failed":
3099
- return l("panel.event-notify-failed", { to: f.to ?? "" });
3100
- // An answer corrected by hand: named by the label it was asked under, when it still has one.
3101
- case "value":
3102
- return l("panel.event-value", {
3103
- field: Qe(f.field ?? ""),
3104
- from: f.from ?? "",
3105
- to: f.to ?? ""
3106
- });
3107
- default:
3108
- return f.type;
3109
- }
3110
- }
3111
- function Qe(f) {
3112
- return p.value?.values.find((P) => P.name === f)?.label || f;
3113
- }
3114
- function ze(f) {
3115
- return (f ?? "").split("\\").pop() ?? "";
3116
- }
3117
- function Je(f) {
3118
- return `${Math.max(1, Math.round(f / 1024))} KB`;
3119
- }
3120
- const Pe = C(() => {
3121
- const f = p.value?.meta ?? {}, Z = [];
3122
- typeof f.page == "string" && f.page !== "" && Z.push({ label: l("panel.meta-page"), value: f.page, link: !0 });
3123
- const P = p.value?.placement;
3124
- typeof P == "string" && P !== "" && Z.push({ label: l("panel.meta-placement"), value: P }), typeof f.referrer == "string" && f.referrer !== "" && Z.push({ label: l("panel.meta-referrer"), value: f.referrer, link: !0 });
3125
- for (const [el, k] of Object.entries(f.utm ?? {}))
3126
- Z.push({ label: el, value: String(k) });
3127
- return typeof f.locale == "string" && f.locale !== "" && Z.push({ label: l("panel.meta-locale"), value: f.locale }), typeof f.ip == "string" && f.ip !== "" && Z.push({ label: l("panel.meta-ip"), value: f.ip }), typeof f.user_agent == "string" && f.user_agent !== "" && Z.push({ label: l("panel.meta-agent"), value: f.user_agent }), Z;
3128
- });
3129
- return (f, Z) => (i(), G("div", Ot, [
3130
- t(e(al), {
3131
- title: D.value,
3132
- subtitle: j.value,
3133
- back: y.value,
3134
- actions: J.value
3135
- }, {
3136
- extra: a(() => [
3137
- t(e(xe), {
3138
- icon: "chevron-left",
3139
- size: "lg",
3140
- title: e(l)("panel.previous"),
3141
- disabled: !p.value?.previous_id,
3142
- onClick: Z[0] || (Z[0] = (P) => Ee(p.value?.previous_id ?? null))
3143
- }, null, 8, ["title", "disabled"]),
3144
- t(e(xe), {
3145
- icon: "chevron-right",
3146
- size: "lg",
3147
- title: e(l)("panel.next"),
3148
- disabled: !p.value?.next_id,
3149
- onClick: Z[1] || (Z[1] = (P) => Ee(p.value?.next_id ?? null))
3150
- }, null, 8, ["title", "disabled"])
3151
- ]),
3152
- _: 1
3153
- }, 8, ["title", "subtitle", "back", "actions"]),
3154
- $.value ? (i(), g(e(Ne), {
3155
- key: 0,
3156
- rows: 6
3157
- })) : p.value ? (i(), G("div", Bt, [
3158
- H("div", Dt, [
3159
- t(e(ne), {
3160
- title: e(l)("panel.answers")
3161
- }, {
3162
- default: a(() => [
3163
- p.value.values.length === 0 ? (i(), g(e(Ye), {
3164
- key: 0,
3165
- size: "sm",
3166
- description: e(l)("panel.no-answers")
3167
- }, null, 8, ["description"])) : (i(), g(e(cl), {
3168
- key: 1,
3169
- columns: 1,
3170
- layout: "vertical"
3171
- }, {
3172
- default: a(() => [
3173
- (i(!0), G(ee, null, ye(p.value.values, (P) => (i(), g(e(Me), {
3174
- key: P.id,
3175
- label: P.label ?? P.name
3176
- }, {
3177
- default: a(() => [
3178
- H("p", Lt, x(P.value || "—"), 1)
3179
- ]),
3180
- _: 2
3181
- }, 1032, ["label"]))), 128))
3182
- ]),
3183
- _: 1
3184
- }))
3185
- ]),
3186
- _: 1
3187
- }, 8, ["title"]),
3188
- p.value.files.length > 0 ? (i(), g(e(ne), {
3189
- key: 0,
3190
- title: e(l)("panel.attachments")
3191
- }, {
3192
- default: a(() => [
3193
- H("div", Rt, [
3194
- (i(!0), G(ee, null, ye(p.value.files, (P) => (i(), g(e(Il), {
3195
- key: P.id,
3196
- name: P.name,
3197
- type: P.mime ?? void 0,
3198
- "download-url": P.url,
3199
- "download-label": e(l)("panel.download"),
3200
- size: "sm"
3201
- }, {
3202
- meta: a(() => [
3203
- A(x(Je(P.size)), 1)
3204
- ]),
3205
- _: 2
3206
- }, 1032, ["name", "type", "download-url", "download-label"]))), 128))
3207
- ])
3208
- ]),
3209
- _: 1
3210
- }, 8, ["title"])) : M("", !0),
3211
- t(e(ne), { class: "wx-submission__more" }, {
3212
- default: a(() => [
3213
- t(e(sl), {
3214
- variant: "pill",
3215
- "aria-label": D.value
3216
- }, {
3217
- default: a(() => [
3218
- t(e(ge), {
3219
- value: "notes",
3220
- label: e(V)("notes.title")
3221
- }, {
3222
- default: a(() => [
3223
- t(e($l), {
3224
- id: p.value.id,
3225
- type: "inbox_submission",
3226
- title: "",
3227
- can: c.value,
3228
- onChange: r
3229
- }, null, 8, ["id", "can"])
3230
- ]),
3231
- _: 1
3232
- }, 8, ["label"]),
3233
- t(e(ge), {
3234
- value: "log",
3235
- label: e(l)("panel.log")
3236
- }, {
3237
- default: a(() => [
3238
- t(e(El), { size: "sm" }, {
3239
- default: a(() => [
3240
- (i(!0), G(ee, null, ye(p.value.events, (P) => (i(), g(e(Pl), {
3241
- key: P.id
3242
- }, {
3243
- default: a(() => [
3244
- t(e(Y), {
3245
- size: "sm",
3246
- as: "p",
3247
- class: "wx-submission__event"
3248
- }, {
3249
- default: a(() => [
3250
- A(x(Ze(P)), 1)
3251
- ]),
3252
- _: 2
3253
- }, 1024),
3254
- H("p", Ht, [
3255
- t(e(Y), {
3256
- size: "sm",
3257
- tone: "muted"
3258
- }, {
3259
- default: a(() => [
3260
- A(x(P.author?.name ?? e(l)("panel.system")), 1)
3261
- ]),
3262
- _: 2
3263
- }, 1024),
3264
- t(e(Le), {
3265
- value: P.created_at
3266
- }, null, 8, ["value"])
3267
- ])
3268
- ]),
3269
- _: 2
3270
- }, 1024))), 128))
3271
- ]),
3272
- _: 1
3273
- })
3274
- ]),
3275
- _: 1
3276
- }, 8, ["label"]),
3277
- t(e(ge), {
3278
- value: "details",
3279
- label: e(l)("panel.details")
3280
- }, {
3281
- default: a(() => [
3282
- H("div", Xt, [
3283
- t(e(cl), {
3284
- columns: 1,
3285
- layout: "vertical",
3286
- size: "sm"
3287
- }, {
3288
- default: a(() => [
3289
- t(e(Me), {
3290
- label: e(l)("panel.received")
3291
- }, {
3292
- default: a(() => [
3293
- t(e(Le), {
3294
- value: p.value.created_at,
3295
- tone: "default"
3296
- }, null, 8, ["value"])
3297
- ]),
3298
- _: 1
3299
- }, 8, ["label"]),
3300
- t(e(Me), {
3301
- label: e(l)("panel.meta-source")
3302
- }, {
3303
- default: a(() => [
3304
- t(e($e), {
3305
- type: p.value.source === "panel" ? "info" : "default"
3306
- }, {
3307
- default: a(() => [
3308
- A(x(p.value.source === "panel" ? e(l)("panel.source-panel") : e(l)("panel.source-web")), 1)
3309
- ]),
3310
- _: 1
3311
- }, 8, ["type"])
3312
- ]),
3313
- _: 1
3314
- }, 8, ["label"]),
3315
- (i(!0), G(ee, null, ye(Pe.value, (P) => (i(), g(e(Me), {
3316
- key: P.label,
3317
- label: P.label
3318
- }, {
3319
- default: a(() => [
3320
- P.link ? (i(), G("a", {
3321
- key: 0,
3322
- href: P.value,
3323
- target: "_blank",
3324
- rel: "noreferrer"
3325
- }, x(P.value), 9, Gt)) : (i(), G("span", jt, x(P.value), 1))
3326
- ]),
3327
- _: 2
3328
- }, 1032, ["label"]))), 128))
3329
- ]),
3330
- _: 1
3331
- }),
3332
- w.value?.state === "failed" ? (i(), g(e(Ce), {
3333
- key: 0,
3334
- type: "warning",
3335
- closable: !1,
3336
- title: e(l)("panel.notify-failed")
3337
- }, {
3338
- default: a(() => [
3339
- H("span", Yt, x(w.value.error), 1)
3340
- ]),
3341
- _: 1
3342
- }, 8, ["title"])) : w.value?.state === "queued" ? (i(), g(e(Y), {
3343
- key: 1,
3344
- size: "sm",
3345
- tone: "muted"
3346
- }, {
3347
- default: a(() => [
3348
- A(x(e(l)("panel.notify-queued")), 1)
3349
- ]),
3350
- _: 1
3351
- })) : w.value?.state === "delivered" ? (i(), g(e(Y), {
3352
- key: 2,
3353
- size: "sm",
3354
- tone: "muted"
3355
- }, {
3356
- default: a(() => [
3357
- A(x(e(l)("panel.notified")), 1)
3358
- ]),
3359
- _: 1
3360
- })) : Ke.value ? (i(), g(e(Y), {
3361
- key: 3,
3362
- size: "sm",
3363
- tone: "muted"
3364
- }, {
3365
- default: a(() => [
3366
- A(x(e(l)("panel.notified-nobody")), 1)
3367
- ]),
3368
- _: 1
3369
- })) : (i(), g(e(Y), {
3370
- key: 4,
3371
- size: "sm",
3372
- tone: "muted"
3373
- }, {
3374
- default: a(() => [
3375
- A(x(e(l)("panel.not-notified")), 1)
3376
- ]),
3377
- _: 1
3378
- })),
3379
- w.value && w.value.recipients.length > 0 ? (i(), G("ul", Kt, [
3380
- (i(!0), G(ee, null, ye(w.value.recipients, (P) => (i(), G("li", {
3381
- key: P.address
3382
- }, [
3383
- t(e(Y), { size: "sm" }, {
3384
- default: a(() => [
3385
- A(x(P.address), 1)
3386
- ]),
3387
- _: 2
3388
- }, 1024),
3389
- t(e($e), {
3390
- type: P.state === "failed" ? "danger" : P.state === "delivered" ? "success" : "default"
3391
- }, {
3392
- default: a(() => [
3393
- A(x(h(P.state)), 1)
3394
- ]),
3395
- _: 2
3396
- }, 1032, ["type"])
3397
- ]))), 128))
3398
- ])) : M("", !0),
3399
- c.value && (w.value?.state === "failed" || w.value?.state === "queued") ? (i(), G("div", Zt, [
3400
- t(e(te), {
3401
- size: "sm",
3402
- onClick: I
3403
- }, {
3404
- default: a(() => [
3405
- A(x(e(l)("panel.notify-again")), 1)
3406
- ]),
3407
- _: 1
3408
- })
3409
- ])) : M("", !0)
3410
- ])
3411
- ]),
3412
- _: 1
3413
- }, 8, ["label"])
3414
- ]),
3415
- _: 1
3416
- }, 8, ["aria-label"])
3417
- ]),
3418
- _: 1
3419
- })
3420
- ]),
3421
- H("aside", Qt, [
3422
- t(e(ne), null, {
3423
- default: a(() => [
3424
- H("div", Jt, [
3425
- H("label", ea, [
3426
- t(e(Y), {
3427
- size: "sm",
3428
- tone: "muted"
3429
- }, {
3430
- default: a(() => [
3431
- A(x(e(l)("panel.status")), 1)
3432
- ]),
3433
- _: 1
3434
- }),
3435
- t(e(fe), {
3436
- "model-value": p.value.status?.id ?? null,
3437
- options: S.value,
3438
- disabled: !c.value,
3439
- "onUpdate:modelValue": me
3440
- }, null, 8, ["model-value", "options", "disabled"])
3441
- ]),
3442
- H("label", la, [
3443
- t(e(Y), {
3444
- size: "sm",
3445
- tone: "muted"
3446
- }, {
3447
- default: a(() => [
3448
- A(x(e(l)("panel.assignee")), 1)
3449
- ]),
3450
- _: 1
3451
- }),
3452
- t(e(fe), {
3453
- "model-value": p.value.assignee?.id ?? null,
3454
- options: z.value,
3455
- disabled: !c.value,
3456
- clearable: "",
3457
- placeholder: e(l)("panel.unassigned"),
3458
- "onUpdate:modelValue": F
3459
- }, null, 8, ["model-value", "options", "disabled", "placeholder"])
3460
- ])
3461
- ])
3462
- ]),
3463
- _: 1
3464
- })
3465
- ])
3466
- ])) : M("", !0)
3467
- ]));
3468
- }
3469
- }), aa = /* @__PURE__ */ ue(ta, [["__scopeId", "data-v-bc5b1b85"]]);
3470
- function ua(s = {}) {
3471
- const o = s.path ?? "/inbox";
3472
- return {
3473
- id: "inbox",
3474
- path: o,
3475
- landing: s.landing ?? !0,
3476
- routes: [
3477
- // The section's own path travels as a prop, so a panel that mounted it somewhere else
3478
- // still links between its screens correctly.
3479
- { path: o, name: "webx.inbox", component: zt, props: { base: o } },
3480
- {
3481
- path: `${o}/statuses`,
3482
- name: "webx.inbox.statuses",
3483
- component: Mt,
3484
- props: { base: o }
3485
- },
3486
- {
3487
- path: `${o}/forms/:id(\\d+)`,
3488
- name: "webx.inbox.form",
3489
- component: ht,
3490
- props: { base: o }
3491
- },
3492
- // A submission has an address of its own, not a dialog over the list (§11): it goes in
3493
- // the mail to whoever deals with it, it gets pasted into a chat, an agent links to it.
3494
- {
3495
- path: `${o}/submissions/:id(\\d+)`,
3496
- name: "webx.inbox.submission",
3497
- component: aa,
3498
- props: { base: o }
3499
- }
3500
- ]
3501
- };
3502
- }
1
+ import "vue";
2
+ import { e as x, b as i, F as b, W as n, f as e, g as t, h as I, S, i as W, c as r, j as m, k as F, o as g } from "./index-BQj2UlUS.js";
3503
3
  export {
3504
- Ol as FIELD_TYPES,
3505
- Bl as STATUS_COLORS,
3506
- Ql as WxInboxFieldList,
3507
- ht as WxInboxFormEditor,
3508
- zt as WxInboxPage,
3509
- Mt as WxInboxStatusesPage,
3510
- Ct as WxInboxSubmissionList,
3511
- aa as WxInboxSubmissionPage,
3512
- ce as createInboxApi,
3513
- ua as inbox,
3514
- Ml as inboxMessages,
3515
- ve as option
4
+ x as FIELD_TYPES,
5
+ i as STATUS_COLORS,
6
+ b as WxInboxFieldList,
7
+ n as WxInboxFormEditor,
8
+ e as WxInboxFormField,
9
+ t as WxInboxPage,
10
+ I as WxInboxStatusesPage,
11
+ S as WxInboxSubmissionList,
12
+ W as WxInboxSubmissionPage,
13
+ r as createInboxApi,
14
+ m as inbox,
15
+ F as inboxMessages,
16
+ g as option
3516
17
  };
3517
18
  //# sourceMappingURL=index.js.map