@webx-ui/module-inbox 0.10.0 → 0.11.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.
@@ -1,608 +0,0 @@
1
- import { defineComponent as qe, ref as N, computed as c, watch as Se, openBlock as s, createElementBlock as d, createVNode as i, unref as a, withCtx as n, createBlock as p, createElementVNode as v, Fragment as W, renderList as z, toDisplayString as o, createTextVNode as f, createCommentVNode as b } from "vue";
2
- import { useRoute as Te, useRouter as Ce } from "vue-router";
3
- import { useAdmin as Ne, useTranslate as J, useErrorText as $e, WxScreenHead as Ve, WxNotes as Ae, WxDate as Q } from "@webx-ui/module-admin";
4
- import { useLocales as Be, localizedValue as Ie, toast as y, confirm as De, WxAction as X, WxSkeleton as Ee, WxCard as $, WxEmpty as Re, WxDescriptions as Y, WxDescriptionsItem as S, WxFileCard as Ue, WxAlert as Z, WxTabs as je, WxTab as V, WxTimeline as Fe, WxTimelineItem as Le, WxText as h, WxBadge as R, WxButton as ee, WxSelect as ae } from "@webx-ui/core";
5
- import { c as Me, u as Oe, d as Pe, _ as He } from "./index-BJ-mLCee.js";
6
- const Ke = { class: "wx-submission" }, Ge = {
7
- key: 1,
8
- class: "wx-submission__panes"
9
- }, Je = { class: "wx-submission__main" }, Qe = { class: "wx-submission__value" }, Xe = { class: "wx-submission__files" }, Ye = { class: "wx-submission__by" }, Ze = { class: "wx-submission__fields" }, ea = ["href"], aa = {
10
- key: 1,
11
- class: "wx-submission__detail"
12
- }, ta = { class: "wx-submission__notification" }, la = { class: "wx-submission__detail" }, sa = { key: 1 }, na = { key: 2 }, ia = { key: 3 }, ua = { key: 4 }, oa = {
13
- key: 5,
14
- class: "wx-submission__recipients"
15
- }, ra = { class: "wx-submission__detail" }, da = { key: 6 }, ca = { class: "wx-submission__fields" }, pa = {
16
- key: 1,
17
- class: "wx-submission__recipients"
18
- }, va = { class: "wx-submission__channel-text" }, fa = { key: 2 }, _a = { class: "wx-submission__aside" }, ma = { class: "wx-submission__fields" }, ba = { class: "wx-submission__field" }, ya = { class: "wx-submission__field" }, ha = /* @__PURE__ */ qe({
19
- __name: "SubmissionPage",
20
- props: {
21
- base: { default: "/inbox" }
22
- },
23
- setup(te) {
24
- const U = te, j = Ne(), g = Me(j), _ = Te(), T = Ce(), le = Be();
25
- Oe();
26
- const t = J("webx-inbox"), se = J("webx-admin"), w = $e(), u = N(null), A = N([]), F = N([]), B = N(!0), x = c(() => j.can("inbox.update")), k = c(() => Number(_.params.id)), ne = c(() => ({
27
- view: typeof _.query.view == "string" ? _.query.view : void 0,
28
- search: typeof _.query.search == "string" ? _.query.search : void 0,
29
- assignee: typeof _.query.assignee == "string" ? _.query.assignee : void 0
30
- })), C = c(() => ({ path: U.base, query: { ..._.query } })), ie = c(
31
- () => A.value.map((e) => ({ value: e.id, label: L(e) }))
32
- ), ue = c(
33
- () => F.value.map((e) => ({ value: e.id, label: e.name }))
34
- ), L = Pe(), I = c(() => t("panel.submission", { id: String(k.value) })), M = c(() => {
35
- const e = u.value?.form;
36
- return e === void 0 ? "" : Ie(e.title ?? {}, le.active.value, e.slug ?? "");
37
- }), O = c(() => (u.value?.values ?? []).find((l) => l.type === "email" && (l.value ?? "") !== "")?.value ?? null), P = c(() => {
38
- if (O.value === null) return null;
39
- const e = encodeURIComponent(`${M.value} — ${I.value}`);
40
- return `mailto:${O.value}?subject=${e}`;
41
- });
42
- async function D() {
43
- B.value = !0;
44
- try {
45
- u.value = await g.submission(k.value, ne.value);
46
- } catch (e) {
47
- y.danger(w(e)), T.replace(C.value);
48
- } finally {
49
- B.value = !1;
50
- }
51
- }
52
- async function oe() {
53
- try {
54
- A.value = await g.statuses(), x.value && (F.value = await g.recipients());
55
- } catch (e) {
56
- y.danger(w(e));
57
- }
58
- }
59
- Se(k, () => {
60
- D();
61
- }, { immediate: !0 }), oe();
62
- async function H(e) {
63
- try {
64
- u.value = await g.saveSubmission(k.value, e), y.success(t("panel.saved"));
65
- } catch (r) {
66
- y.danger(w(r)), await D();
67
- }
68
- }
69
- function re(e) {
70
- typeof e == "number" && H({ status_id: e });
71
- }
72
- function de(e) {
73
- H({ assignee_id: typeof e == "number" ? e : null });
74
- }
75
- const ce = c(() => {
76
- const e = [];
77
- return P.value && e.push({
78
- key: "reply",
79
- label: t("panel.reply"),
80
- icon: "mail",
81
- primary: !0,
82
- href: P.value,
83
- target: "_self"
84
- }), x.value && u.value !== null && e.push(
85
- {
86
- key: "unread",
87
- icon: "eye-off",
88
- label: t("panel.mark-unread"),
89
- menu: !0,
90
- run: () => {
91
- me();
92
- }
93
- },
94
- {
95
- key: "notify",
96
- icon: "mail",
97
- label: t("panel.notify-again"),
98
- menu: !0,
99
- run: () => {
100
- E();
101
- }
102
- },
103
- {
104
- key: "delete",
105
- icon: "trash",
106
- label: t("panel.delete"),
107
- danger: !0,
108
- run: () => {
109
- be();
110
- }
111
- }
112
- ), e;
113
- });
114
- async function E() {
115
- try {
116
- u.value = await g.notifySubmission(k.value), y.success(t("panel.notify-sent-again"));
117
- } catch (e) {
118
- y.danger(w(e));
119
- }
120
- }
121
- const m = c(() => u.value?.notification ?? null);
122
- function pe(e) {
123
- return t(`panel.notify-recipient-${e}`);
124
- }
125
- const q = c(() => u.value?.channels ?? null), ve = c(() => (q.value ?? []).some((e) => e.status === "failed")), fe = c(() => (q.value ?? []).some((e) => e.retryable));
126
- function _e(e) {
127
- return e.status === "failed" ? "danger" : e.status === "sent" ? "success" : e.status === "skipped" ? "warning" : "default";
128
- }
129
- async function me() {
130
- try {
131
- await g.massSubmissions({ ids: [k.value], action: "unread" }), T.push(C.value);
132
- } catch (e) {
133
- y.danger(w(e));
134
- }
135
- }
136
- async function be() {
137
- if (await De({
138
- title: t("panel.delete-submission-title"),
139
- message: t("panel.delete-submission-text"),
140
- confirmText: t("panel.delete"),
141
- cancelText: t("panel.cancel"),
142
- tone: "danger"
143
- }))
144
- try {
145
- await g.removeSubmission(k.value), y.success(t("panel.deleted")), T.push(C.value);
146
- } catch (r) {
147
- y.danger(w(r));
148
- }
149
- }
150
- function K(e) {
151
- e !== null && T.push({ path: `${U.base}/submissions/${e}`, query: { ..._.query } });
152
- }
153
- function ye(e) {
154
- const r = A.value.find((l) => l.key === e);
155
- return r === void 0 ? e : L(r);
156
- }
157
- const he = c(
158
- () => u.value?.events?.some((e) => e.type === "no_recipients") ?? !1
159
- );
160
- function ge(e) {
161
- switch (e.type) {
162
- case "created":
163
- return t("panel.event-created");
164
- case "status":
165
- return t("panel.event-status", { to: ye(e.to ?? "") });
166
- case "assignee":
167
- return e.to === null || e.to === "" ? t("panel.event-unassigned") : t("panel.event-assignee", { to: e.to });
168
- case "note":
169
- return t("panel.event-note");
170
- case "notified":
171
- return t("panel.event-notified");
172
- // A handler of `webx-inbox.handlers`: `from` is its class, shown by its own short name.
173
- case "handled":
174
- return t("panel.event-handled", { name: G(e.from) });
175
- case "handler_error":
176
- return t("panel.event-handler-error", {
177
- name: G(e.from),
178
- error: e.to ?? ""
179
- });
180
- case "no_recipients":
181
- return t("panel.event-no-recipients");
182
- case "notify_queued":
183
- return t("panel.event-notify-queued");
184
- case "notify_failed":
185
- return t("panel.event-notify-failed", { to: e.to ?? "" });
186
- // An answer corrected by hand: named by the label it was asked under, when it still has one.
187
- case "value":
188
- return t("panel.event-value", {
189
- field: xe(e.field ?? ""),
190
- from: e.from ?? "",
191
- to: e.to ?? ""
192
- });
193
- default:
194
- return e.type;
195
- }
196
- }
197
- function xe(e) {
198
- return u.value?.values.find((l) => l.name === e)?.label || e;
199
- }
200
- function G(e) {
201
- return (e ?? "").split("\\").pop() ?? "";
202
- }
203
- function ke(e) {
204
- return `${Math.max(1, Math.round(e / 1024))} KB`;
205
- }
206
- const we = c(() => {
207
- const e = u.value?.meta ?? {}, r = [];
208
- typeof e.page == "string" && e.page !== "" && r.push({ label: t("panel.meta-page"), value: e.page, link: !0 });
209
- const l = u.value?.placement;
210
- typeof l == "string" && l !== "" && r.push({ label: t("panel.meta-placement"), value: l }), typeof e.referrer == "string" && e.referrer !== "" && r.push({ label: t("panel.meta-referrer"), value: e.referrer, link: !0 });
211
- for (const [We, ze] of Object.entries(e.utm ?? {}))
212
- r.push({ label: We, value: String(ze) });
213
- return typeof e.locale == "string" && e.locale !== "" && r.push({ label: t("panel.meta-locale"), value: e.locale }), typeof e.ip == "string" && e.ip !== "" && r.push({ label: t("panel.meta-ip"), value: e.ip }), typeof e.user_agent == "string" && e.user_agent !== "" && r.push({ label: t("panel.meta-agent"), value: e.user_agent }), r;
214
- });
215
- return (e, r) => (s(), d("div", Ke, [
216
- i(a(Ve), {
217
- title: I.value,
218
- subtitle: M.value,
219
- back: C.value,
220
- actions: ce.value
221
- }, {
222
- extra: n(() => [
223
- i(a(X), {
224
- icon: "chevron-left",
225
- size: "lg",
226
- title: a(t)("panel.previous"),
227
- disabled: !u.value?.previous_id,
228
- onClick: r[0] || (r[0] = (l) => K(u.value?.previous_id ?? null))
229
- }, null, 8, ["title", "disabled"]),
230
- i(a(X), {
231
- icon: "chevron-right",
232
- size: "lg",
233
- title: a(t)("panel.next"),
234
- disabled: !u.value?.next_id,
235
- onClick: r[1] || (r[1] = (l) => K(u.value?.next_id ?? null))
236
- }, null, 8, ["title", "disabled"])
237
- ]),
238
- _: 1
239
- }, 8, ["title", "subtitle", "back", "actions"]),
240
- B.value ? (s(), p(a(Ee), {
241
- key: 0,
242
- rows: 6
243
- })) : u.value ? (s(), d("div", Ge, [
244
- v("div", Je, [
245
- i(a($), {
246
- title: a(t)("panel.answers")
247
- }, {
248
- default: n(() => [
249
- u.value.values.length === 0 ? (s(), p(a(Re), {
250
- key: 0,
251
- size: "sm",
252
- description: a(t)("panel.no-answers")
253
- }, null, 8, ["description"])) : (s(), p(a(Y), {
254
- key: 1,
255
- columns: 1,
256
- layout: "vertical"
257
- }, {
258
- default: n(() => [
259
- (s(!0), d(W, null, z(u.value.values, (l) => (s(), p(a(S), {
260
- key: l.id,
261
- label: l.label ?? l.name
262
- }, {
263
- default: n(() => [
264
- v("p", Qe, o(l.value || "—"), 1)
265
- ]),
266
- _: 2
267
- }, 1032, ["label"]))), 128))
268
- ]),
269
- _: 1
270
- }))
271
- ]),
272
- _: 1
273
- }, 8, ["title"]),
274
- u.value.files.length > 0 ? (s(), p(a($), {
275
- key: 0,
276
- title: a(t)("panel.attachments")
277
- }, {
278
- default: n(() => [
279
- v("div", Xe, [
280
- (s(!0), d(W, null, z(u.value.files, (l) => (s(), p(a(Ue), {
281
- key: l.id,
282
- name: l.name,
283
- type: l.mime ?? void 0,
284
- "download-url": l.url,
285
- "download-label": a(t)("panel.download"),
286
- size: "sm"
287
- }, {
288
- meta: n(() => [
289
- f(o(ke(l.size)), 1)
290
- ]),
291
- _: 2
292
- }, 1032, ["name", "type", "download-url", "download-label"]))), 128))
293
- ])
294
- ]),
295
- _: 1
296
- }, 8, ["title"])) : b("", !0),
297
- ve.value ? (s(), p(a(Z), {
298
- key: 1,
299
- type: "warning",
300
- closable: !1,
301
- title: a(t)("panel.channels-failed")
302
- }, null, 8, ["title"])) : b("", !0),
303
- i(a($), { class: "wx-submission__more" }, {
304
- default: n(() => [
305
- i(a(je), {
306
- variant: "pill",
307
- "aria-label": I.value
308
- }, {
309
- default: n(() => [
310
- i(a(V), {
311
- value: "notes",
312
- label: a(se)("notes.title")
313
- }, {
314
- default: n(() => [
315
- i(a(Ae), {
316
- id: u.value.id,
317
- type: "inbox_submission",
318
- title: "",
319
- can: x.value,
320
- onChange: D
321
- }, null, 8, ["id", "can"])
322
- ]),
323
- _: 1
324
- }, 8, ["label"]),
325
- i(a(V), {
326
- value: "log",
327
- label: a(t)("panel.log")
328
- }, {
329
- default: n(() => [
330
- i(a(Fe), { size: "sm" }, {
331
- default: n(() => [
332
- (s(!0), d(W, null, z(u.value.events, (l) => (s(), p(a(Le), {
333
- key: l.id
334
- }, {
335
- default: n(() => [
336
- i(a(h), {
337
- size: "sm",
338
- as: "p",
339
- class: "wx-submission__event"
340
- }, {
341
- default: n(() => [
342
- f(o(ge(l)), 1)
343
- ]),
344
- _: 2
345
- }, 1024),
346
- v("p", Ye, [
347
- i(a(h), {
348
- size: "sm",
349
- tone: "muted"
350
- }, {
351
- default: n(() => [
352
- f(o(l.author?.name ?? a(t)("panel.system")), 1)
353
- ]),
354
- _: 2
355
- }, 1024),
356
- i(a(Q), {
357
- value: l.created_at
358
- }, null, 8, ["value"])
359
- ])
360
- ]),
361
- _: 2
362
- }, 1024))), 128))
363
- ]),
364
- _: 1
365
- })
366
- ]),
367
- _: 1
368
- }, 8, ["label"]),
369
- i(a(V), {
370
- value: "details",
371
- label: a(t)("panel.details")
372
- }, {
373
- default: n(() => [
374
- v("div", Ze, [
375
- i(a(Y), {
376
- columns: 1,
377
- layout: "vertical",
378
- size: "sm"
379
- }, {
380
- default: n(() => [
381
- i(a(S), {
382
- label: a(t)("panel.received")
383
- }, {
384
- default: n(() => [
385
- i(a(Q), {
386
- value: u.value.created_at,
387
- tone: "default"
388
- }, null, 8, ["value"])
389
- ]),
390
- _: 1
391
- }, 8, ["label"]),
392
- i(a(S), {
393
- label: a(t)("panel.meta-source")
394
- }, {
395
- default: n(() => [
396
- i(a(R), {
397
- type: u.value.source === "panel" ? "info" : "default"
398
- }, {
399
- default: n(() => [
400
- f(o(u.value.source === "panel" ? a(t)("panel.source-panel") : a(t)("panel.source-web")), 1)
401
- ]),
402
- _: 1
403
- }, 8, ["type"])
404
- ]),
405
- _: 1
406
- }, 8, ["label"]),
407
- (s(!0), d(W, null, z(we.value, (l) => (s(), p(a(S), {
408
- key: l.label,
409
- label: l.label
410
- }, {
411
- default: n(() => [
412
- l.link ? (s(), d("a", {
413
- key: 0,
414
- href: l.value,
415
- target: "_blank",
416
- rel: "noreferrer"
417
- }, o(l.value), 9, ea)) : (s(), d("span", aa, o(l.value), 1))
418
- ]),
419
- _: 2
420
- }, 1032, ["label"]))), 128)),
421
- i(a(S), {
422
- label: a(t)("panel.tab-notifications")
423
- }, {
424
- default: n(() => [
425
- v("div", ta, [
426
- m.value?.state === "failed" ? (s(), p(a(Z), {
427
- key: 0,
428
- type: "warning",
429
- closable: !1,
430
- title: a(t)("panel.notify-failed")
431
- }, {
432
- default: n(() => [
433
- v("span", la, o(m.value.error), 1)
434
- ]),
435
- _: 1
436
- }, 8, ["title"])) : m.value?.state === "queued" ? (s(), d("span", sa, o(a(t)("panel.notify-queued")), 1)) : m.value?.state === "delivered" ? (s(), d("span", na, o(a(t)("panel.notified")), 1)) : he.value ? (s(), d("span", ia, o(a(t)("panel.notified-nobody")), 1)) : (s(), d("span", ua, o(a(t)("panel.not-notified")), 1)),
437
- m.value && m.value.recipients.length > 0 ? (s(), d("ul", oa, [
438
- (s(!0), d(W, null, z(m.value.recipients, (l) => (s(), d("li", {
439
- key: l.address
440
- }, [
441
- v("span", ra, o(l.address), 1),
442
- i(a(R), {
443
- type: l.state === "failed" ? "danger" : l.state === "delivered" ? "success" : "default"
444
- }, {
445
- default: n(() => [
446
- f(o(pe(l.state)), 1)
447
- ]),
448
- _: 2
449
- }, 1032, ["type"])
450
- ]))), 128))
451
- ])) : b("", !0),
452
- x.value && (m.value?.state === "failed" || m.value?.state === "queued") ? (s(), d("div", da, [
453
- i(a(ee), {
454
- size: "sm",
455
- onClick: E
456
- }, {
457
- default: n(() => [
458
- f(o(a(t)("panel.notify-again")), 1)
459
- ]),
460
- _: 1
461
- })
462
- ])) : b("", !0)
463
- ])
464
- ]),
465
- _: 1
466
- }, 8, ["label"])
467
- ]),
468
- _: 1
469
- })
470
- ])
471
- ]),
472
- _: 1
473
- }, 8, ["label"]),
474
- q.value ? (s(), p(a(V), {
475
- key: 0,
476
- value: "channels",
477
- label: a(t)("panel.channels")
478
- }, {
479
- default: n(() => [
480
- v("div", ca, [
481
- q.value.length === 0 ? (s(), p(a(h), {
482
- key: 0,
483
- size: "sm",
484
- tone: "muted"
485
- }, {
486
- default: n(() => [
487
- f(o(a(t)("panel.channels-none")), 1)
488
- ]),
489
- _: 1
490
- })) : (s(), d("ul", pa, [
491
- (s(!0), d(W, null, z(q.value, (l) => (s(), d("li", {
492
- key: l.id,
493
- class: "wx-submission__channel"
494
- }, [
495
- v("div", va, [
496
- i(a(h), { size: "sm" }, {
497
- default: n(() => [
498
- f(o(l.channel), 1)
499
- ]),
500
- _: 2
501
- }, 1024),
502
- l.recipient !== "" ? (s(), p(a(h), {
503
- key: 0,
504
- size: "sm",
505
- tone: "muted"
506
- }, {
507
- default: n(() => [
508
- f(o(l.recipient_label ?? l.recipient), 1)
509
- ]),
510
- _: 2
511
- }, 1024)) : b("", !0),
512
- l.error ?? l.reason_label ? (s(), p(a(h), {
513
- key: 1,
514
- size: "sm",
515
- tone: "muted",
516
- class: "wx-submission__detail"
517
- }, {
518
- default: n(() => [
519
- f(o(l.error ?? l.reason_label), 1)
520
- ]),
521
- _: 2
522
- }, 1024)) : b("", !0)
523
- ]),
524
- i(a(R), {
525
- type: _e(l)
526
- }, {
527
- default: n(() => [
528
- f(o(l.status_label), 1)
529
- ]),
530
- _: 2
531
- }, 1032, ["type"])
532
- ]))), 128))
533
- ])),
534
- x.value && fe.value ? (s(), d("div", fa, [
535
- i(a(ee), {
536
- size: "sm",
537
- onClick: E
538
- }, {
539
- default: n(() => [
540
- f(o(a(t)("panel.notify-again")), 1)
541
- ]),
542
- _: 1
543
- })
544
- ])) : b("", !0)
545
- ])
546
- ]),
547
- _: 1
548
- }, 8, ["label"])) : b("", !0)
549
- ]),
550
- _: 1
551
- }, 8, ["aria-label"])
552
- ]),
553
- _: 1
554
- })
555
- ]),
556
- v("aside", _a, [
557
- i(a($), null, {
558
- default: n(() => [
559
- v("div", ma, [
560
- v("label", ba, [
561
- i(a(h), {
562
- size: "sm",
563
- tone: "muted"
564
- }, {
565
- default: n(() => [
566
- f(o(a(t)("panel.status")), 1)
567
- ]),
568
- _: 1
569
- }),
570
- i(a(ae), {
571
- "model-value": u.value.status?.id ?? null,
572
- options: ie.value,
573
- disabled: !x.value,
574
- "onUpdate:modelValue": re
575
- }, null, 8, ["model-value", "options", "disabled"])
576
- ]),
577
- v("label", ya, [
578
- i(a(h), {
579
- size: "sm",
580
- tone: "muted"
581
- }, {
582
- default: n(() => [
583
- f(o(a(t)("panel.assignee")), 1)
584
- ]),
585
- _: 1
586
- }),
587
- i(a(ae), {
588
- "model-value": u.value.assignee?.id ?? null,
589
- options: ue.value,
590
- disabled: !x.value,
591
- clearable: "",
592
- placeholder: a(t)("panel.unassigned"),
593
- "onUpdate:modelValue": de
594
- }, null, 8, ["model-value", "options", "disabled", "placeholder"])
595
- ])
596
- ])
597
- ]),
598
- _: 1
599
- })
600
- ])
601
- ])) : b("", !0)
602
- ]));
603
- }
604
- }), za = /* @__PURE__ */ He(ha, [["__scopeId", "data-v-aeaabeff"]]);
605
- export {
606
- za as default
607
- };
608
- //# sourceMappingURL=SubmissionPage-DI8jAaud.js.map