@bahmni/admin-app 0.0.1-dev.456 → 0.0.1-dev.458
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/{AdminDashboard-CW3dg5aH.js → AdminDashboard-D2myV8h8.js} +2 -2
- package/dist/{AuditLog-4UIEeMim.js → AuditLog-BANA_El_.js} +30 -30
- package/dist/{CsvExport-BLWgpSqE.js → CsvExport-D3MLPM8D.js} +12 -12
- package/dist/{CsvUpload-CCl-44UF.js → CsvUpload-BKdwBbmG.js} +1 -1
- package/dist/DocumentsTable-ClDSnyUa-CID7otGi.js +387 -0
- package/dist/{FormsTable-CNZ9uLEn-COEQdXsG.js → FormsTable-Cbe9Shu--DHI0E9vM.js} +79 -79
- package/dist/{LNWAZHJI-DhcOz-DA.js → LNWAZHJI-ioGdkR1P.js} +4 -4
- package/dist/{MWZ6AO7Z-C5NeGavZ.js → MWZ6AO7Z-JcHU5Vtp.js} +5 -5
- package/dist/{Observations-DrtP4xat-3o42-Jun.js → Observations-foWY-TMm-BQi7Rhp-.js} +29 -29
- package/dist/{YPM2AS64-B31dtVSY.js → YPM2AS64-WlM3cWX3.js} +1 -1
- package/dist/{index-BhPzl7gM.js → index-DibGUGp0.js} +27324 -27258
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/DocumentsTable-CIA5vIKF-D8A7W_YZ.js +0 -439
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import "react";
|
|
2
|
+
import { H as o, M as a, P as s, S as t } from "./index-DibGUGp0.js";
|
|
4
3
|
import "@tanstack/react-query";
|
|
4
|
+
import "react";
|
|
5
5
|
const i = () => /* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
|
|
6
6
|
a,
|
|
7
7
|
{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as d, jsxs as S } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useState as l, useRef as
|
|
2
|
+
import { a8 as ee, a9 as te, aa as se, ab as K, a as ae, ac as ne, ad as re, H as ie, a4 as oe, ae as ue, af as de, ag as C, a6 as V, ah as le } from "./index-DibGUGp0.js";
|
|
3
|
+
import { useState as l, useRef as U, useEffect as k, useMemo as ce, useCallback as me } from "react";
|
|
4
4
|
import { useQuery as Ee } from "@tanstack/react-query";
|
|
5
|
-
const
|
|
5
|
+
const q = Symbol.for("constructDateFrom");
|
|
6
6
|
function y(e, t) {
|
|
7
|
-
return typeof e == "function" ? e(t) : e && typeof e == "object" &&
|
|
7
|
+
return typeof e == "function" ? e(t) : e && typeof e == "object" && q in e ? e[q](t) : e instanceof Date ? new e.constructor(t) : new Date(t);
|
|
8
8
|
}
|
|
9
9
|
function w(e, t) {
|
|
10
10
|
return y(e, e);
|
|
@@ -32,15 +32,15 @@ const Le = (e, t) => {
|
|
|
32
32
|
}
|
|
33
33
|
if (!Number.isNaN(r.getTime()))
|
|
34
34
|
return r.toISOString();
|
|
35
|
-
},
|
|
35
|
+
}, G = "NO_EVENTS_FOUND", Y = "NO_MORE_EVENTS_FOUND", Ie = "MATCHING_EVENTS_NOT_FOUND", Te = () => {
|
|
36
36
|
const [e, t] = l({
|
|
37
37
|
startDate: ee(),
|
|
38
38
|
startTime: "00:00",
|
|
39
39
|
username: "",
|
|
40
40
|
patientId: ""
|
|
41
|
-
}), [r, a] = l(0), [i, u] = l(0), [E, _] = l([]), [R, p] = l(null), [b, f] = l(!1), [O, g] = l(!1), [F, M] = l(1),
|
|
42
|
-
|
|
43
|
-
}, o =
|
|
41
|
+
}), [r, a] = l(0), [i, u] = l(0), [E, _] = l([]), [R, p] = l(null), [b, f] = l(!1), [O, g] = l(!1), [F, M] = l(1), I = U(1), s = (c) => {
|
|
42
|
+
I.current = c, M(c);
|
|
43
|
+
}, o = U(0), [n, Q] = l(null), B = U(null), { data: N, isLoading: j, isFetching: L, isError: z } = Ee({
|
|
44
44
|
queryKey: ["auditLogs", n?.requestId],
|
|
45
45
|
queryFn: () => te(n.params),
|
|
46
46
|
enabled: !!n,
|
|
@@ -48,10 +48,10 @@ const Le = (e, t) => {
|
|
|
48
48
|
// (and audit logs must always be fetched fresh). Drop entries as soon as
|
|
49
49
|
// they become inactive instead of retaining them for the default gcTime.
|
|
50
50
|
gcTime: 0
|
|
51
|
-
}),
|
|
51
|
+
}), T = (c, H, m, h, D, W) => {
|
|
52
52
|
o.current += 1, Q({
|
|
53
53
|
action: c,
|
|
54
|
-
params:
|
|
54
|
+
params: H,
|
|
55
55
|
alwaysReplace: m,
|
|
56
56
|
defaultFirstIndex: h,
|
|
57
57
|
defaultLastIndex: D,
|
|
@@ -59,13 +59,13 @@ const Le = (e, t) => {
|
|
|
59
59
|
requestId: o.current
|
|
60
60
|
});
|
|
61
61
|
}, A = Le(e.startDate, e.startTime), X = () => {
|
|
62
|
-
|
|
62
|
+
T(
|
|
63
63
|
"init",
|
|
64
64
|
{ startFrom: A, defaultView: !0 },
|
|
65
65
|
!0,
|
|
66
66
|
0,
|
|
67
67
|
0,
|
|
68
|
-
|
|
68
|
+
G
|
|
69
69
|
);
|
|
70
70
|
}, v = () => !!r || !!i, Z = () => {
|
|
71
71
|
if (!L) {
|
|
@@ -73,7 +73,7 @@ const Le = (e, t) => {
|
|
|
73
73
|
x();
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
T(
|
|
77
77
|
"next",
|
|
78
78
|
{
|
|
79
79
|
lastAuditLogId: i,
|
|
@@ -94,7 +94,7 @@ const Le = (e, t) => {
|
|
|
94
94
|
x();
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
T(
|
|
98
98
|
"prev",
|
|
99
99
|
{
|
|
100
100
|
lastAuditLogId: r,
|
|
@@ -109,7 +109,7 @@ const Le = (e, t) => {
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
}, x = () => {
|
|
112
|
-
L ||
|
|
112
|
+
L || T(
|
|
113
113
|
"runReport",
|
|
114
114
|
{
|
|
115
115
|
defaultView: !0,
|
|
@@ -120,7 +120,7 @@ const Le = (e, t) => {
|
|
|
120
120
|
!0,
|
|
121
121
|
0,
|
|
122
122
|
0,
|
|
123
|
-
|
|
123
|
+
Ie
|
|
124
124
|
);
|
|
125
125
|
}, J = () => {
|
|
126
126
|
L || (t({
|
|
@@ -128,11 +128,11 @@ const Le = (e, t) => {
|
|
|
128
128
|
startTime: "",
|
|
129
129
|
username: "",
|
|
130
130
|
patientId: ""
|
|
131
|
-
}),
|
|
131
|
+
}), T("init", { defaultView: !0 }, !0, 0, 0, G));
|
|
132
132
|
};
|
|
133
|
-
return
|
|
133
|
+
return k(() => {
|
|
134
134
|
X();
|
|
135
|
-
}, []),
|
|
135
|
+
}, []), k(() => {
|
|
136
136
|
if (!n || N === void 0 || B.current === n.requestId) return;
|
|
137
137
|
B.current = n.requestId;
|
|
138
138
|
const c = !!n.params.defaultView, m = (c ? N : [...N].reverse()).map(se), h = m.length === K;
|
|
@@ -140,10 +140,10 @@ const Le = (e, t) => {
|
|
|
140
140
|
if (_(m), p(null), a(m[0].auditLogId), u(m[m.length - 1].auditLogId), c)
|
|
141
141
|
g(!1), f(h), s(1);
|
|
142
142
|
else if (n.action === "next")
|
|
143
|
-
g(!0), f(h), s(
|
|
143
|
+
g(!0), f(h), s(I.current + 1);
|
|
144
144
|
else {
|
|
145
145
|
f(!0);
|
|
146
|
-
const D = Math.max(1,
|
|
146
|
+
const D = Math.max(1, I.current - 1);
|
|
147
147
|
g(D > 1), s(D);
|
|
148
148
|
}
|
|
149
149
|
else
|
|
@@ -166,7 +166,7 @@ const Le = (e, t) => {
|
|
|
166
166
|
runReport: x,
|
|
167
167
|
reset: J
|
|
168
168
|
};
|
|
169
|
-
}, pe = "AuditLog-module_page__-FKzd", Ne = "AuditLog-module_filters__DA4tQ", Ae = "AuditLog-module_filterRow__x6DqE",
|
|
169
|
+
}, pe = "AuditLog-module_page__-FKzd", Ne = "AuditLog-module_filters__DA4tQ", Ae = "AuditLog-module_filterRow__x6DqE", P = {
|
|
170
170
|
page: pe,
|
|
171
171
|
filters: Ne,
|
|
172
172
|
filterRow: Ae
|
|
@@ -186,7 +186,7 @@ const Le = (e, t) => {
|
|
|
186
186
|
prev: O,
|
|
187
187
|
runReport: g,
|
|
188
188
|
reset: F
|
|
189
|
-
} =
|
|
189
|
+
} = Te(), M = ce(
|
|
190
190
|
() => [
|
|
191
191
|
{ key: "auditLogId", header: e("EVENT_ID") },
|
|
192
192
|
{ key: "dateCreated", header: e("CREATED_AT") },
|
|
@@ -197,7 +197,7 @@ const Le = (e, t) => {
|
|
|
197
197
|
{ key: "module", header: e("MODULE") }
|
|
198
198
|
],
|
|
199
199
|
[e]
|
|
200
|
-
),
|
|
200
|
+
), I = me(
|
|
201
201
|
(s, o) => {
|
|
202
202
|
switch (o) {
|
|
203
203
|
case "dateCreated":
|
|
@@ -228,11 +228,11 @@ const Le = (e, t) => {
|
|
|
228
228
|
id: "admin-audit-log-page",
|
|
229
229
|
"data-testid": "admin-audit-log-page-test-id",
|
|
230
230
|
"aria-label": "admin-audit-log-page-aria-label",
|
|
231
|
-
className:
|
|
231
|
+
className: P.page,
|
|
232
232
|
children: [
|
|
233
|
-
/* @__PURE__ */ S(oe, { className:
|
|
233
|
+
/* @__PURE__ */ S(oe, { className: P.filters, "aria-label": e("FILTERS_HEADER_LABEL"), children: [
|
|
234
234
|
/* @__PURE__ */ d("h2", { children: e("FILTERS_HEADER_LABEL") }),
|
|
235
|
-
/* @__PURE__ */ S("div", { className:
|
|
235
|
+
/* @__PURE__ */ S("div", { className: P.filterRow, children: [
|
|
236
236
|
/* @__PURE__ */ d(
|
|
237
237
|
ue,
|
|
238
238
|
{
|
|
@@ -298,7 +298,7 @@ const Le = (e, t) => {
|
|
|
298
298
|
}
|
|
299
299
|
),
|
|
300
300
|
/* @__PURE__ */ d(
|
|
301
|
-
|
|
301
|
+
V,
|
|
302
302
|
{
|
|
303
303
|
kind: "tertiary",
|
|
304
304
|
onClick: F,
|
|
@@ -308,7 +308,7 @@ const Le = (e, t) => {
|
|
|
308
308
|
}
|
|
309
309
|
),
|
|
310
310
|
/* @__PURE__ */ d(
|
|
311
|
-
|
|
311
|
+
V,
|
|
312
312
|
{
|
|
313
313
|
kind: "primary",
|
|
314
314
|
onClick: g,
|
|
@@ -328,7 +328,7 @@ const Le = (e, t) => {
|
|
|
328
328
|
title: e("AUDIT_LOG_TABLE_HEADER_LABEL"),
|
|
329
329
|
dataTestId: "audit-log-table",
|
|
330
330
|
loading: i,
|
|
331
|
-
renderCell:
|
|
331
|
+
renderCell: I,
|
|
332
332
|
emptyStateMessage: _ ? e(_) : void 0,
|
|
333
333
|
errorStateMessage: E ? e("ADMIN_ERROR_FETCH_CONFIG") : null,
|
|
334
334
|
pagination: {
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { jsx as a, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
const X = "CsvExport-module_tile__yBrLM",
|
|
2
|
+
import { a as A, z as M, _ as R, a0 as h, a1 as O, a2 as P, a3 as g, H as D, a4 as V, a5 as f, a6 as x, a7 as b } from "./index-DibGUGp0.js";
|
|
3
|
+
import { useQuery as y, useMutation as L } from "@tanstack/react-query";
|
|
4
|
+
import { useState as E, useMemo as v } from "react";
|
|
5
|
+
const X = "CsvExport-module_tile__yBrLM", B = "CsvExport-module_title__epZnI", H = "CsvExport-module_form__w-cN-", z = "CsvExport-module_search__G82i7", r = {
|
|
6
6
|
tile: X,
|
|
7
|
-
title:
|
|
8
|
-
form:
|
|
7
|
+
title: B,
|
|
8
|
+
form: H,
|
|
9
9
|
search: z
|
|
10
|
-
},
|
|
10
|
+
}, G = 300, p = 2, _ = 5e3, U = "custom:(uuid,setMembers:(uuid))", Q = () => {
|
|
11
11
|
const { t } = A(), { addNotification: i } = M(), [S, C] = E(""), [s, c] = E(
|
|
12
12
|
null
|
|
13
|
-
), n = R(S.trim(),
|
|
13
|
+
), n = R(S.trim(), G), { data: l = [] } = y({
|
|
14
14
|
queryKey: ["csvExportConceptSearch", n],
|
|
15
15
|
queryFn: () => h(n),
|
|
16
16
|
enabled: n.length >= p && n !== s?.name,
|
|
17
17
|
// Keep prior options visible while the next term loads, but not once the input is too short to search
|
|
18
18
|
placeholderData: (e) => n.length >= p ? e : void 0
|
|
19
|
-
}), T =
|
|
19
|
+
}), T = v(
|
|
20
20
|
() => l.flatMap(
|
|
21
21
|
(e) => e.name?.name ? [{ uuid: e.uuid, name: e.name.name }] : []
|
|
22
22
|
),
|
|
23
23
|
[l]
|
|
24
|
-
), o =
|
|
24
|
+
), o = L({
|
|
25
25
|
mutationFn: async (e) => (await P(e.uuid, U)).setMembers?.length ? g(e.name) : null,
|
|
26
26
|
onSuccess: (e, u) => {
|
|
27
27
|
const m = u.name;
|
|
@@ -104,7 +104,7 @@ const X = "CsvExport-module_tile__yBrLM", G = "CsvExport-module_title__epZnI", B
|
|
|
104
104
|
testId: "csv-export-button-test-id",
|
|
105
105
|
disabled: o.isPending,
|
|
106
106
|
children: o.isPending ? /* @__PURE__ */ a(
|
|
107
|
-
|
|
107
|
+
b,
|
|
108
108
|
{
|
|
109
109
|
description: t("ADMIN_CSV_EXPORT_IN_PROGRESS"),
|
|
110
110
|
testId: "csv-export-loading-test-id"
|
|
@@ -118,5 +118,5 @@ const X = "CsvExport-module_tile__yBrLM", G = "CsvExport-module_title__epZnI", B
|
|
|
118
118
|
) });
|
|
119
119
|
};
|
|
120
120
|
export {
|
|
121
|
-
|
|
121
|
+
Q as CsvExport
|
|
122
122
|
};
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { jsx as n, jsxs as h, Fragment as _e } from "react/jsx-runtime";
|
|
2
|
+
import { u as pe, a as Ee, z as ge, i as Ne, Q as Ce, w as Ie, T as v, b as Ae, c as be, K as Le, h as fe, O as ye, d as De, U as j, J as ve, L as we, I as Oe, e as Se, N as Ue, X as J, G as ee } from "./index-DibGUGp0.js";
|
|
3
|
+
import { useQuery as Me } from "@tanstack/react-query";
|
|
4
|
+
import { useState as T, useRef as Re, useEffect as E, useMemo as g, useCallback as _ } from "react";
|
|
5
|
+
const ke = "DocumentsTable-module_documentsTableBody__6iR3w", $e = "DocumentsTable-module_viewAttachmentsLink__aQ1on", He = "DocumentsTable-module_documentViewerContainer__F5m8D", Be = "DocumentsTable-module_printContainer__rtarJ", Ge = "DocumentsTable-module_attachmentItem__17KA7", ze = "DocumentsTable-module_attachmentCounter__WFiI3", Ve = "DocumentsTable-module_attachmentError__RI4U2", We = "DocumentsTable-module_documentIframe__ptq5I", Fe = "DocumentsTable-module_attachmentContent__IaCEe", xe = "DocumentsTable-module_attachmentLoading__FAR6p", qe = "DocumentsTable-module_hiddenWhileLoading__IxocW", Ke = "DocumentsTable-module_documentImage__KQVgS", Pe = "DocumentsTable-module_header__345GY", Qe = "DocumentsTable-module_documentTypeCell__uWGM8", je = "DocumentsTable-module_printAllButton__IVYUW", Je = "DocumentsTable-module_attachmentHeader__yI2xn", o = {
|
|
6
|
+
documentsTableBody: ke,
|
|
7
|
+
viewAttachmentsLink: $e,
|
|
8
|
+
documentViewerContainer: He,
|
|
9
|
+
printContainer: Be,
|
|
10
|
+
attachmentItem: Ge,
|
|
11
|
+
attachmentCounter: ze,
|
|
12
|
+
attachmentError: Ve,
|
|
13
|
+
documentIframe: We,
|
|
14
|
+
attachmentContent: Fe,
|
|
15
|
+
attachmentLoading: xe,
|
|
16
|
+
hiddenWhileLoading: qe,
|
|
17
|
+
documentImage: Ke,
|
|
18
|
+
header: Pe,
|
|
19
|
+
documentTypeCell: Qe,
|
|
20
|
+
printAllButton: je,
|
|
21
|
+
attachmentHeader: Je
|
|
22
|
+
}, Xe = "startConsultation", Ye = "add", Ze = "documents", X = "document-print-container", Y = () => /* @__PURE__ */ n(ee, {}), et = /* @__PURE__ */ new Set([
|
|
23
|
+
"ArrowUp",
|
|
24
|
+
"ArrowDown",
|
|
25
|
+
"PageUp",
|
|
26
|
+
"PageDown",
|
|
27
|
+
"Home",
|
|
28
|
+
"End",
|
|
29
|
+
" "
|
|
30
|
+
]), tt = 15e3, nt = [
|
|
31
|
+
"documentType",
|
|
32
|
+
"documentIdentifier",
|
|
33
|
+
"attachments",
|
|
34
|
+
"uploadedOn",
|
|
35
|
+
"uploadedBy"
|
|
36
|
+
], at = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i, Z = (l) => l.attachments.length > 0 ? l.attachments : l.documentUrl ? [{ url: l.documentUrl, contentType: l.contentType }] : [], lt = ({ config: l, encounterUuids: H }) => {
|
|
37
|
+
const [m, B] = T(!1), [r, G] = T(
|
|
38
|
+
null
|
|
39
|
+
), [b, w] = T(
|
|
40
|
+
/* @__PURE__ */ new Set()
|
|
41
|
+
), [L, O] = T(
|
|
42
|
+
/* @__PURE__ */ new Set()
|
|
43
|
+
), C = Re(null), [S, z] = T(
|
|
44
|
+
null
|
|
45
|
+
), V = S !== null;
|
|
46
|
+
E(() => () => C.current?.abort(), []);
|
|
47
|
+
const N = pe(), { t: a } = Ee(), { addNotification: f } = ge(), c = g(
|
|
48
|
+
() => l?.actions?.find(
|
|
49
|
+
(e) => e.type === Ye
|
|
50
|
+
),
|
|
51
|
+
[l?.actions]
|
|
52
|
+
), te = Ne(c?.requiredPrivilege), ne = !!c && te, ae = Number(l?.pageSize) || 5, [U, M] = T(1), [I, oe] = T(ae), [re, R] = T(void 0), W = _((e) => {
|
|
53
|
+
G(e), B(!0);
|
|
54
|
+
}, []), de = _(() => {
|
|
55
|
+
C.current?.abort(), O(/* @__PURE__ */ new Set()), B(!1), G(null), w(/* @__PURE__ */ new Set());
|
|
56
|
+
}, []), F = _((e) => {
|
|
57
|
+
O((t) => new Set(t).add(e));
|
|
58
|
+
}, []), x = _((e) => {
|
|
59
|
+
w((t) => new Set(t).add(e));
|
|
60
|
+
}, []), se = _(() => {
|
|
61
|
+
c && globalThis.dispatchEvent(
|
|
62
|
+
new CustomEvent(Xe, {
|
|
63
|
+
detail: {
|
|
64
|
+
encounterType: c.encounterType,
|
|
65
|
+
editOnly: c.editOnly ?? Ze,
|
|
66
|
+
...c.editTitle ? { editTitle: c.editTitle } : {}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
}, [c]), { data: A, isLoading: le, isError: k, error: $, refetch: q } = Me({
|
|
71
|
+
queryKey: [
|
|
72
|
+
"documents",
|
|
73
|
+
N,
|
|
74
|
+
H,
|
|
75
|
+
U,
|
|
76
|
+
I
|
|
77
|
+
],
|
|
78
|
+
enabled: !!N,
|
|
79
|
+
queryFn: () => Ce(
|
|
80
|
+
N,
|
|
81
|
+
H,
|
|
82
|
+
I,
|
|
83
|
+
U
|
|
84
|
+
)
|
|
85
|
+
});
|
|
86
|
+
Ie(
|
|
87
|
+
(e) => {
|
|
88
|
+
e.patientUUID === N && e.updatedResources.documents && q();
|
|
89
|
+
},
|
|
90
|
+
[N, q]
|
|
91
|
+
), E(() => {
|
|
92
|
+
A && R(A.total);
|
|
93
|
+
}, [A]), E(() => {
|
|
94
|
+
M(1), R(void 0);
|
|
95
|
+
}, [N]), E(() => {
|
|
96
|
+
k && f({
|
|
97
|
+
title: a("ERROR_DEFAULT_TITLE"),
|
|
98
|
+
message: $?.message ?? "",
|
|
99
|
+
type: "error"
|
|
100
|
+
});
|
|
101
|
+
}, [k, $, f, a]), E(() => {
|
|
102
|
+
const e = new AbortController();
|
|
103
|
+
return (async () => {
|
|
104
|
+
if (!m || !r) return;
|
|
105
|
+
const t = /* @__PURE__ */ new Set(), d = Z(r);
|
|
106
|
+
for (let s = 0; s < d.length; s++) {
|
|
107
|
+
const u = v(d[s].url);
|
|
108
|
+
try {
|
|
109
|
+
(await fetch(u, {
|
|
110
|
+
method: "HEAD",
|
|
111
|
+
signal: e.signal
|
|
112
|
+
})).ok || t.add(s);
|
|
113
|
+
} catch (p) {
|
|
114
|
+
p instanceof Error && p.name !== "AbortError" && t.add(s);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
e.signal.aborted || w(t);
|
|
118
|
+
})(), () => e.abort();
|
|
119
|
+
}, [m, r]), E(() => {
|
|
120
|
+
if (!m || !r) return;
|
|
121
|
+
const e = document.querySelector(
|
|
122
|
+
'[data-testid="document-view-modal"] .cds--modal-content'
|
|
123
|
+
);
|
|
124
|
+
if (!e) return;
|
|
125
|
+
let t = !1;
|
|
126
|
+
const d = () => {
|
|
127
|
+
t = !0;
|
|
128
|
+
}, s = (D) => {
|
|
129
|
+
D.target === e && d();
|
|
130
|
+
}, u = (D) => {
|
|
131
|
+
const Te = D.target;
|
|
132
|
+
et.has(D.key) && !Te?.closest("button, input, textarea, select, a") && d();
|
|
133
|
+
}, p = () => {
|
|
134
|
+
!t && e.scrollTop !== 0 && (e.scrollTop = 0);
|
|
135
|
+
};
|
|
136
|
+
return e.addEventListener("wheel", d, { passive: !0 }), e.addEventListener("touchmove", d, { passive: !0 }), e.addEventListener("mousedown", s), e.addEventListener("keydown", u), e.addEventListener("scroll", p), () => {
|
|
137
|
+
e.removeEventListener("wheel", d), e.removeEventListener("touchmove", d), e.removeEventListener("mousedown", s), e.removeEventListener("keydown", u), e.removeEventListener("scroll", p);
|
|
138
|
+
};
|
|
139
|
+
}, [m, r]);
|
|
140
|
+
const ie = _(
|
|
141
|
+
(e, t) => {
|
|
142
|
+
t !== I ? (oe(t), M(1), R(void 0)) : M(e);
|
|
143
|
+
},
|
|
144
|
+
[I]
|
|
145
|
+
), y = g(
|
|
146
|
+
() => l?.fields ?? nt,
|
|
147
|
+
[l?.fields]
|
|
148
|
+
), ce = g(() => [...A?.documents ?? []].sort((e, t) => !e.uploadedOn && !t.uploadedOn ? 0 : e.uploadedOn ? t.uploadedOn ? new Date(t.uploadedOn).getTime() - new Date(e.uploadedOn).getTime() : -1 : 1), [A]), me = g(() => Ae(y, a), [y, a]), ue = g(
|
|
149
|
+
() => y.map((e) => ({
|
|
150
|
+
key: e,
|
|
151
|
+
sortable: e !== "attachments"
|
|
152
|
+
})),
|
|
153
|
+
[y]
|
|
154
|
+
), i = g(
|
|
155
|
+
() => r ? Z(r) : [],
|
|
156
|
+
[r]
|
|
157
|
+
), K = i.every(
|
|
158
|
+
(e, t) => L.has(t) || b.has(t) || v(e.url) === "#"
|
|
159
|
+
);
|
|
160
|
+
E(() => {
|
|
161
|
+
if (!m || i.length === 0) return;
|
|
162
|
+
const e = setTimeout(
|
|
163
|
+
() => O(new Set(i.keys())),
|
|
164
|
+
tt
|
|
165
|
+
);
|
|
166
|
+
return () => clearTimeout(e);
|
|
167
|
+
}, [m, i]);
|
|
168
|
+
const P = _(
|
|
169
|
+
async (e, t) => {
|
|
170
|
+
if (!r || C.current) return;
|
|
171
|
+
const d = new AbortController(), { signal: s } = d;
|
|
172
|
+
C.current = d, z(t);
|
|
173
|
+
const u = document.getElementById(X);
|
|
174
|
+
try {
|
|
175
|
+
await be(
|
|
176
|
+
e,
|
|
177
|
+
r.documentIdentifier,
|
|
178
|
+
{ container: u, signal: s }
|
|
179
|
+
);
|
|
180
|
+
} catch {
|
|
181
|
+
s.aborted || f({
|
|
182
|
+
title: a("ERROR_DEFAULT_TITLE"),
|
|
183
|
+
message: a("DOCUMENTS_ERROR_LOADING_ATTACHMENT"),
|
|
184
|
+
type: "error"
|
|
185
|
+
});
|
|
186
|
+
} finally {
|
|
187
|
+
C.current = null, z(null);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
[r, f, a]
|
|
191
|
+
), Q = g(
|
|
192
|
+
() => i.filter(
|
|
193
|
+
(e, t) => v(e.url) !== "#" && !b.has(t)
|
|
194
|
+
),
|
|
195
|
+
[i, b]
|
|
196
|
+
), he = _(
|
|
197
|
+
(e, t) => {
|
|
198
|
+
switch (t) {
|
|
199
|
+
case "documentIdentifier":
|
|
200
|
+
return /* @__PURE__ */ n("span", { children: e.documentIdentifier?.trim() || "-" });
|
|
201
|
+
case "documentType":
|
|
202
|
+
return /* @__PURE__ */ h("div", { className: o.documentTypeCell, children: [
|
|
203
|
+
/* @__PURE__ */ n("span", { children: e.documentType ?? a("DOCUMENTS_NOT_AVAILABLE") }),
|
|
204
|
+
e.description && /* @__PURE__ */ n(
|
|
205
|
+
ye,
|
|
206
|
+
{
|
|
207
|
+
iconName: "fa-file-lines",
|
|
208
|
+
content: e.description,
|
|
209
|
+
ariaLabel: e.description,
|
|
210
|
+
testId: `document-notes-${e.id}`
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] });
|
|
214
|
+
case "uploadedOn":
|
|
215
|
+
return fe(
|
|
216
|
+
e.uploadedOn,
|
|
217
|
+
a,
|
|
218
|
+
!0
|
|
219
|
+
).formattedResult || a("DOCUMENTS_NOT_AVAILABLE");
|
|
220
|
+
case "uploadedBy":
|
|
221
|
+
return e.uploadedBy ?? a("DOCUMENTS_NOT_AVAILABLE");
|
|
222
|
+
case "attachments":
|
|
223
|
+
return e.attachments.length > 0 || e.documentUrl ? /* @__PURE__ */ n(
|
|
224
|
+
Le,
|
|
225
|
+
{
|
|
226
|
+
onClick: () => W(e),
|
|
227
|
+
className: o.viewAttachmentsLink,
|
|
228
|
+
"data-testid": `view-attachments-${e.id}`,
|
|
229
|
+
children: a("DOCUMENTS_VIEW_ATTACHMENTS")
|
|
230
|
+
}
|
|
231
|
+
) : "--";
|
|
232
|
+
default:
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
[W, a]
|
|
237
|
+
);
|
|
238
|
+
return /* @__PURE__ */ h(_e, { children: [
|
|
239
|
+
ne && /* @__PURE__ */ h(De, { className: o.header, testId: "documents-header", children: [
|
|
240
|
+
/* @__PURE__ */ n("p", { children: a("DOCUMENTS_TABLE_HEADING") }),
|
|
241
|
+
/* @__PURE__ */ n(
|
|
242
|
+
j,
|
|
243
|
+
{
|
|
244
|
+
autoAlign: !0,
|
|
245
|
+
size: "lg",
|
|
246
|
+
kind: "ghost",
|
|
247
|
+
label: a(c.label),
|
|
248
|
+
testId: "documents-add-button",
|
|
249
|
+
onClick: se,
|
|
250
|
+
children: /* @__PURE__ */ n(ve, { id: "documents-add-icon", name: "fa-plus", size: we.LG })
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
] }),
|
|
254
|
+
/* @__PURE__ */ n("div", { "data-testid": "documents-table", children: /* @__PURE__ */ n(
|
|
255
|
+
Oe,
|
|
256
|
+
{
|
|
257
|
+
headers: me,
|
|
258
|
+
ariaLabel: a("DOCUMENTS_TABLE_HEADING"),
|
|
259
|
+
rows: ce,
|
|
260
|
+
loading: le,
|
|
261
|
+
errorStateMessage: k ? $?.message : null,
|
|
262
|
+
sortable: ue,
|
|
263
|
+
emptyStateMessage: a("DOCUMENTS_NO_RECORDS"),
|
|
264
|
+
renderCell: he,
|
|
265
|
+
className: o.documentsTableBody,
|
|
266
|
+
dataTestId: "documents-table",
|
|
267
|
+
pageSize: I,
|
|
268
|
+
totalItems: re,
|
|
269
|
+
page: U,
|
|
270
|
+
onPageChange: ie
|
|
271
|
+
}
|
|
272
|
+
) }),
|
|
273
|
+
m && r && /* @__PURE__ */ n(
|
|
274
|
+
Se,
|
|
275
|
+
{
|
|
276
|
+
id: "modalIdForActionAreaLayout",
|
|
277
|
+
portalId: "main-display-area",
|
|
278
|
+
open: m,
|
|
279
|
+
onRequestClose: de,
|
|
280
|
+
modalHeading: r.documentIdentifier,
|
|
281
|
+
passiveModal: !0,
|
|
282
|
+
size: "lg",
|
|
283
|
+
testId: "document-view-modal",
|
|
284
|
+
children: /* @__PURE__ */ h("div", { className: o.documentViewerContainer, children: [
|
|
285
|
+
Q.length > 1 && /* @__PURE__ */ n(
|
|
286
|
+
Ue,
|
|
287
|
+
{
|
|
288
|
+
kind: "tertiary",
|
|
289
|
+
size: "sm",
|
|
290
|
+
className: o.printAllButton,
|
|
291
|
+
renderIcon: S === "all" ? Y : J,
|
|
292
|
+
disabled: V || !K,
|
|
293
|
+
testId: "print-all-attachments",
|
|
294
|
+
onClick: () => P(Q, "all"),
|
|
295
|
+
children: a("DOCUMENTS_PRINT_ALL")
|
|
296
|
+
}
|
|
297
|
+
),
|
|
298
|
+
i.map((e, t) => {
|
|
299
|
+
const d = v(e.url), s = e.contentType?.toLowerCase().includes("pdf"), u = (e.contentType?.toLowerCase().includes("image") ?? !1) || at.test(e.url ?? ""), p = b.has(t);
|
|
300
|
+
return d === "#" || p ? /* @__PURE__ */ h(
|
|
301
|
+
"div",
|
|
302
|
+
{
|
|
303
|
+
className: o.attachmentError,
|
|
304
|
+
"data-testid": `attachment-error-${t}`,
|
|
305
|
+
children: [
|
|
306
|
+
i.length > 1 && /* @__PURE__ */ n("p", { className: o.attachmentCounter, children: a("DOCUMENTS_ATTACHMENT_COUNTER", {
|
|
307
|
+
current: t + 1,
|
|
308
|
+
total: i.length
|
|
309
|
+
}) }),
|
|
310
|
+
/* @__PURE__ */ n("p", { children: a("DOCUMENTS_ERROR_LOADING_ATTACHMENT") })
|
|
311
|
+
]
|
|
312
|
+
},
|
|
313
|
+
`${r.id}-${e.url}`
|
|
314
|
+
) : /* @__PURE__ */ h(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
className: o.attachmentItem,
|
|
318
|
+
"data-testid": `attachment-item-${t}`,
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ h("div", { className: o.attachmentHeader, children: [
|
|
321
|
+
i.length > 1 ? /* @__PURE__ */ n("p", { className: o.attachmentCounter, children: a("DOCUMENTS_ATTACHMENT_COUNTER", {
|
|
322
|
+
current: t + 1,
|
|
323
|
+
total: i.length
|
|
324
|
+
}) }) : /* @__PURE__ */ n("span", {}),
|
|
325
|
+
/* @__PURE__ */ n(
|
|
326
|
+
j,
|
|
327
|
+
{
|
|
328
|
+
kind: "ghost",
|
|
329
|
+
size: "sm",
|
|
330
|
+
label: a("DOCUMENTS_PRINT_ATTACHMENT", {
|
|
331
|
+
index: t + 1
|
|
332
|
+
}),
|
|
333
|
+
disabled: V || !K,
|
|
334
|
+
testId: `print-attachment-${t}`,
|
|
335
|
+
onClick: () => P([e], t),
|
|
336
|
+
children: S === t ? /* @__PURE__ */ n(Y, {}) : /* @__PURE__ */ n(J, {})
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
] }),
|
|
340
|
+
/* @__PURE__ */ h("div", { className: o.attachmentContent, children: [
|
|
341
|
+
!L.has(t) && /* @__PURE__ */ n(
|
|
342
|
+
"div",
|
|
343
|
+
{
|
|
344
|
+
className: o.attachmentLoading,
|
|
345
|
+
"data-testid": `attachment-loading-${t}`,
|
|
346
|
+
children: /* @__PURE__ */ n(
|
|
347
|
+
ee,
|
|
348
|
+
{
|
|
349
|
+
description: a("DOCUMENTS_LOADING_ATTACHMENT")
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
),
|
|
354
|
+
u ? /* @__PURE__ */ n(
|
|
355
|
+
"img",
|
|
356
|
+
{
|
|
357
|
+
src: d,
|
|
358
|
+
alt: r.documentIdentifier,
|
|
359
|
+
className: `${o.documentImage} ${L.has(t) ? "" : o.hiddenWhileLoading}`,
|
|
360
|
+
onLoad: () => F(t),
|
|
361
|
+
onError: () => x(t)
|
|
362
|
+
}
|
|
363
|
+
) : /* @__PURE__ */ n(
|
|
364
|
+
"iframe",
|
|
365
|
+
{
|
|
366
|
+
src: s ? `${d}#toolbar=0` : d,
|
|
367
|
+
className: `${o.documentIframe} ${L.has(t) ? "" : o.hiddenWhileLoading}`,
|
|
368
|
+
title: r.documentIdentifier,
|
|
369
|
+
onLoad: () => F(t),
|
|
370
|
+
onError: () => x(t)
|
|
371
|
+
}
|
|
372
|
+
)
|
|
373
|
+
] })
|
|
374
|
+
]
|
|
375
|
+
},
|
|
376
|
+
`${r.id}-${e.url}`
|
|
377
|
+
);
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ n("div", { id: X, className: o.printContainer })
|
|
380
|
+
] })
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] });
|
|
384
|
+
};
|
|
385
|
+
export {
|
|
386
|
+
lt as default
|
|
387
|
+
};
|