@argusoft/medplat-core 1.0.9 → 1.0.11

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.
Files changed (116) hide show
  1. package/dist/index-D6bNg8bx.js +66 -0
  2. package/dist/index-D6bNg8bx.js.map +1 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +99455 -445
  5. package/dist/index.js.map +1 -1
  6. package/package.json +4 -1
  7. package/dist/AccessRights-sgIhYR30.js +0 -1238
  8. package/dist/AccessRights-sgIhYR30.js.map +0 -1
  9. package/dist/AddEditQueryBuilder-BaZxS2Cm.js +0 -289
  10. package/dist/AddEditQueryBuilder-BaZxS2Cm.js.map +0 -1
  11. package/dist/AddEditQueryBuilder.css +0 -1
  12. package/dist/AddFeatures-DLbjDGei.js +0 -212
  13. package/dist/AddFeatures-DLbjDGei.js.map +0 -1
  14. package/dist/AddLabelModal-DE3ploGD.js +0 -734
  15. package/dist/AddLabelModal-DE3ploGD.js.map +0 -1
  16. package/dist/AddMenuConfiguration-QWfpcnuP.js +0 -2237
  17. package/dist/AddMenuConfiguration-QWfpcnuP.js.map +0 -1
  18. package/dist/AddMenuConfiguration.css +0 -1
  19. package/dist/AddRoleDrawer-ZK1eejxI.js +0 -453
  20. package/dist/AddRoleDrawer-ZK1eejxI.js.map +0 -1
  21. package/dist/AppModal-BgZyfrd-.js +0 -428
  22. package/dist/AppModal-BgZyfrd-.js.map +0 -1
  23. package/dist/ChangePasswordModal-MV7g8tkA.js +0 -176
  24. package/dist/ChangePasswordModal-MV7g8tkA.js.map +0 -1
  25. package/dist/ConditionConfig-GDCXIg3C.js +0 -395
  26. package/dist/ConditionConfig-GDCXIg3C.js.map +0 -1
  27. package/dist/ConditionConfig.css +0 -1
  28. package/dist/EntityManagement-D-x6Qzal.js +0 -50
  29. package/dist/EntityManagement-D-x6Qzal.js.map +0 -1
  30. package/dist/EventConfigurations-jGCJ4LqP.js +0 -384
  31. package/dist/EventConfigurations-jGCJ4LqP.js.map +0 -1
  32. package/dist/EventConfigurations.css +0 -1
  33. package/dist/EventsExceptionModal-BF6E1Np7.js +0 -200
  34. package/dist/EventsExceptionModal-BF6E1Np7.js.map +0 -1
  35. package/dist/EventsSkeleton-BN7_0IGs.js +0 -74
  36. package/dist/EventsSkeleton-BN7_0IGs.js.map +0 -1
  37. package/dist/FeatureMenu-BYSRoNm0.js +0 -249
  38. package/dist/FeatureMenu-BYSRoNm0.js.map +0 -1
  39. package/dist/Features-CKMmuqcs.js +0 -11
  40. package/dist/Features-CKMmuqcs.js.map +0 -1
  41. package/dist/FlywayQuery-Cx2sly6g.js +0 -169
  42. package/dist/FlywayQuery-Cx2sly6g.js.map +0 -1
  43. package/dist/ImmunizationConfigurationBase-DZ8EqXlF.js +0 -5166
  44. package/dist/ImmunizationConfigurationBase-DZ8EqXlF.js.map +0 -1
  45. package/dist/ImmunizationConfigurationBase.css +0 -1
  46. package/dist/ImmunizationConfigurationsList-CQnxWa09.js +0 -335
  47. package/dist/ImmunizationConfigurationsList-CQnxWa09.js.map +0 -1
  48. package/dist/ImmunizationSkeleton-D2tdv5k-.js +0 -186
  49. package/dist/ImmunizationSkeleton-D2tdv5k-.js.map +0 -1
  50. package/dist/LanguagesModal-rk6IGQwY.js +0 -394
  51. package/dist/LanguagesModal-rk6IGQwY.js.map +0 -1
  52. package/dist/ManageDynamicFeature-BKkCnQvF.js +0 -4189
  53. package/dist/ManageDynamicFeature-BKkCnQvF.js.map +0 -1
  54. package/dist/ManageEventConfiguration-BJxS2Su0.js +0 -1017
  55. package/dist/ManageEventConfiguration-BJxS2Su0.js.map +0 -1
  56. package/dist/ManageEventConfiguration.css +0 -1
  57. package/dist/ManageNotification-B4prX-9Z.js +0 -6819
  58. package/dist/ManageNotification-B4prX-9Z.js.map +0 -1
  59. package/dist/ManageRole-BjIIXAlK.js +0 -728
  60. package/dist/ManageRole-BjIIXAlK.js.map +0 -1
  61. package/dist/ManageTranslation-BTxvSYKb.js +0 -616
  62. package/dist/ManageTranslation-BTxvSYKb.js.map +0 -1
  63. package/dist/ManageTranslation.css +0 -1
  64. package/dist/ManageUser-PHiTNyF8.js +0 -2160
  65. package/dist/ManageUser-PHiTNyF8.js.map +0 -1
  66. package/dist/ManageUser.css +0 -1
  67. package/dist/MobileMenuManagement-DmQU5TTo.js +0 -108
  68. package/dist/MobileMenuManagement-DmQU5TTo.js.map +0 -1
  69. package/dist/MobileTypeEventConfigModal-ChhO_A4f.js +0 -783
  70. package/dist/MobileTypeEventConfigModal-ChhO_A4f.js.map +0 -1
  71. package/dist/NewServerManagement-5YcAtF-g.js +0 -1002
  72. package/dist/NewServerManagement-5YcAtF-g.js.map +0 -1
  73. package/dist/NotificationFlywayQuery-BY8Zzml_.js +0 -244
  74. package/dist/NotificationFlywayQuery-BY8Zzml_.js.map +0 -1
  75. package/dist/NotificationList-BkpOrCpM.js +0 -400
  76. package/dist/NotificationList-BkpOrCpM.js.map +0 -1
  77. package/dist/OtherTypeEventConfigModal-ZnCGWm9v.js +0 -1953
  78. package/dist/OtherTypeEventConfigModal-ZnCGWm9v.js.map +0 -1
  79. package/dist/QueryBuilder-Cus_mRwZ.js +0 -378
  80. package/dist/QueryBuilder-Cus_mRwZ.js.map +0 -1
  81. package/dist/QueryBuilder.css +0 -1
  82. package/dist/QueryManagement-DXA73N2j.js +0 -671
  83. package/dist/QueryManagement-DXA73N2j.js.map +0 -1
  84. package/dist/QueryManagement.css +0 -1
  85. package/dist/RoleManagement-v5Nyp1vr.js +0 -416
  86. package/dist/RoleManagement-v5Nyp1vr.js.map +0 -1
  87. package/dist/ServerSyncModal-uNjGCQJz.js +0 -869
  88. package/dist/ServerSyncModal-uNjGCQJz.js.map +0 -1
  89. package/dist/ShowFlywayQuery-DMsAbtOW.js +0 -130
  90. package/dist/ShowFlywayQuery-DMsAbtOW.js.map +0 -1
  91. package/dist/ShowFlywayQuery-DVRCd384.js +0 -259
  92. package/dist/ShowFlywayQuery-DVRCd384.js.map +0 -1
  93. package/dist/ShowQueryHistory-BDN0tzHg.js +0 -190
  94. package/dist/ShowQueryHistory-BDN0tzHg.js.map +0 -1
  95. package/dist/SubMenu-BHcSNSUF.js +0 -187
  96. package/dist/SubMenu-BHcSNSUF.js.map +0 -1
  97. package/dist/TableDetails-DzREeJkm.js +0 -1508
  98. package/dist/TableDetails-DzREeJkm.js.map +0 -1
  99. package/dist/TableList-B9hr05Hs.js +0 -428
  100. package/dist/TableList-B9hr05Hs.js.map +0 -1
  101. package/dist/TypeConfiguration-C-lk8Szs.js +0 -117
  102. package/dist/TypeConfiguration-C-lk8Szs.js.map +0 -1
  103. package/dist/UserList-BxB1tCwM.js +0 -13042
  104. package/dist/UserList-BxB1tCwM.js.map +0 -1
  105. package/dist/UserList.css +0 -1
  106. package/dist/UserListSkeleton-cglK2SaU.js +0 -184
  107. package/dist/UserListSkeleton-cglK2SaU.js.map +0 -1
  108. package/dist/WidgetList-BSApErov.js +0 -188
  109. package/dist/WidgetList-BSApErov.js.map +0 -1
  110. package/dist/_commonjsHelpers-BItOPCY9.js +0 -29
  111. package/dist/_commonjsHelpers-BItOPCY9.js.map +0 -1
  112. package/dist/i18next-CTOWN_jH.js +0 -1394
  113. package/dist/i18next-CTOWN_jH.js.map +0 -1
  114. package/dist/manageImmunization-B4swS745.js +0 -1204
  115. package/dist/manageImmunization-B4swS745.js.map +0 -1
  116. package/dist/manageImmunization.css +0 -1
@@ -1,4189 +0,0 @@
1
- import { jsx as t, jsxs as s, Fragment as fe } from "react/jsx-runtime";
2
- import { executeAll as Ft, execute as G } from "@/common/services/QueryBuilder";
3
- import { useDebounceFn as fn } from "@/hooks/useDebounceFn.js";
4
- import Ve from "@/views/custom-components/CustomDropdown";
5
- import zi from "@/views/custom-components/CustomSvgUpload";
6
- import ne from "@/views/custom-components/CustomTextField";
7
- import { yupResolver as vn } from "@hookform/resolvers/yup";
8
- import { Editor as Li } from "@monaco-editor/react";
9
- import { generateUUID as hn } from "@/utils/UUIDgenerator";
10
- import { getRoleList as $i, executeQuery as Qi } from "@/common/services/GlobalApis";
11
- import { Dialog as Fn, DialogTitle as Tn, DialogContent as _n, DialogContentText as Ji, Grid2 as xe, Divider as Ye, Chip as ot, FormControl as te, TextField as Vn, IconButton as qe, Box as c, Alert as ji, DialogActions as En, Button as U, useTheme as Dn, debounce as Gi, Step as Hi, Typography as f, Accordion as kt, AccordionSummary as It, AccordionDetails as wt, Tooltip as Yi, RadioGroup as pn, FormControlLabel as lt, Radio as dt, Checkbox as gn, FormGroup as Ki, TableContainer as yn, Table as bn, TableHead as xn, TableRow as ct, TableCell as ee, TableBody as Sn, Stack as Pn, Select as Zi, MenuItem as Cn, Modal as Xi, Card as er, alpha as tr } from "@mui/material";
12
- import H from "@mui/material/Grid2";
13
- import { t as ut } from "./i18next-CTOWN_jH.js";
14
- import nr, { useState as x, useRef as ir, useMemo as Nn, useEffect as ae, useCallback as rr } from "react";
15
- import { useForm as ft, Controller as $, useWatch as mt } from "react-hook-form";
16
- import { useSelector as ar } from "react-redux";
17
- import { useLocation as sr, useNavigate as or } from "react-router";
18
- import * as O from "yup";
19
- import { showToast as me } from "@/common/toaster/toaster";
20
- import { FormConfiguratorService as kn } from "@/common/services/FormConfiguratorService";
21
- import I from "prop-types";
22
- import { useDebounceFn as lr } from "@/hooks/useDebounceFn";
23
- import le from "@/common/fontAwesomeIcons/FontAwesomeIcons";
24
- import Ee from "@/views/custom-components/CustomAutoComplete.jsx";
25
- import { a as In } from "./Features-CKMmuqcs.js";
26
- import Ie from "@/views/custom-components/CustomSwitch";
27
- import dr from "@/views/custom-components/CustomTextArea";
28
- import vt from "@/views/custom-components/CustomCheckBox";
29
- import wn from "@/views/custom-components/CustomDatePicker";
30
- import ge from "@/views/custom-components/FieldDescription";
31
- import { useTranslateProvider as cr } from "@/common/languageTranslator/TranslationContext";
32
- import { getFeatureData as ur, updateUserMenuItems as mr } from "@/common/services/Features";
33
- import fr from "@/views/custom-components/CustomRadioComponent";
34
- function An({
35
- mainFormCtrl: m,
36
- openAddFormModal: M,
37
- setModal: A,
38
- reloadForms: E
39
- }) {
40
- const [l, b] = x(""), [C, Y] = x([]), [ie, R] = x(!0), W = O.object().shape({
41
- formName: O.string().required("Enter form name"),
42
- formCode: O.string().required("Enter form code").matches(
43
- /^[A-Z_]*$/,
44
- "Only uppercase letters and underscores are allowed"
45
- ),
46
- state: O.string().required("Select state"),
47
- formType: O.string().required("Select form type"),
48
- description: O.string().required("Enter description")
49
- }), v = ft({
50
- defaultValues: {
51
- formName: "",
52
- formCode: "",
53
- state: "ACTIVE",
54
- description: "",
55
- menuConfigId: null,
56
- pageParams: "",
57
- formType: null,
58
- navigationState: "medplat.form"
59
- },
60
- resolver: vn(W),
61
- mode: "onChange"
62
- }), de = () => {
63
- if (l.trim() && !C.includes(l)) {
64
- const N = [...C, l];
65
- Y(N), b(""), v.setValue("pageParams", N.join(","));
66
- }
67
- }, Z = (N) => {
68
- const S = C.filter((D) => D !== N);
69
- Y(S), v.setValue("pageParams", S.join(","));
70
- }, z = (N) => {
71
- const S = N.target.value;
72
- /^[a-zA-Z_]*$/.test(S) && b(S);
73
- }, he = () => {
74
- A(!1);
75
- }, Q = (N) => {
76
- J(N);
77
- }, J = (N) => {
78
- if (!ie) {
79
- me({ message: "Form Code is already taken!", type: "error" });
80
- return;
81
- }
82
- const S = () => {
83
- const D = new FormData();
84
- return D.append(
85
- "form",
86
- new Blob([JSON.stringify(N)], {
87
- type: "application/json"
88
- })
89
- ), console.log(D), D;
90
- };
91
- N.isSeparateFeature = !0, kn.saveForm(S()).then(() => {
92
- me({
93
- message: "Configuration created sucessfully!",
94
- type: "success"
95
- });
96
- let D = [];
97
- N.formName && N.formName.length > 0 && D.push({
98
- code: "medplat_form_insert_into_translation_master",
99
- parameters: {
100
- translation_key: N.formName.replaceAll(" ", ""),
101
- translation_value: N.formName,
102
- form_code: N.formCode
103
- },
104
- sequence: 1
105
- }), D.length > 0 && Ft(D), m.setValue("formCode", N.formCode), m.setValue("version", "DRAFT"), m.setValue("navigationState", N.navigationState), he(), v.reset({
106
- formName: "",
107
- formCode: "",
108
- state: "ACTIVE",
109
- description: "",
110
- menuConfigId: null,
111
- pageParams: "",
112
- formType: null,
113
- navigationState: "medplat.form"
114
- }), E();
115
- });
116
- }, pe = lr(async (N) => {
117
- if (!(N != null && N.trim())) return;
118
- const S = (await kn.checkFormCodeAvailability(N)).data;
119
- return R(S), S;
120
- }, 500);
121
- return /* @__PURE__ */ t(
122
- Fn,
123
- {
124
- open: M,
125
- fullWidth: !0,
126
- maxWidth: "lg",
127
- onClose: he,
128
- slotProps: {
129
- paper: {
130
- style: {
131
- borderRadius: "8px"
132
- }
133
- }
134
- },
135
- children: /* @__PURE__ */ s(
136
- "form",
137
- {
138
- noValidate: !0,
139
- onSubmit: (N) => {
140
- N.preventDefault(), N.stopPropagation(), v.handleSubmit(Q)();
141
- },
142
- children: [
143
- /* @__PURE__ */ t(Tn, { children: "Add new form" }),
144
- /* @__PURE__ */ s(_n, { children: [
145
- /* @__PURE__ */ t(Ji, { id: "alert-dialog-slide-description", children: "Please enter all details" }),
146
- /* @__PURE__ */ s(xe, { container: !0, spacing: 2, columns: 12, sx: { mt: 1 }, children: [
147
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(ot, { label: "Basic Details", size: "small" }) }) }),
148
- /* @__PURE__ */ t(xe, { size: 4, children: /* @__PURE__ */ t(
149
- ne,
150
- {
151
- control: v.control,
152
- name: "formName",
153
- id: "formName",
154
- fullWidth: !0,
155
- size: "small",
156
- label: "Name",
157
- errors: v.formState.errors,
158
- required: !0
159
- }
160
- ) }),
161
- /* @__PURE__ */ t(xe, { size: 4, children: /* @__PURE__ */ t(
162
- ne,
163
- {
164
- control: v.control,
165
- name: "formCode",
166
- id: "formCode",
167
- fullWidth: !0,
168
- size: "small",
169
- label: "Code",
170
- errors: {
171
- ...v.formState.errors,
172
- ...ie === !1 && {
173
- formCode: { message: "Form Code is already taken!" }
174
- }
175
- },
176
- required: !0,
177
- onChange: (N) => {
178
- const S = N.target.value.toUpperCase().replace(/[^A-Z_]/g, "");
179
- v.setValue("formCode", S), v.setValue(
180
- "navigationState",
181
- `medplat.form.${S}`
182
- ), pe(S);
183
- }
184
- }
185
- ) }),
186
- /* @__PURE__ */ t(xe, { size: 2, children: /* @__PURE__ */ t(te, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
187
- Ve,
188
- {
189
- control: v.control,
190
- name: "state",
191
- id: "state",
192
- options: ["ACTIVE", "INACTIVE"],
193
- errors: v.formState.errors,
194
- size: "small",
195
- placeholder: "",
196
- label: "State",
197
- required: !0
198
- }
199
- ) }) }),
200
- /* @__PURE__ */ t(xe, { size: 2, children: /* @__PURE__ */ t(te, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
201
- Ve,
202
- {
203
- control: v.control,
204
- name: "formType",
205
- id: "formType",
206
- options: ["FORM", "SEARCH"],
207
- errors: v.formState.errors,
208
- size: "small",
209
- placeholder: "",
210
- label: "Type",
211
- required: !0
212
- }
213
- ) }) }),
214
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(
215
- ne,
216
- {
217
- control: v.control,
218
- name: "description",
219
- id: "description",
220
- fullWidth: !0,
221
- multiline: !0,
222
- rows: 2,
223
- size: "small",
224
- label: "Description",
225
- errors: v.formState.errors,
226
- required: !0
227
- }
228
- ) }),
229
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(ot, { label: "Page Param Details", size: "small" }) }) }),
230
- /* @__PURE__ */ s(xe, { size: 12, children: [
231
- /* @__PURE__ */ t(
232
- $,
233
- {
234
- name: "pageParams",
235
- control: v.control,
236
- render: ({ field: N }) => /* @__PURE__ */ t(
237
- Vn,
238
- {
239
- ...N,
240
- label: "Page Params",
241
- size: "small",
242
- placeholder: "Add Page Params",
243
- value: l,
244
- onChange: z,
245
- onKeyDown: (S) => {
246
- S.key === "Enter" && (S.preventDefault(), de());
247
- },
248
- fullWidth: !0,
249
- slotProps: {
250
- input: {
251
- endAdornment: /* @__PURE__ */ t(qe, { color: "primary", onClick: de, children: /* @__PURE__ */ t(
252
- le,
253
- {
254
- iconName: "faArrowRightToBracket",
255
- size: "xs"
256
- }
257
- ) })
258
- }
259
- }
260
- }
261
- )
262
- }
263
- ),
264
- /* @__PURE__ */ t(c, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: 2 }, children: C.map((N, S) => /* @__PURE__ */ t(
265
- ot,
266
- {
267
- label: N,
268
- onDelete: () => Z(N),
269
- color: "primary"
270
- },
271
- S + 1
272
- )) }),
273
- C.length === 0 && /* @__PURE__ */ t(ji, { severity: "info", variant: "outlined", children: "No page params added" })
274
- ] }),
275
- ["FORM", "SEARCH"].includes(v.getValues("formType")) && /* @__PURE__ */ s(fe, { children: [
276
- /* @__PURE__ */ t(xe, { size: 12, children: /* @__PURE__ */ t(Ye, { children: /* @__PURE__ */ t(ot, { label: "Route Details", size: "small" }) }) }),
277
- /* @__PURE__ */ t(
278
- ne,
279
- {
280
- control: v.control,
281
- name: "navigationState",
282
- id: "navigationState",
283
- fullWidth: !0,
284
- size: "small",
285
- label: "Navigation State",
286
- errors: v.formState.errors,
287
- disabled: !0
288
- }
289
- )
290
- ] })
291
- ] })
292
- ] }),
293
- /* @__PURE__ */ s(En, { children: [
294
- /* @__PURE__ */ t(U, { type: "submit", color: "success", children: "Create" }),
295
- /* @__PURE__ */ t(U, { onClick: he, children: "Close" })
296
- ] })
297
- ]
298
- }
299
- )
300
- }
301
- );
302
- }
303
- An.propTypes = {
304
- mainFormCtrl: I.any,
305
- openAddFormModal: I.any,
306
- setModal: I.any,
307
- reloadForms: I.any
308
- };
309
- const Tt = ({
310
- permission: m,
311
- index: M,
312
- depth: A = 0,
313
- onEdit: E,
314
- onRemove: l,
315
- handleAddChildClick: b,
316
- isLastChild: C = !1,
317
- isDynamicFeature: Y
318
- }) => {
319
- var W;
320
- const ie = Dn(), R = (v) => v.replaceAll(".child.", ".");
321
- return /* @__PURE__ */ s(c, { sx: { position: "relative", pl: A * 3 }, children: [
322
- A > 0 && /* @__PURE__ */ s(fe, { children: [
323
- /* @__PURE__ */ t(
324
- c,
325
- {
326
- sx: {
327
- position: "absolute",
328
- left: 16,
329
- top: 0,
330
- bottom: C ? "50%" : 0,
331
- width: 2,
332
- bgcolor: ie.palette.divider
333
- }
334
- }
335
- ),
336
- /* @__PURE__ */ t(
337
- c,
338
- {
339
- sx: {
340
- position: "absolute",
341
- left: 16,
342
- top: 22,
343
- width: 24,
344
- height: 2,
345
- bgcolor: ie.palette.divider
346
- }
347
- }
348
- )
349
- ] }),
350
- /* @__PURE__ */ s(
351
- c,
352
- {
353
- sx: {
354
- display: "flex",
355
- alignItems: "center",
356
- gap: 1.5,
357
- border: `1px solid ${ie.palette.divider}`,
358
- borderRadius: 2,
359
- padding: "8px 12px",
360
- backgroundColor: A === 0 ? ie.palette.background.paper : tr(ie.palette.background.paper, 0.8),
361
- ml: A > 0 ? 3 : 0,
362
- position: "relative"
363
- },
364
- children: [
365
- A === 0 && /* @__PURE__ */ s(f, { sx: { width: 24, color: "text.secondary" }, children: [
366
- M + 1,
367
- "."
368
- ] }),
369
- /* @__PURE__ */ t(f, { sx: { flexGrow: 1, fontWeight: 500 }, children: R(m.permissionId) }),
370
- A === 0 && /* @__PURE__ */ t(
371
- U,
372
- {
373
- variant: "outlined",
374
- size: "small",
375
- startIcon: /* @__PURE__ */ t(le, { iconName: "faPlus" }),
376
- onClick: () => b(m),
377
- children: "Add Child"
378
- }
379
- ),
380
- (!m.isDefault || m.isDefault && !Y) && /* @__PURE__ */ t(
381
- qe,
382
- {
383
- color: "secondary",
384
- onClick: () => E(m, M),
385
- children: /* @__PURE__ */ t(le, { iconName: "faEdit", size: "sm" })
386
- }
387
- ),
388
- !m.isDefault && /* @__PURE__ */ t(qe, { color: "error", onClick: () => l(m), children: /* @__PURE__ */ t(le, { iconName: "faTrash", size: "sm" }) })
389
- ]
390
- }
391
- ),
392
- ((W = m.childPermissions) == null ? void 0 : W.length) > 0 && /* @__PURE__ */ t(Pn, { spacing: 1, sx: { mt: 1 }, children: m.childPermissions.map((v, de) => /* @__PURE__ */ t(
393
- Tt,
394
- {
395
- permission: v,
396
- index: de,
397
- depth: A + 1,
398
- onEdit: E,
399
- onRemove: l,
400
- handleAddChildClick: b,
401
- isLastChild: de === m.childPermissions.length - 1,
402
- isDynamicFeature: Y
403
- },
404
- de
405
- )) })
406
- ] });
407
- }, Wn = ({
408
- permissions: m,
409
- onEdit: M,
410
- onRemove: A,
411
- handleAddChildClick: E,
412
- isDynamicFeature: l
413
- }) => /* @__PURE__ */ t(Pn, { spacing: 1, children: m.map((b, C) => /* @__PURE__ */ t(
414
- Tt,
415
- {
416
- permission: b,
417
- index: C,
418
- depth: 0,
419
- onEdit: M,
420
- onRemove: A,
421
- handleAddChildClick: E,
422
- isLastChild: C === m.length - 1,
423
- isDynamicFeature: l
424
- },
425
- C
426
- )) }), qn = ({
427
- open: m,
428
- onClose: M,
429
- onSave: A,
430
- formCtrl: E,
431
- editData: l,
432
- parentPermissionId: b = null,
433
- mode: C = "add-parent",
434
- permissionTypes: Y,
435
- setPermissionTypes: ie,
436
- existingPermissionIds: R,
437
- isDynamicFeature: W = !0
438
- }) => {
439
- var Be, Oe, be;
440
- const [v, de] = x(""), [Z, z] = x([]), [he, Q] = x(""), J = {
441
- permissionType: "",
442
- permissionId: "--",
443
- permissionName: "",
444
- permissionDesc: "",
445
- enabled: !0,
446
- permissionSuffix: "",
447
- parentPermissionSuffix: ""
448
- }, pe = {
449
- backendUrl: "",
450
- urlType: "",
451
- queryCodeRequired: l ? (Be = l == null ? void 0 : l.backendUrl) != null && Be.trim() && ((Oe = l == null ? void 0 : l.urlType) != null && Oe.trim()) ? !1 : (be = l == null ? void 0 : l.queryCode) != null && be.trim() ? !0 : void 0 : void 0,
452
- queryCode: ""
453
- }, N = W ? J : { ...J, ...pe }, {
454
- control: S,
455
- watch: D,
456
- handleSubmit: Ke,
457
- reset: Se,
458
- setValue: B,
459
- getValues: De,
460
- setError: ye,
461
- clearErrors: we,
462
- formState: Pe
463
- } = ft({
464
- mode: "onChange",
465
- defaultValues: N
466
- }), j = D("queryCodeRequired"), V = D("permissionType"), Re = D("permissionSuffix"), Ze = D("backendUrl"), ve = D("queryCode"), ht = [
467
- { label: "Query", value: !0 },
468
- { label: "API", value: !1 }
469
- ], L = (p = {}) => ({ ...W ? J : { ...J, ...pe }, ...p }), Ce = D("parentPermissionSuffix"), Ae = (p) => p.trim().toLowerCase().split(/\s+/).map(
470
- (g, w) => w === 0 ? g : g.charAt(0).toUpperCase() + g.slice(1)
471
- ).join(""), Xe = async (p) => {
472
- const g = (await G({
473
- code: "GET_ALL_QUERY_CODE",
474
- parameters: { search: p }
475
- })).data;
476
- z((g == null ? void 0 : g.result) || []);
477
- };
478
- ae(() => {
479
- !W && (async () => {
480
- const g = (await G({
481
- code: "GET_ALL_QUERY_CODE",
482
- parameters: {
483
- search: De("queryCode") ? De("queryCode") : ""
484
- }
485
- })).data;
486
- z((g == null ? void 0 : g.result) || []), Q(De("queryCode"));
487
- })();
488
- }, [ve]), ae(() => {
489
- j === !0 && !Ze ? (B("backendUrl", ""), B("urlType", "")) : j === !1 && !ve && B("queryCode", "");
490
- }, [j]), ae(() => {
491
- var p, g, w;
492
- if (m) {
493
- if (C === "edit" && l) {
494
- const T = {
495
- permissionType: l.permissionType || "",
496
- permissionId: l.permissionId || "--",
497
- permissionName: l.permissionName || "",
498
- permissionDesc: l.permissionDesc || "",
499
- enabled: !!l.enabled,
500
- permissionSuffix: ""
501
- };
502
- if (W)
503
- Se(T);
504
- else {
505
- const re = ((p = l == null ? void 0 : l.backendUrl) == null ? void 0 : p.trim()) && ((g = l == null ? void 0 : l.urlType) == null ? void 0 : g.trim()), _ = (w = l == null ? void 0 : l.queryCode) == null ? void 0 : w.trim();
506
- Se({
507
- ...T,
508
- urlType: l.urlType || "",
509
- backendUrl: l.backendUrl || "",
510
- queryCode: l.queryCode || "",
511
- queryCodeRequired: l ? re ? !1 : _ ? !0 : void 0 : void 0
512
- });
513
- }
514
- return;
515
- }
516
- if (C === "add-child" && b) {
517
- const T = b.split(".")[0] || "";
518
- Se(
519
- L({
520
- permissionType: T,
521
- permissionId: b,
522
- permissionName: "",
523
- permissionDesc: "",
524
- enabled: !0,
525
- permissionSuffix: "",
526
- urlType: "",
527
- backendUrl: "",
528
- queryCodeRequired: void 0,
529
- queryCode: ""
530
- })
531
- );
532
- return;
533
- }
534
- Se(L());
535
- }
536
- }, [m, C, l, b, Se]), ae(() => {
537
- if (C === "add-parent") {
538
- const p = (V == null ? void 0 : V.type) === "menu" ? "view" : V == null ? void 0 : V.type;
539
- if (!p) {
540
- B("permissionId", "--");
541
- return;
542
- }
543
- const g = E.getValues("menuType") || "menuType", w = E.getValues("featureConstant") || "feature";
544
- let T;
545
- if (W)
546
- T = `${p}.${g}.${w}`;
547
- else {
548
- const re = E.getValues("menuName");
549
- T = `${p}.${g}.${Ae(re)}`;
550
- }
551
- Ce != null && Ce.trim() && (T = `${T}.${Ce.trim()}`), B("permissionId", T);
552
- }
553
- }, [V, Ce, C]), ae(() => {
554
- j === !0 && !Ze ? (B("backendUrl", ""), B("urlType", "")) : j === !1 && !ve && B("queryCode", "");
555
- }, [j]), ae(() => {
556
- if (C === "add-child" && b !== null) {
557
- const p = b.split(".")[0] || "", g = `${b}.child`, w = Re ? `${g}.${Re}` : g;
558
- B("permissionId", w), B("permissionType", p);
559
- }
560
- }, [Re, C, b, B]);
561
- const et = (p) => {
562
- const g = {
563
- permissionId: p.permissionId,
564
- permissionType: p.permissionType || (b ? b.split(".")[0] : ""),
565
- permissionName: p.permissionName,
566
- permissionDesc: p.permissionDesc,
567
- enabled: p.enabled,
568
- backendUrl: p != null && p.backendUrl && !j ? p.backendUrl : null,
569
- urlType: p != null && p.urlType && !j ? p.urlType : null,
570
- queryCode: p != null && p.queryCode && j ? p.queryCode : null,
571
- childPermissions: [],
572
- isDefault: l != null && l.isDefault ? l == null ? void 0 : l.isDefault : !1
573
- };
574
- A(g), Se(), M();
575
- }, Me = async (p) => !p || p === "--" ? void 0 : (await G({
576
- code: "CHECK_UNIQUE_PERMISSION_ID",
577
- parameters: { permissionId: p }
578
- })).data.result[0].exists;
579
- return /* @__PURE__ */ s(Fn, { open: m, onClose: M, fullWidth: !0, maxWidth: "sm", children: [
580
- /* @__PURE__ */ t(Tn, { children: C === "edit" ? "Edit Permission" : "Add Permission" }),
581
- /* @__PURE__ */ s(
582
- _n,
583
- {
584
- sx: { display: "flex", flexDirection: "column", gap: 2, mt: 1 },
585
- children: [
586
- C !== "add-child" && C !== "edit" && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
587
- /* @__PURE__ */ s(
588
- f,
589
- {
590
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
591
- children: [
592
- "Permission Type",
593
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
594
- ]
595
- }
596
- ),
597
- /* @__PURE__ */ t(te, { fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
598
- $,
599
- {
600
- name: "permissionType",
601
- control: S,
602
- rules: { required: !0 },
603
- render: ({ field: p }) => /* @__PURE__ */ t(
604
- Ee,
605
- {
606
- id: "permissionType",
607
- name: "permissionType",
608
- control: S,
609
- singleSelect: !0,
610
- checkEquality: "type",
611
- freeSolo: !0,
612
- disableClearable: !1,
613
- placeholder: "Choose permission type",
614
- options: Y ? !v || Y.some(
615
- (g) => g.type.toLowerCase() === v.toLowerCase()
616
- ) ? Y : [
617
- ...Y,
618
- { type: `__add_new__${v}`, isNew: !0 }
619
- ] : [],
620
- getOptionLabel: (g) => g.isNew ? `Add "${g.type.replace("__add_new__", "")}"` : g.type,
621
- onInputChange: (g, w) => de(w),
622
- onChange: (g, w) => {
623
- if (!w) {
624
- p.onChange(null), B("permissionId", "--");
625
- return;
626
- }
627
- if (w.isNew) {
628
- const T = w.type.replace("__add_new__", ""), re = { type: T };
629
- ie(
630
- (_) => _.some((Fe) => Fe.type === T) ? _ : [..._, re]
631
- ), p.onChange(re);
632
- return;
633
- }
634
- p.onChange(w);
635
- }
636
- }
637
- )
638
- }
639
- ) })
640
- ] }),
641
- C === "add-child" ? /* @__PURE__ */ t(fe, { children: /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
642
- /* @__PURE__ */ s(
643
- f,
644
- {
645
- sx: {
646
- minWidth: 160,
647
- fontWeight: 500,
648
- color: "text.secondary"
649
- },
650
- children: [
651
- "Permission ID",
652
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
653
- ]
654
- }
655
- ),
656
- /* @__PURE__ */ s(c, { sx: { display: "flex", gap: 1, flexGrow: 1 }, children: [
657
- /* @__PURE__ */ t(
658
- ne,
659
- {
660
- control: S,
661
- name: "parentPermissionDisplay",
662
- value: `${b}.child.`,
663
- disabled: !0,
664
- fullWidth: !0
665
- }
666
- ),
667
- /* @__PURE__ */ t(
668
- ne,
669
- {
670
- control: S,
671
- name: "permissionSuffix",
672
- placeholder: "Enter child suffix",
673
- errors: Pe.errors,
674
- fullWidth: !0,
675
- onChange: async (p) => {
676
- const g = p.target.value.trim();
677
- if (B("permissionSuffix", g), g.toLowerCase() === "child") {
678
- ye("permissionSuffix", {
679
- type: "manual",
680
- message: "Suffix cannot be 'child'"
681
- });
682
- return;
683
- }
684
- we("permissionSuffix");
685
- const w = `${b}.child.${g}`;
686
- if (B("permissionId", w), R != null && R.has(w)) {
687
- ye("permissionSuffix", {
688
- type: "manual",
689
- message: "Permission ID already exists"
690
- });
691
- return;
692
- }
693
- await Me(w) ? ye("permissionSuffix", {
694
- type: "manual",
695
- message: "Permission ID already exists in DB"
696
- }) : we("permissionSuffix");
697
- }
698
- }
699
- )
700
- ] })
701
- ] }) }) : C === "add-parent" ? V != null && V.type ? /* @__PURE__ */ t(fe, { children: /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
702
- /* @__PURE__ */ s(
703
- f,
704
- {
705
- sx: {
706
- minWidth: 160,
707
- fontWeight: 500,
708
- color: "text.secondary"
709
- },
710
- children: [
711
- "Permission ID",
712
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
713
- ]
714
- }
715
- ),
716
- /* @__PURE__ */ t(
717
- ne,
718
- {
719
- control: S,
720
- name: "baseId",
721
- value: `${(V == null ? void 0 : V.type) === "menu" ? "view" : V == null ? void 0 : V.type}.${E.getValues("menuType")}.${W ? E.getValues("featureConstant") : Ae(E.getValues("menuName"))}.`,
722
- disabled: !0,
723
- fullWidth: !0
724
- }
725
- ),
726
- /* @__PURE__ */ t(
727
- ne,
728
- {
729
- control: S,
730
- name: "parentPermissionSuffix",
731
- placeholder: "Enter suffix",
732
- errors: Pe.errors,
733
- fullWidth: !0,
734
- onChange: async (p) => {
735
- const g = p.target.value.trim();
736
- if (B("parentPermissionSuffix", g), g.toLowerCase() === "child") {
737
- ye("parentPermissionSuffix", {
738
- type: "manual",
739
- message: "Suffix cannot be 'child'"
740
- });
741
- return;
742
- }
743
- we("parentPermissionSuffix");
744
- const w = (V == null ? void 0 : V.type) === "menu" ? "view" : (V == null ? void 0 : V.type) || V || "", T = E.getValues("menuType"), re = E.getValues("featureConstant");
745
- let _;
746
- if (W ? _ = `${w}.${T}.${re}.${g}` : _ = `${w}.${T}.${Ae(E.getValues("menuName"))}.${g}`, B("permissionId", _), R != null && R.has(_)) {
747
- ye("parentPermissionSuffix", {
748
- type: "manual",
749
- message: "Permission ID already exists"
750
- });
751
- return;
752
- }
753
- await Me(_) ? ye("parentPermissionSuffix", {
754
- type: "manual",
755
- message: "Permission ID already exists in DB"
756
- }) : we("parentPermissionSuffix");
757
- }
758
- }
759
- )
760
- ] }) }) : /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
761
- /* @__PURE__ */ s(
762
- f,
763
- {
764
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
765
- children: [
766
- "Permission ID",
767
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
768
- ]
769
- }
770
- ),
771
- /* @__PURE__ */ t(
772
- ne,
773
- {
774
- control: S,
775
- name: "permissionId",
776
- value: "--",
777
- disabled: !0,
778
- fullWidth: !0
779
- }
780
- )
781
- ] }) : /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
782
- /* @__PURE__ */ s(
783
- f,
784
- {
785
- sx: {
786
- minWidth: 160,
787
- fontWeight: 500,
788
- color: "text.secondary"
789
- },
790
- children: [
791
- "Permission ID",
792
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
793
- ]
794
- }
795
- ),
796
- /* @__PURE__ */ t(
797
- ne,
798
- {
799
- control: S,
800
- name: "permissionId",
801
- label: "Permission ID",
802
- disabled: !0,
803
- fullWidth: !0
804
- }
805
- )
806
- ] }),
807
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
808
- /* @__PURE__ */ s(
809
- f,
810
- {
811
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
812
- children: [
813
- "Permission Name",
814
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
815
- ]
816
- }
817
- ),
818
- /* @__PURE__ */ t(
819
- $,
820
- {
821
- name: "permissionName",
822
- control: S,
823
- rules: { required: !0 },
824
- render: ({ field: p }) => /* @__PURE__ */ t(
825
- ne,
826
- {
827
- control: S,
828
- ...p,
829
- placeholder: "Enter name"
830
- }
831
- )
832
- }
833
- )
834
- ] }),
835
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "flex-start", gap: 2, children: [
836
- /* @__PURE__ */ t(
837
- f,
838
- {
839
- sx: {
840
- minWidth: 160,
841
- fontWeight: 500,
842
- color: "text.secondary",
843
- mt: 1
844
- },
845
- children: "Description"
846
- }
847
- ),
848
- /* @__PURE__ */ t(
849
- $,
850
- {
851
- name: "permissionDesc",
852
- control: S,
853
- render: ({ field: p }) => /* @__PURE__ */ t(
854
- dr,
855
- {
856
- control: S,
857
- ...p,
858
- placeholder: "Enter description (optional)",
859
- minRows: 2
860
- }
861
- )
862
- }
863
- )
864
- ] }),
865
- !W && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
866
- /* @__PURE__ */ s(
867
- f,
868
- {
869
- sx: {
870
- minWidth: 160,
871
- fontWeight: 500,
872
- color: "text.secondary"
873
- },
874
- children: [
875
- "Type",
876
- " "
877
- ]
878
- }
879
- ),
880
- /* @__PURE__ */ t(
881
- fr,
882
- {
883
- name: "queryCodeRequired",
884
- control: S,
885
- options: ht,
886
- direction: "row",
887
- dataTestId: "queryOrApi"
888
- }
889
- )
890
- ] }),
891
- !W && j !== void 0 && /* @__PURE__ */ t(fe, { children: j === !1 ? /* @__PURE__ */ s(fe, { children: [
892
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
893
- /* @__PURE__ */ t(
894
- f,
895
- {
896
- sx: {
897
- minWidth: 160,
898
- fontWeight: 500,
899
- color: "text.secondary"
900
- },
901
- children: "URL Type"
902
- }
903
- ),
904
- /* @__PURE__ */ t(te, { fullWidth: !0, size: "small", children: /* @__PURE__ */ t(
905
- $,
906
- {
907
- name: "urlType",
908
- control: S,
909
- render: ({ field: p }) => /* @__PURE__ */ s(Zi, { ...p, displayEmpty: !0, children: [
910
- /* @__PURE__ */ t(Cn, { value: "", children: /* @__PURE__ */ t("em", { children: "Select Type" }) }),
911
- ["GET", "POST", "PUT", "DELETE"].map((g) => /* @__PURE__ */ t(Cn, { value: g, children: g }, g))
912
- ] })
913
- }
914
- ) })
915
- ] }),
916
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
917
- /* @__PURE__ */ t(
918
- f,
919
- {
920
- sx: {
921
- minWidth: 160,
922
- fontWeight: 500,
923
- color: "text.secondary"
924
- },
925
- children: "Backend URL"
926
- }
927
- ),
928
- /* @__PURE__ */ t(
929
- $,
930
- {
931
- name: "backendUrl",
932
- control: S,
933
- render: ({ field: p }) => /* @__PURE__ */ t(
934
- ne,
935
- {
936
- control: S,
937
- ...p,
938
- placeholder: "Enter URL"
939
- }
940
- )
941
- }
942
- )
943
- ] })
944
- ] }) : /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
945
- /* @__PURE__ */ t(
946
- f,
947
- {
948
- sx: {
949
- minWidth: 160,
950
- fontWeight: 500,
951
- color: "text.secondary"
952
- },
953
- children: "Query Code"
954
- }
955
- ),
956
- /* @__PURE__ */ t(
957
- $,
958
- {
959
- name: "queryCode",
960
- control: S,
961
- render: ({ field: p, fieldState: { error: g } }) => /* @__PURE__ */ t(
962
- Ee,
963
- {
964
- id: "queryCode",
965
- name: "queryCode",
966
- control: S,
967
- options: Z,
968
- getOptionLabel: (w) => (w == null ? void 0 : w.code) || "",
969
- checkEquality: "code",
970
- inputValue: he,
971
- disableClearable: !1,
972
- value: (Z == null ? void 0 : Z.find((w) => w.code === p.value)) || null,
973
- onInputChange: (w, T, re) => {
974
- re === "input" && (Q(T), Xe(T));
975
- },
976
- singleSelect: !0,
977
- onChange: (w, T) => {
978
- p.onChange((T == null ? void 0 : T.code) || ""), Q((T == null ? void 0 : T.code) || "");
979
- },
980
- placeholder: "Search Query Code...",
981
- errors: g,
982
- fullWidth: !0,
983
- freeSolo: !1
984
- }
985
- )
986
- }
987
- )
988
- ] }) }),
989
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
990
- /* @__PURE__ */ s(
991
- f,
992
- {
993
- sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
994
- children: [
995
- "Is Active",
996
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" })
997
- ]
998
- }
999
- ),
1000
- /* @__PURE__ */ t(
1001
- $,
1002
- {
1003
- name: "enabled",
1004
- control: S,
1005
- render: ({ field: p }) => /* @__PURE__ */ t(
1006
- Ie,
1007
- {
1008
- ...p,
1009
- disabled: (l == null ? void 0 : l.isDefault) && !W,
1010
- checked: p.value,
1011
- onChange: (g) => p.onChange(g.target.checked)
1012
- }
1013
- )
1014
- }
1015
- )
1016
- ] })
1017
- ]
1018
- }
1019
- ),
1020
- /* @__PURE__ */ s(En, { children: [
1021
- /* @__PURE__ */ t(U, { onClick: M, children: "Cancel" }),
1022
- /* @__PURE__ */ t(
1023
- U,
1024
- {
1025
- onClick: Ke(et),
1026
- variant: "contained",
1027
- disabled: !Pe.isValid || Object.keys(Pe.errors).length > 0,
1028
- children: C === "edit" ? "Update" : C === "add-child" ? "Add Child" : "Add"
1029
- }
1030
- )
1031
- ] })
1032
- ] });
1033
- }, Rn = ({
1034
- open: m,
1035
- onClose: M,
1036
- onSave: A,
1037
- entityData: E,
1038
- permissions: l = []
1039
- }) => {
1040
- const { control: b, watch: C, getValues: Y } = ft({
1041
- defaultValues: {
1042
- noStartDate: !0,
1043
- noEndDate: !0,
1044
- startDate: null,
1045
- endDate: null,
1046
- isBackendOnly: !1
1047
- }
1048
- }), ie = C("noStartDate"), R = C("noEndDate"), W = C("startDate"), v = C("endDate"), de = () => {
1049
- const z = Y();
1050
- Z(z);
1051
- }, Z = (z) => {
1052
- const he = [];
1053
- E.forEach((Q) => {
1054
- if (Q.type === "user") {
1055
- const J = Array.isArray(Q.id) ? Q.id : [Q.id];
1056
- he.push(
1057
- ...J.map((pe) => ({
1058
- entityType: "user",
1059
- user_id: pe,
1060
- name: Q.name,
1061
- startDate: z.noStartDate ? null : z.startDate,
1062
- endDate: z.noEndDate ? null : z.endDate,
1063
- isBackendOnly: z.isBackendOnly,
1064
- permissions: JSON.parse(JSON.stringify(l))
1065
- }))
1066
- );
1067
- }
1068
- Q.type === "role" && Q.ids.forEach((J, pe) => {
1069
- he.push({
1070
- entityType: "role",
1071
- role_id: J,
1072
- name: Q.names[pe],
1073
- startDate: z.noStartDate ? null : z.startDate,
1074
- endDate: z.noEndDate ? null : z.endDate,
1075
- isBackendOnly: z.isBackendOnly,
1076
- permissions: JSON.parse(JSON.stringify(l))
1077
- });
1078
- });
1079
- }), he.forEach((Q) => A(Q)), M();
1080
- };
1081
- return /* @__PURE__ */ t(Xi, { open: m, onClose: M, children: /* @__PURE__ */ t(c, { className: "fixed inset-0 flex items-start justify-center z-50 bg-opacity-10 overflow-y-auto", children: /* @__PURE__ */ s(er, { className: "relative mt-10 p-4 shadow-lg flex flex-col rounded-xl", children: [
1082
- /* @__PURE__ */ s(H, { className: "flex justify-between items-center mb-4", children: [
1083
- /* @__PURE__ */ t(f, { variant: "h6", children: "Grant Access" }),
1084
- /* @__PURE__ */ t(qe, { onClick: M, children: /* @__PURE__ */ t(le, { iconName: "faXmark", size: "sm" }) })
1085
- ] }),
1086
- /* @__PURE__ */ t(H, { container: !0, spacing: 2, children: /* @__PURE__ */ s(H, { item: !0, xs: 12, display: "flex", gap: 2, children: [
1087
- /* @__PURE__ */ s(c, { display: "flex", flexDirection: "column", flex: 1, children: [
1088
- /* @__PURE__ */ t(
1089
- vt,
1090
- {
1091
- label: "No Start Date",
1092
- name: "noStartDate",
1093
- control: b,
1094
- sx: { mb: 1 }
1095
- }
1096
- ),
1097
- /* @__PURE__ */ t(
1098
- wn,
1099
- {
1100
- name: "startDate",
1101
- control: b,
1102
- disabled: ie,
1103
- maxDate: v || void 0
1104
- }
1105
- )
1106
- ] }),
1107
- /* @__PURE__ */ s(c, { display: "flex", flexDirection: "column", flex: 1, children: [
1108
- /* @__PURE__ */ t(
1109
- vt,
1110
- {
1111
- label: "No End Date",
1112
- name: "noEndDate",
1113
- control: b,
1114
- sx: { mb: 1 }
1115
- }
1116
- ),
1117
- /* @__PURE__ */ t(
1118
- wn,
1119
- {
1120
- name: "endDate",
1121
- control: b,
1122
- disabled: R,
1123
- minDate: W || void 0
1124
- }
1125
- )
1126
- ] })
1127
- ] }) }),
1128
- /* @__PURE__ */ t(c, { mt: 2, children: /* @__PURE__ */ t(
1129
- vt,
1130
- {
1131
- label: "Is Backend Only?",
1132
- name: "isBackendOnly",
1133
- control: b
1134
- }
1135
- ) }),
1136
- /* @__PURE__ */ s(H, { className: "flex justify-end gap-2 mt-4", children: [
1137
- /* @__PURE__ */ t(U, { type: "button", variant: "outlined", onClick: M, children: "Cancel" }),
1138
- /* @__PURE__ */ t(U, { variant: "contained", type: "button", onClick: de, children: "Save" })
1139
- ] })
1140
- ] }) }) });
1141
- }, _t = ({ permissions: m, onToggle: M, isChild: A = !1 }) => {
1142
- const E = (l) => l.replaceAll(".child", "");
1143
- return m.map((l, b) => {
1144
- var C;
1145
- return /* @__PURE__ */ s(
1146
- c,
1147
- {
1148
- display: "flex",
1149
- flexDirection: "column",
1150
- gap: 1,
1151
- ml: A ? 2 : 0,
1152
- children: [
1153
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 1, children: [
1154
- /* @__PURE__ */ t(
1155
- Ie,
1156
- {
1157
- sx: {
1158
- transform: "scale(0.75)",
1159
- transformOrigin: "left center"
1160
- },
1161
- checked: !!l.enabled,
1162
- disabled: A,
1163
- onChange: () => {
1164
- A || M(l);
1165
- }
1166
- }
1167
- ),
1168
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: E(l.permissionId) })
1169
- ] }),
1170
- ((C = l.childPermissions) == null ? void 0 : C.length) > 0 && /* @__PURE__ */ t(
1171
- _t,
1172
- {
1173
- permissions: l.childPermissions,
1174
- onToggle: M,
1175
- isChild: !0
1176
- }
1177
- )
1178
- ]
1179
- },
1180
- b
1181
- );
1182
- });
1183
- };
1184
- function Jr() {
1185
- var tn, nn, rn, an, sn, on, ln, dn, cn, un, mn;
1186
- const { translate: m } = cr(), M = ir(null), A = sr(), E = or(), { isNew: l } = A.state || {}, b = Nn(
1187
- () => new URLSearchParams(A.search),
1188
- [A.search]
1189
- ), C = Dn(), [Y, ie] = x([]), [R, W] = x(!1), [v, de] = x([]), [Z, z] = x([]), [he, Q] = x(), [J, pe] = x({}), [N, S] = x(!1), [D, Ke] = x(!1), [Se, B] = x(""), [De, ye] = x(""), [we, Pe] = x(""), [j, V] = x(), [Re, Ze] = x([]), [ve, ht] = x(!1), [L, Ce] = x(0), [Ae, Xe] = x(!1), [et, Me] = x([]), [Be, Oe] = x([]), [be, p] = x([]), [g, w] = x([]), [T, re] = x([]), [_, Fe] = x({}), [Ue, ze] = x([]), [Le, Mn] = x({}), [ce, $e] = x([]), [Bn, Qe] = x(!1), [Je, tt] = x("add-parent"), [pt, nt] = x(null), [On, it] = x(null), [Un, rt] = x(null), [zn, gt] = x(!1), [Ln, $n] = x(null), [Ne, We] = x([]), [Qn, Vt] = x(!1), [Te, at] = x(!1), [Et, Jn] = x(!1), [K, Dt] = x({ value: !1, length: 0 }), [jn, Gn] = x([
1190
- { type: "update" },
1191
- { type: "menu" },
1192
- { type: "create" },
1193
- { type: "download" },
1194
- { type: "execute" }
1195
- ]), [ke, Hn] = x([]), [Yn, je] = x(""), [Kn, Ge] = x(""), [yt, bt] = x({
1196
- basicConfig: !0,
1197
- trainingConfig: !1,
1198
- notificationConfig: !1
1199
- }), [Pt, Zn] = nr.useState(null), Xn = (e) => et.includes(e), [ei, At] = x(/* @__PURE__ */ new Set()), ti = ar((e) => e.theme.mode), q = [
1200
- { key: "featureDetails", label: "Feature Details" },
1201
- { key: "mobileConfig", label: "Mobile Config" },
1202
- { key: "formLinking", label: "Form Linking" },
1203
- { key: "additionalPermissions", label: "Permission Management" },
1204
- { key: "assignFeatures", label: "Assignment" },
1205
- { key: "submit", label: "Submit" }
1206
- ], ni = O.object().shape({
1207
- menuName: O.string().required("Enter Feature Name"),
1208
- featureConstant: O.string().when("isDynamicFeature", {
1209
- is: !0,
1210
- then: (e) => e.required("Enter Feature Constant"),
1211
- otherwise: (e) => e.notRequired()
1212
- }),
1213
- navigationState: O.string().when("isDynamicFeature", {
1214
- is: !1,
1215
- then: (e) => e.required("Enter Navigation State").matches(
1216
- /^(techo\.[a-zA-Z]+\.[a-zA-Z]+|medplat\.form\.[a-zA-Z_]+)$/,
1217
- "invalid format for state"
1218
- ),
1219
- otherwise: (e) => e.notRequired()
1220
- }),
1221
- menuType: O.string().required("Enter Feature Type"),
1222
- icon: O.string().when("$showMobileFields", {
1223
- is: !0,
1224
- then: (e) => e.required("Please upload an icon"),
1225
- otherwise: (e) => e.notRequired()
1226
- }),
1227
- conditions: O.string().transform((e) => e ? e.trim() : ""),
1228
- mobileMode: O.string().when("$showMobileFields", {
1229
- is: !0,
1230
- then: (e) => e.required("Please select a mode"),
1231
- otherwise: (e) => e.notRequired()
1232
- }),
1233
- trainingQuery: O.string().when("trainingRequired", {
1234
- is: !0,
1235
- then: (e) => e.required("Please select a training query"),
1236
- otherwise: (e) => e.notRequired()
1237
- }),
1238
- notificationBadgeType: O.string().when("notificationBadgeEnabled", {
1239
- is: !0,
1240
- then: (e) => e.required("Please select a badge type"),
1241
- otherwise: (e) => e.notRequired()
1242
- }),
1243
- notificationBadgeQuery: O.string().when(
1244
- ["notificationBadgeEnabled", "notificationBadgeType"],
1245
- (e, n) => {
1246
- const [i, r] = e;
1247
- return i && r ? n.required(
1248
- r === "COUNT" ? "Please select a count query" : "Please select a nudge query"
1249
- ) : n.notRequired();
1250
- }
1251
- ),
1252
- updatedFields: O.array().when(
1253
- ["isDynamicFeature", "isNew", "isUpdate", "showFields"],
1254
- (e, n) => {
1255
- const [i, r, o, u] = e;
1256
- return i === !1 && (r == null ? void 0 : r.val) === !1 && (o == null ? void 0 : o.value) === !0 && u === !0 ? n.of(
1257
- O.object().shape({
1258
- value: O.string().required("Right is required")
1259
- })
1260
- ) : n.optional();
1261
- }
1262
- )
1263
- }), a = ft({
1264
- defaultValues: {
1265
- menuName: "",
1266
- featureConstant: "",
1267
- navigationState: "medplat.form",
1268
- menuType: "",
1269
- menuGroup: "",
1270
- isDynamicFeature: !0,
1271
- isWebFeature: !1,
1272
- isMobileFeature: !1,
1273
- accessRights: [],
1274
- entityName: null,
1275
- mobileEntitiesSync: [],
1276
- icon: "",
1277
- mobileMode: null,
1278
- conditions: "",
1279
- formCode: "",
1280
- version: null,
1281
- additionalPermissions: [],
1282
- fields: [],
1283
- updatedFields: [],
1284
- trainingRequired: !1,
1285
- trainingQuery: "",
1286
- notificationBadgeEnabled: !1,
1287
- notificationBadgeType: "",
1288
- notificationBadgeQuery: ""
1289
- },
1290
- resolver: vn(ni),
1291
- mode: "onChange"
1292
- }), P = mt({
1293
- control: a.control,
1294
- name: "isDynamicFeature"
1295
- }), Wt = mt({
1296
- control: a.control,
1297
- name: "isMobileFeature"
1298
- }), qt = mt({
1299
- control: a.control,
1300
- name: "isWebFeature"
1301
- }), ii = mt({
1302
- control: a.control,
1303
- name: ai((tn = q[L]) == null ? void 0 : tn.key)
1304
- }), ri = a.watch();
1305
- function ai(e) {
1306
- switch (e) {
1307
- case "featureDetails":
1308
- return P ? ["menuName", "featureConstant", "menuType"] : ["menuName", "navigationState", "menuType"];
1309
- case "mobileConfig":
1310
- return R ? [
1311
- "icon",
1312
- "mobileMode",
1313
- "trainingRequired",
1314
- "trainingQuery",
1315
- "notificationBadgeEnabled",
1316
- "notificationBadgeType",
1317
- "notificationBadgeQuery"
1318
- ] : [];
1319
- case "formLinking":
1320
- return P ? ["formCode", "version"] : [];
1321
- case "additionalPermissions":
1322
- return !P && (l == null ? void 0 : l.val) === !1 ? ["updatedFields"] : ["additionalPermissions"];
1323
- default:
1324
- return [];
1325
- }
1326
- }
1327
- const Rt = Nn(() => {
1328
- var n;
1329
- switch ((n = q[L]) == null ? void 0 : n.key) {
1330
- case "featureDetails": {
1331
- const i = !!a.formState.errors.navigationState, r = !!a.formState.errors.featureConstant;
1332
- return a.formState.isValid && !!a.getValues("menuName") && (P ? !!a.getValues("featureConstant") && !r : !!a.getValues("navigationState") && !i) && !!a.getValues("menuType");
1333
- }
1334
- case "mobileConfig": {
1335
- if (!R) return !0;
1336
- const i = !!a.getValues("icon"), r = !!a.getValues("mobileMode"), o = a.getValues("trainingRequired"), u = a.getValues("trainingQuery"), d = a.getValues("notificationBadgeEnabled"), h = a.getValues("notificationBadgeType"), y = a.getValues("notificationBadgeQuery");
1337
- return i && r && (!o || !!u) && (!d || !!h) && (!d || !h || !!y);
1338
- }
1339
- case "formLinking": {
1340
- if (!P) return !0;
1341
- const i = a.getValues("formCode"), r = a.getValues("version");
1342
- return !!i && !!r;
1343
- }
1344
- case "additionalPermissions": {
1345
- if (!P && (l == null ? void 0 : l.val) === !1 && Te)
1346
- return (a.getValues("updatedFields") || []).every(
1347
- (o) => o.value && o.value.trim()
1348
- );
1349
- {
1350
- const i = a.getValues("additionalPermissions") || [];
1351
- return i.length > 0 && i.every(
1352
- (o) => {
1353
- var u, d, h, y;
1354
- return ((u = o.permissionId) == null ? void 0 : u.trim()) && ((d = o.permissionName) == null ? void 0 : d.trim()) && ((y = (h = o.permissionType) == null ? void 0 : h.type) == null ? void 0 : y.trim());
1355
- }
1356
- );
1357
- }
1358
- }
1359
- default:
1360
- return !0;
1361
- }
1362
- }, [
1363
- ii,
1364
- a.formState.isValid,
1365
- L,
1366
- R
1367
- ]), He = q.filter(
1368
- (e) => (e.key !== "mobileConfig" || R) && (e.key !== "formLinking" || P)
1369
- ), xt = async () => {
1370
- const e = q[L].key;
1371
- if (Xn(e)) {
1372
- Mt();
1373
- return;
1374
- }
1375
- await a.trigger(Bt(e)) && (At((i) => new Set(i).add(e)), Me((i) => i.filter((r) => r !== e)), Mt());
1376
- }, Mt = () => {
1377
- const e = q[L].key, n = He.findIndex(
1378
- (r) => r.key === e
1379
- ), i = He[n + 1];
1380
- if (i) {
1381
- i.key === "additionalPermissions" && ce.length === 0 && ci(), e === "additionalPermissions" && i.key === "assignFeatures" && We(
1382
- li(ce, Ne)
1383
- );
1384
- const r = q.findIndex(
1385
- (o) => o.key === i.key
1386
- );
1387
- Ce(r);
1388
- }
1389
- };
1390
- ae(() => {
1391
- if (D === !0) {
1392
- const e = a.getValues("mobileMode");
1393
- Zn(e);
1394
- }
1395
- }, [D, a]), ae(() => {
1396
- P ? a.setValue("navigationState", "medplat.form") : (b.get("featureId") === null && a.setValue("navigationState", ""), a.setValue("featureConstant", ""), B(""), a.clearErrors("featureConstant"));
1397
- }, [P]);
1398
- const Bt = (e) => {
1399
- switch (e) {
1400
- case "formLinking":
1401
- return ["formCode", "version"];
1402
- case "additionalPermissions":
1403
- return ["permissionId", "permissionName", "permissionType"];
1404
- default:
1405
- return [];
1406
- }
1407
- }, si = () => {
1408
- L === 0 && E("/ui/medplat/manage/menu");
1409
- const e = q[L].key, n = He.findIndex(
1410
- (r) => r.key === e
1411
- ), i = He[n - 1];
1412
- if (i) {
1413
- const r = q.findIndex(
1414
- (o) => o.key === i.key
1415
- );
1416
- Ce(r);
1417
- }
1418
- }, oi = (e) => {
1419
- const n = q[e].key;
1420
- return ei.has(n);
1421
- };
1422
- ae(() => {
1423
- (async () => {
1424
- var e;
1425
- if (await hi(), await pi(), await gi(), ht(!0), await Lt(), await yi(), await _e(), b.get("featureId") && P) {
1426
- const { data: n } = await In(b.get("featureId"));
1427
- if (n != null && n.permissions) {
1428
- const i = Ot(
1429
- n.permissions
1430
- );
1431
- if (((e = n == null ? void 0 : n.userMenuItemDtos) == null ? void 0 : e.length) > 0) {
1432
- const o = Ut(
1433
- i,
1434
- n.userMenuItemDtos
1435
- ).map((u) => ({
1436
- ...u,
1437
- permissions: St(u.permissions)
1438
- }));
1439
- We(o);
1440
- }
1441
- $e(i);
1442
- }
1443
- }
1444
- })();
1445
- }, []), ae(() => {
1446
- if (Le != null && Le.userMenuItemDtos) {
1447
- const e = a.getValues("updatedFields") || [], n = e == null ? void 0 : e.reduce((r, o) => (r[o.name] = o.enabled, r), {}), i = Le.userMenuItemDtos.map((r) => {
1448
- let o = {};
1449
- try {
1450
- o = r.featureJson ? JSON.parse(r.featureJson) : {};
1451
- } catch (d) {
1452
- console.warn("Invalid JSON in featureJson:", d);
1453
- }
1454
- const u = {
1455
- ...n,
1456
- ...o
1457
- };
1458
- return {
1459
- ...r,
1460
- featureJson: JSON.stringify(u)
1461
- };
1462
- });
1463
- ze(i);
1464
- }
1465
- }, [Le]), ae(() => {
1466
- try {
1467
- const e = b.get("featureId");
1468
- if (b.get("featureType") && e) {
1469
- const i = async () => {
1470
- var r;
1471
- if (l != null && l.val) {
1472
- const { data: o } = await In(e);
1473
- if (Vt(!0), await zt(), o != null && o.permissions) {
1474
- const u = Ot(
1475
- o.permissions
1476
- );
1477
- if (((r = o == null ? void 0 : o.userMenuItemDtos) == null ? void 0 : r.length) > 0) {
1478
- const h = Ut(
1479
- u,
1480
- o.userMenuItemDtos
1481
- ).map((y) => ({
1482
- ...y,
1483
- permissions: St(y.permissions)
1484
- }));
1485
- We(h);
1486
- }
1487
- $e(u);
1488
- }
1489
- Dt((u) => ({ ...u, value: !0, length: 0 }));
1490
- } else {
1491
- const { data: o } = await ur(e);
1492
- Mn(o), await zt();
1493
- const u = JSON.parse(o.featureJson || "{}"), d = Object.keys(u).map((h, y) => ({
1494
- id: y + 1,
1495
- value: h,
1496
- checkbox: u[h],
1497
- updated: !0
1498
- }));
1499
- a.setValue("updatedFields", d), at(d.length > 0), d.length > 0 && Vt(!0), Dt((h) => ({ ...h, value: !0, length: u.length || 0 })), Jn(o == null ? void 0 : o.isSeparateFeature);
1500
- }
1501
- };
1502
- Ct(), i();
1503
- }
1504
- } catch (e) {
1505
- me({
1506
- type: "error",
1507
- message: `error :${e == null ? void 0 : e.message}`
1508
- });
1509
- }
1510
- }, [b, a.setValue, ve, j]);
1511
- const Ot = (e) => {
1512
- const n = a.getValues("menuType"), i = a.getValues("featureConstant"), r = (d) => d.trim().toLowerCase().split(/\s+/).map(
1513
- (h, y) => y === 0 ? h : h.charAt(0).toUpperCase() + h.slice(1)
1514
- ).join("");
1515
- let o;
1516
- if (!P || (i == null ? void 0 : i.length) === 0) {
1517
- const d = a.getValues("menuName");
1518
- o = `view.${n}.${r(d)}`;
1519
- } else
1520
- o = `view.${n}.${i}`;
1521
- const u = (d) => {
1522
- const h = d.id === o;
1523
- return {
1524
- permissionId: d.id,
1525
- permissionType: { type: d.type },
1526
- permissionName: d.name,
1527
- permissionDesc: d.desc || "",
1528
- enabled: d.is_active,
1529
- isDefault: h,
1530
- childPermissions: d.child ? d.child.map((y) => u(y)) : [],
1531
- urlType: (d == null ? void 0 : d.httpMethod) || "",
1532
- backendUrl: (d == null ? void 0 : d.url) || "",
1533
- queryCodeRequired: !(d != null && d.url),
1534
- queryCode: (d == null ? void 0 : d.queryCodes) || ""
1535
- };
1536
- };
1537
- return e.map(u);
1538
- }, Ut = (e, n) => {
1539
- if (!Array.isArray(n)) return [];
1540
- const i = (r, o) => {
1541
- var y;
1542
- const u = ((y = r.childPermissions) == null ? void 0 : y.map(
1543
- (F) => i(F, o)
1544
- )) || [], d = u.some((F) => F.enabled), h = o.includes(r.permissionId) || d;
1545
- return { ...r, enabled: h, childPermissions: u };
1546
- };
1547
- return n.map((r) => {
1548
- var y, F, k, ue, X, se, oe;
1549
- const o = ((y = r.permissions) == null ? void 0 : y.map((Nt) => Nt.id)) || [], u = !!r.roleName || !!r.designationId || !!r.roleId, d = !!r.userId || !!r.fullName, h = e.map(
1550
- (Nt) => i(Nt, o)
1551
- );
1552
- return {
1553
- entityType: u ? "role" : "user",
1554
- user_id: d && r.userId || null,
1555
- role_id: u && (r.designationId || r.roleId) || null,
1556
- name: d ? r.fullName || "" : r.roleName || "",
1557
- startDate: ((k = (F = r.permissions) == null ? void 0 : F[0]) == null ? void 0 : k.startDate) || null,
1558
- endDate: ((X = (ue = r.permissions) == null ? void 0 : ue[0]) == null ? void 0 : X.endDate) || null,
1559
- isBackendOnly: ((oe = (se = r.permissions) == null ? void 0 : se[0]) == null ? void 0 : oe.isBackendOnly) || !1,
1560
- permissions: h
1561
- };
1562
- });
1563
- }, St = (e) => {
1564
- const n = (i) => {
1565
- var o, u;
1566
- let r = [];
1567
- if ((o = i.childPermissions) != null && o.length) {
1568
- r = i.childPermissions.map(n);
1569
- const d = r.every((h) => h.enabled);
1570
- i.enabled = i.enabled || d;
1571
- }
1572
- return i.enabled && ((u = i.childPermissions) != null && u.length) && (r = r.map((d) => {
1573
- var h;
1574
- return {
1575
- ...d,
1576
- enabled: !0,
1577
- childPermissions: (h = d.childPermissions) != null && h.length ? St(d.childPermissions) : []
1578
- };
1579
- })), {
1580
- ...i,
1581
- childPermissions: r
1582
- };
1583
- };
1584
- return e.map(n);
1585
- }, li = (e, n) => {
1586
- const i = /* @__PURE__ */ new Map(), r = (u) => {
1587
- u.forEach((d) => {
1588
- var h;
1589
- i.set(d.permissionId, d), (h = d.childPermissions) != null && h.length && r(d.childPermissions);
1590
- });
1591
- };
1592
- r(e);
1593
- const o = (u, d) => u.map((h) => {
1594
- const y = (d == null ? void 0 : d.find((k) => k.permissionId === h.permissionId)) || {}, F = o(
1595
- h.childPermissions || [],
1596
- y.childPermissions || []
1597
- );
1598
- return {
1599
- ...h,
1600
- enabled: y.enabled ?? h.enabled,
1601
- childPermissions: F
1602
- };
1603
- });
1604
- return n.map((u) => ({
1605
- ...u,
1606
- permissions: o(e, u.permissions)
1607
- }));
1608
- }, di = async () => {
1609
- try {
1610
- const e = (await G({
1611
- code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1612
- parameters: {
1613
- id: parseInt(b.get("featureId")),
1614
- menuType: b.get("featureType")
1615
- }
1616
- })).data;
1617
- if (e.result) {
1618
- let n = e.result[0];
1619
- const i = (() => {
1620
- try {
1621
- return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1622
- } catch {
1623
- return {};
1624
- }
1625
- })(), o = ((i == null ? void 0 : i.mobile_entities_sync) ?? []).map(
1626
- (h) => Z == null ? void 0 : Z.find((y) => y.tableName === h)
1627
- ).filter(Boolean);
1628
- a.reset({
1629
- menuName: n.menuName ? n.menuName : "",
1630
- featureConstant: n.featureConstant ? n.featureConstant : "",
1631
- navigationState: n.navigationState ? n.navigationState : "medplat.form",
1632
- isDynamicFeature: n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1,
1633
- menuType: n.menuType ? n.menuType : "",
1634
- menuGroup: n.group_id ? n.group_id.toString() : "",
1635
- isWebFeature: n.isWebFeature ? n.isWebFeature : !1,
1636
- isMobileFeature: n.isMobileFeature ? n.isMobileFeature : !1,
1637
- entityName: (i == null ? void 0 : i.entity_name) ?? "",
1638
- mobileMode: (i == null ? void 0 : i.mobile_mode) ?? null,
1639
- icon: (i == null ? void 0 : i.icon) ?? "",
1640
- mobileEntitiesSync: i != null && i.mobile_entities_sync ? i.mobile_entities_sync : [],
1641
- conditions: (i == null ? void 0 : i.conditions) ?? "",
1642
- formCode: n.formCode ? n.formCode : "",
1643
- version: n.currentVersion ? n.currentVersion : "",
1644
- trainingRequired: (i == null ? void 0 : i.training_required) ?? !1,
1645
- trainingQuery: (i == null ? void 0 : i.training_query) ?? "",
1646
- notificationBadgeEnabled: (i == null ? void 0 : i.notification_badge_enabled) ?? !1,
1647
- notificationBadgeType: (i == null ? void 0 : i.notification_badge_type) ?? "",
1648
- notificationBadgeQuery: (i == null ? void 0 : i.notification_badge_query) ?? ""
1649
- }), re(o), n.isMobileFeature && W(!0);
1650
- const u = (i == null ? void 0 : i.training_query) ?? "", d = (i == null ? void 0 : i.notification_badge_query) ?? "";
1651
- u && (je(u), _e(u)), d && (Ge(d), _e(d)), n.formCode && (ye(n.formCode), Pe(n.formCode)), Ct(), Ke(!0);
1652
- }
1653
- } catch (e) {
1654
- me({
1655
- message: e.message,
1656
- type: "error"
1657
- });
1658
- }
1659
- }, zt = async () => {
1660
- try {
1661
- const e = (await G({
1662
- code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1663
- parameters: {
1664
- id: parseInt(b.get("featureId")),
1665
- menuType: b.get("featureType")
1666
- }
1667
- })).data;
1668
- if (e.result) {
1669
- let n = e.result[0];
1670
- const i = (() => {
1671
- try {
1672
- return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1673
- } catch {
1674
- return {};
1675
- }
1676
- })(), r = (y, F = null) => {
1677
- try {
1678
- return !y || typeof y != "string" ? F : JSON.parse(y);
1679
- } catch {
1680
- return F;
1681
- }
1682
- }, u = ((i == null ? void 0 : i.mobile_entities_sync) ?? []).map(
1683
- (y) => Z == null ? void 0 : Z.find((F) => F.tableName === y)
1684
- ).filter(Boolean);
1685
- a.setValue("menuName", n.menuName ? n.menuName : ""), a.setValue(
1686
- "navigationState",
1687
- n.navigationState ? n.navigationState : ""
1688
- ), a.setValue(
1689
- "isDynamicFeature",
1690
- n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1
1691
- ), a.setValue("menuType", n.menuType ? n.menuType : ""), a.setValue(
1692
- "menuGroup",
1693
- n.group_id ? n.group_id.toString() : ""
1694
- ), a.setValue(
1695
- "isWebFeature",
1696
- n.isWebFeature ? n.isWebFeature : !1
1697
- ), a.setValue(
1698
- "isMobileFeature",
1699
- n.isMobileFeature ? n.isMobileFeature : !1
1700
- ), a.setValue("entityName", (i == null ? void 0 : i.entity_name) ?? ""), a.setValue("mobileMode", (i == null ? void 0 : i.mobile_mode) ?? null), a.setValue("icon", (i == null ? void 0 : i.icon) ?? ""), a.setValue(
1701
- "mobileEntitiesSync",
1702
- (i == null ? void 0 : i.mobile_entities_sync) ?? []
1703
- ), a.setValue("conditions", (i == null ? void 0 : i.conditions) ?? ""), a.setValue(
1704
- "trainingRequired",
1705
- (i == null ? void 0 : i.training_required) ?? !1
1706
- ), a.setValue("trainingQuery", (i == null ? void 0 : i.training_query) ?? ""), a.setValue(
1707
- "notificationBadgeEnabled",
1708
- (i == null ? void 0 : i.notification_badge_enabled) ?? !1
1709
- ), a.setValue(
1710
- "notificationBadgeType",
1711
- (i == null ? void 0 : i.notification_badge_type) ?? ""
1712
- ), a.setValue(
1713
- "notificationBadgeQuery",
1714
- (i == null ? void 0 : i.notification_badge_query) ?? ""
1715
- ), re(u), n.isMobileFeature && W(!0);
1716
- const d = (i == null ? void 0 : i.training_query) ?? "", h = (i == null ? void 0 : i.notification_badge_query) ?? "";
1717
- d && (je(d), _e(d)), h && (Ge(h), _e(h)), Ke(!0);
1718
- }
1719
- } catch (e) {
1720
- me({
1721
- message: e.message,
1722
- type: "error"
1723
- });
1724
- }
1725
- }, ci = () => {
1726
- const e = a.getValues("menuType") || "menuType", n = a.getValues("featureConstant") || "feature", i = (u) => u.trim().toLowerCase().split(/\s+/).map(
1727
- (d, h) => h === 0 ? d : d.charAt(0).toUpperCase() + d.slice(1)
1728
- ).join("");
1729
- let r;
1730
- if (P)
1731
- r = `view.${e}.${n}`;
1732
- else {
1733
- const u = a.getValues("menuName");
1734
- r = `view.${e}.${i(u)}`;
1735
- }
1736
- const o = {
1737
- permissionId: r,
1738
- permissionType: { type: "menu" },
1739
- permissionName: `view ${n}`,
1740
- permissionDesc: "",
1741
- enabled: !0,
1742
- isDefault: !0,
1743
- childPermissions: [],
1744
- ...P === !1 && {
1745
- backendUrl: "",
1746
- urlType: "",
1747
- queryCode: ""
1748
- }
1749
- };
1750
- $e([o]);
1751
- }, ui = (e) => {
1752
- w(e);
1753
- }, mi = (e) => {
1754
- const n = (e == null ? void 0 : e.map((i) => i == null ? void 0 : i.tableName)) || [];
1755
- re(e), a.setValue("mobileEntitiesSync", n);
1756
- }, fi = (e, n) => {
1757
- Fe(n);
1758
- };
1759
- ae(() => {
1760
- const e = (b == null ? void 0 : b.get("staticOrDynamic")) === "STATIC";
1761
- ve && j && b.get("featureId") && !e && di();
1762
- }, [ve, j]);
1763
- const hi = async () => {
1764
- const e = (await G({
1765
- code: "fetch_menu_groups"
1766
- })).data;
1767
- Ze(e.result.map((n) => n.menu_type)), V(e.result);
1768
- }, pi = async () => {
1769
- const e = (await G({
1770
- code: "mfa_retreive_all_table_names"
1771
- })).data;
1772
- de(e.result.map((n) => n.table_name));
1773
- }, gi = async () => {
1774
- const e = (await G({
1775
- code: "retrieve_synced_tables"
1776
- })).data;
1777
- z(e == null ? void 0 : e.result);
1778
- }, Lt = async () => {
1779
- const e = (await G({
1780
- code: "mfa_retrieve_separate_feature_forms"
1781
- })).data;
1782
- if (e.result) {
1783
- let n = e.result;
1784
- Q(n);
1785
- let i = {};
1786
- return n.forEach((r) => {
1787
- try {
1788
- const o = JSON.parse(r.versions);
1789
- i[r.form_code] = o;
1790
- } catch (o) {
1791
- console.error("Invalid JSON in form.versions:", r.versions, o), i[r.form_code] = [];
1792
- }
1793
- }), pe(i), i;
1794
- }
1795
- }, yi = async () => {
1796
- try {
1797
- const { data: e } = await G({
1798
- code: "user_search_for_selectize",
1799
- parameters: {
1800
- searchString: ""
1801
- }
1802
- });
1803
- Oe(e == null ? void 0 : e.result);
1804
- const n = await $i();
1805
- p(n.data);
1806
- } catch (e) {
1807
- console.error("Error fetching users or roles:", e);
1808
- }
1809
- }, _e = async (e = "") => {
1810
- try {
1811
- const n = (await G({
1812
- code: "GET_ALL_QUERY_CODE",
1813
- parameters: { search: e }
1814
- })).data;
1815
- Hn((n == null ? void 0 : n.result) || []);
1816
- } catch (n) {
1817
- console.error("Error fetching query codes:", n);
1818
- }
1819
- }, $t = () => a.getValues("isMobileFeature") && a.getValues("isWebFeature") ? be : be.filter((e) => {
1820
- const { roleType: n } = e;
1821
- return !!(n === null || a.getValues("isMobileFeature") && (n === "MOBILE" || n === "BOTH") || a.getValues("isWebFeature") && (n === "WEB" || n === "BOTH"));
1822
- });
1823
- ae(() => {
1824
- if (!(be != null && be.length)) return;
1825
- const e = Ue.filter((n) => {
1826
- if (!n.roleName) return !0;
1827
- const i = be.find((o) => o.name === n.roleName);
1828
- if (!i) return !0;
1829
- const { roleType: r } = i;
1830
- return !(!Wt && r === "MOBILE" || !qt && r === "WEB");
1831
- });
1832
- ze(e);
1833
- }, [Wt, qt, be]);
1834
- const bi = (e) => {
1835
- const { firstName: n, lastName: i, userName: r } = e;
1836
- return !n && !i && !r ? "" : n && !i && !r ? n : `${n} ${i} (${r})`;
1837
- }, Ct = () => {
1838
- ie(() => {
1839
- const e = a.getValues("menuType") ? JSON.parse(
1840
- j == null ? void 0 : j.find(
1841
- (i) => i.menu_type === a.getValues("menuType")
1842
- ).groupNames
1843
- ) : null, n = e == null ? void 0 : e.filter((i) => i.id !== null);
1844
- return n != null && n.length || a.setValue("menuGroup", ""), n;
1845
- });
1846
- }, xi = (e) => {
1847
- a.setValue("menuGroup", e.target.value);
1848
- }, Si = (e) => {
1849
- e.target.checked ? W(!0) : (W(!1), a.setValue("entityName", null), a.setValue("icon", null), a.setValue("mobileEntitiesSync", null), a.setValue("conditions", null), a.setValue("mobileMode", null));
1850
- }, Ci = (e) => {
1851
- e.target.checked || (a.setValue("formCode", null), a.setValue("version", null));
1852
- }, Ni = () => {
1853
- tt("add-parent"), nt(null), it(null), rt(null), Qe(!0);
1854
- }, ki = (e) => {
1855
- tt("add-child"), nt(e.permissionId), it(null), rt(null), Qe(!0);
1856
- }, Ii = (e) => {
1857
- tt("edit"), nt(null), it(e), rt(e.permissionId), Qe(!0);
1858
- }, Qt = (e, n, i) => e.map((r) => r.permissionId === n ? {
1859
- ...r,
1860
- childPermissions: [...r.childPermissions || [], i]
1861
- } : {
1862
- ...r,
1863
- childPermissions: Qt(
1864
- r.childPermissions || [],
1865
- n,
1866
- i
1867
- )
1868
- }), Jt = (e, n, i) => e.map((r) => r.permissionId === n ? {
1869
- ...i,
1870
- childPermissions: r.childPermissions || []
1871
- } : {
1872
- ...r,
1873
- childPermissions: Jt(
1874
- r.childPermissions || [],
1875
- n,
1876
- i
1877
- )
1878
- }), jt = (e, n) => e.filter((i) => i.permissionId !== n).map((i) => ({
1879
- ...i,
1880
- childPermissions: jt(
1881
- i.childPermissions || [],
1882
- n
1883
- )
1884
- })), wi = (e) => {
1885
- $e((n) => {
1886
- let i = [...n];
1887
- if (Je === "add-parent")
1888
- i = [...n, e];
1889
- else if (Je === "add-child") {
1890
- const r = (d, h) => {
1891
- var y;
1892
- for (const F of d) {
1893
- if (F.permissionId === h) return F;
1894
- if ((y = F.childPermissions) != null && y.length) {
1895
- const k = r(F.childPermissions, h);
1896
- if (k) return k;
1897
- }
1898
- }
1899
- return null;
1900
- }, o = r(n, pt), u = {
1901
- ...e,
1902
- permissionType: typeof o.permissionType == "string" ? { type: o.permissionType } : o.permissionType
1903
- };
1904
- i = Qt(
1905
- n,
1906
- pt,
1907
- u
1908
- );
1909
- } else Je === "edit" && (i = Jt(
1910
- n,
1911
- Un,
1912
- e
1913
- ));
1914
- return i;
1915
- }), Qe(!1), tt("add-parent"), nt(null), it(null), rt(null);
1916
- }, vi = (e) => {
1917
- const n = typeof e == "string" ? e : e.permissionId;
1918
- $e((i) => jt(i, n));
1919
- };
1920
- ae(() => {
1921
- a.setValue("additionalPermissions", ce);
1922
- }, [ce, a]);
1923
- const st = (e, n = null) => {
1924
- let i = [];
1925
- return e.forEach((r) => {
1926
- const {
1927
- permissionId: o,
1928
- permissionType: u,
1929
- permissionName: d,
1930
- permissionDesc: h,
1931
- enabled: y,
1932
- backendUrl: F,
1933
- urlType: k,
1934
- queryCode: ue
1935
- } = r;
1936
- i.push({
1937
- permissionId: o,
1938
- permissionType: u == null ? void 0 : u.type,
1939
- permissionName: d,
1940
- permissionDesc: h,
1941
- parentPermissionId: n,
1942
- enabled: y,
1943
- backendUrl: F,
1944
- urlType: k,
1945
- queryCode: ue
1946
- }), r.childPermissions && r.childPermissions.length > 0 && (i = i.concat(
1947
- st(r.childPermissions, o)
1948
- ));
1949
- }), i;
1950
- }, Fi = () => {
1951
- (async () => {
1952
- let e = await Lt();
1953
- pe(e), ye(a.getValues("formCode"));
1954
- })();
1955
- }, Gt = JSON.stringify(
1956
- (nn = K.value ? a.getValues("updatedFields") : a.getValues("fields")) == null ? void 0 : nn.reduce((e, n) => {
1957
- var i;
1958
- return (i = n.value) != null && i.trim() && (e[n.value.trim()] = n.checkbox), e;
1959
- }, {})
1960
- ), Ti = () => {
1961
- if (!P && (l == null ? void 0 : l.val) === !1)
1962
- try {
1963
- const e = [];
1964
- _ != null && _.id && e.push({
1965
- designationId: null,
1966
- userId: _.id,
1967
- fullName: `${_.firstName || ""} ${_.lastName || ""}`.trim(),
1968
- featureJson: Gt
1969
- }), (g == null ? void 0 : g.length) > 0 && e.push(
1970
- ...g.map((n) => ({
1971
- designationId: n.id,
1972
- roleName: n.name,
1973
- featureJson: Gt
1974
- }))
1975
- ), ze((n) => [...n, ...e]), me({
1976
- message: "Menu item added successfully",
1977
- type: "success"
1978
- }), w([]), Fe({});
1979
- } catch (e) {
1980
- console.error(e), me({
1981
- message: "Cannot add menu item",
1982
- type: "error"
1983
- });
1984
- }
1985
- else {
1986
- const e = [];
1987
- if (_ != null && _.id && e.push({
1988
- type: "user",
1989
- id: _.id,
1990
- name: _.firstName + " " + _.lastName
1991
- }), g.length > 0 && e.push({
1992
- type: "role",
1993
- ids: g.map((n) => n.id),
1994
- names: g.map((n) => n.name)
1995
- }), e.length === 0) return;
1996
- $n(e), gt(!0), Fe(null), w([]);
1997
- }
1998
- }, Ht = (e) => {
1999
- const n = [], i = (r, o) => {
2000
- for (const u of r)
2001
- u.enabled && n.push({
2002
- permission_id: u.permissionId,
2003
- user_id: o.user_id || null,
2004
- role_id: o.role_id || null,
2005
- is_backend_only: o.isBackendOnly || !1,
2006
- start_date: o.startDate || null,
2007
- end_date: o.endDate || null
2008
- });
2009
- };
2010
- for (const r of e)
2011
- i(r.permissions || [], r);
2012
- return n;
2013
- }, _i = (e, n) => {
2014
- We((i) => {
2015
- const r = [...i];
2016
- return r[e] = {
2017
- ...r[e],
2018
- permissions: Yt(
2019
- r[e].permissions,
2020
- n.permissionId,
2021
- !n.enabled
2022
- )
2023
- }, r;
2024
- });
2025
- }, Yt = (e, n, i) => e.map((o) => {
2026
- var u, d;
2027
- if (o.permissionId === n)
2028
- return {
2029
- ...o,
2030
- enabled: i,
2031
- childPermissions: (u = o.childPermissions) != null && u.length ? Kt(o.childPermissions, i) : []
2032
- };
2033
- if ((d = o.childPermissions) != null && d.length) {
2034
- const h = Yt(
2035
- o.childPermissions,
2036
- n,
2037
- i
2038
- ), y = h.length > 0 && h.every((F) => F.enabled === !0);
2039
- return {
2040
- ...o,
2041
- enabled: y,
2042
- childPermissions: h
2043
- };
2044
- }
2045
- return o;
2046
- }), Kt = (e, n) => e.map((i) => {
2047
- var r;
2048
- return {
2049
- ...i,
2050
- enabled: n,
2051
- childPermissions: (r = i.childPermissions) != null && r.length ? Kt(i.childPermissions, n) : []
2052
- };
2053
- }), Vi = async (e) => {
2054
- (await G({
2055
- code: "check_unique_feature_constant",
2056
- parameters: {
2057
- featureConstant: e
2058
- }
2059
- })).data.result[0].exists ? a.setError("featureConstant", {
2060
- type: "manual",
2061
- message: "Feature constant already exists"
2062
- }) : B(`${e} Feature constant is available`);
2063
- }, Ei = async (e) => {
2064
- (await G({
2065
- code: "CHECK_UNIQUE_NAVIGATION_STATE",
2066
- parameters: {
2067
- featureState: e
2068
- }
2069
- })).data.result[0].exists ? a.setError("navigationState", {
2070
- type: "manual",
2071
- message: "Feature State already exists"
2072
- }) : B(`${e} Feature State is available`);
2073
- }, Di = fn(Vi, 500), Pi = fn(
2074
- Ei,
2075
- 500
2076
- ), Zt = Gi(
2077
- async (e, n, i) => {
2078
- const { data: r } = await G({
2079
- code: "user_search_for_selectize",
2080
- parameters: {
2081
- searchString: e
2082
- }
2083
- });
2084
- n(r.result), i({ firstName: e, lastName: "", userName: "" });
2085
- },
2086
- 500
2087
- ), Ai = async (e) => {
2088
- const n = st(ce);
2089
- let i = {
2090
- code: "insert_dynamic_feature_into_menu_config",
2091
- parameters: {
2092
- menuName: e.menuName ? e.menuName : null,
2093
- featureConstant: e.featureConstant ? e.featureConstant : null,
2094
- formCode: e.formCode && e.formCode !== "" ? e.formCode : null,
2095
- prevFormCode: we || null,
2096
- deLinkPrevForm: we !== e.formCode,
2097
- menuType: e.menuType ? e.menuType : null,
2098
- menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2099
- navigationState: e.navigationState && e.formCode && e.formCode !== "" ? e.navigationState : null,
2100
- formVersion: e.version ? e.version : null,
2101
- isMobileFeature: e.isMobileFeature ? e.isMobileFeature : null,
2102
- isWebFeature: e.isWebFeature ? e.isWebFeature : null,
2103
- permissions: JSON.stringify(n),
2104
- mobileConfig: JSON.stringify({
2105
- entity_name: e.entityName ?? null,
2106
- mobile_mode: e.mobileMode ? e.mobileMode.toUpperCase() : null,
2107
- icon: e.icon ?? null,
2108
- mobile_entities_sync: e.mobileEntitiesSync ?? [],
2109
- conditions: e.conditions ?? null,
2110
- training_required: e.trainingRequired ?? !1,
2111
- training_query: e.trainingQuery ?? null,
2112
- notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2113
- notification_badge_type: e.notificationBadgeType ?? null,
2114
- notification_badge_query: e.notificationBadgeQuery ?? null
2115
- })
2116
- }
2117
- };
2118
- try {
2119
- if (await G(i)) {
2120
- let o = [];
2121
- e.menuName && e.menuName.length > 0 && o.push({
2122
- code: "medplat_form_insert_into_translation_master",
2123
- parameters: {
2124
- translation_key: e.menuName.replaceAll(" ", ""),
2125
- translation_value: e.menuName,
2126
- form_code: "General"
2127
- },
2128
- sequence: 1
2129
- }), o.length > 0 && await Ft(o);
2130
- const u = Ht(Ne);
2131
- u && await G({
2132
- code: "GRANT_PERMISSION_USER_MAP",
2133
- parameters: {
2134
- permissionUserMap: JSON.stringify(u)
2135
- }
2136
- });
2137
- }
2138
- me({
2139
- message: b.get("featureId") ? "Feature updated successfully" : "New Dynamic feature created successfully!",
2140
- type: "success"
2141
- }), Xe(!0);
2142
- } catch (r) {
2143
- me({
2144
- message: r.message,
2145
- type: "error"
2146
- });
2147
- }
2148
- }, Wi = async (e) => {
2149
- var n, i, r, o;
2150
- try {
2151
- let u = null, d = null, h = null;
2152
- const y = hn();
2153
- (n = e == null ? void 0 : e.menuGroup) != null && n.length && (u = hn());
2154
- const F = st(ce), k = {
2155
- code: "insert_menu_config",
2156
- parameters: {
2157
- UUID: y,
2158
- featureJson: null,
2159
- menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2160
- groupUUID: u,
2161
- menuName: e.menuName ? e.menuName : null,
2162
- menuType: e.menuType ? e.menuType : null,
2163
- navigationState: e.navigationState ? e.navigationState : null,
2164
- subgroupId: d,
2165
- subgroupUUID: h,
2166
- isMobileFeature: e != null && e.isMobileFeature ? e == null ? void 0 : e.isMobileFeature : null,
2167
- isWebFeature: e != null && e.isWebFeature ? e == null ? void 0 : e.isWebFeature : null,
2168
- permissions: JSON.stringify(F),
2169
- isNewFeature: "true",
2170
- mobileConfig: JSON.stringify({
2171
- entity_name: (e == null ? void 0 : e.entityName) ?? null,
2172
- mobile_mode: e != null && e.mobileMode ? e == null ? void 0 : e.mobileMode.toUpperCase() : null,
2173
- icon: (e == null ? void 0 : e.icon) ?? null,
2174
- mobile_entities_sync: (e == null ? void 0 : e.mobileEntitiesSync) ?? [],
2175
- conditions: (e == null ? void 0 : e.conditions) ?? null,
2176
- training_required: e.trainingRequired ?? !1,
2177
- training_query: e.trainingQuery ?? null,
2178
- notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2179
- notification_badge_type: e.notificationBadgeType ?? null,
2180
- notification_badge_query: e.notificationBadgeQuery ?? null
2181
- })
2182
- }
2183
- };
2184
- if (K.value && (l == null ? void 0 : l.val) === !1) {
2185
- k.code = "update_menu_config";
2186
- const { fields: X, updatedFields: se } = e, oe = K.value && Te ? en(se) : (i = X[0]) != null && i.value && Te ? en(X) : {};
2187
- a.setValue("featureJson", oe), delete k.parameters.UUID, delete k.parameters.groupUUID, delete k.parameters.subgroupUUID, delete k.parameters.permissions, delete k.parameters.isNewFeature, k.parameters.featureType = b.get("featureType"), k.parameters.featureId = b.get("featureId"), k.parameters.featureJson = oe;
2188
- }
2189
- let ue;
2190
- if (K.value && (l == null ? void 0 : l.val) === !1) {
2191
- const { data: X } = await Qi(k);
2192
- ue = X, await mr((r = X == null ? void 0 : X.result[0]) == null ? void 0 : r.id, Ue);
2193
- } else {
2194
- K.value && (delete k.parameters.UUID, delete k.parameters.groupUUID, delete k.parameters.subgroupUUID, delete k.parameters.isNewFeature, k.parameters.featureType = b.get("featureType"), k.parameters.featureId = b.get("featureId"));
2195
- const { data: X } = await G(k);
2196
- if (ue = X, X) {
2197
- let se = [];
2198
- e.menuName && e.menuName.length > 0 && se.push({
2199
- code: "medplat_form_insert_into_translation_master",
2200
- parameters: {
2201
- translation_key: e.menuName.replaceAll(" ", ""),
2202
- translation_value: e.menuName,
2203
- form_code: "General"
2204
- },
2205
- sequence: 1
2206
- }), se.length > 0 && await Ft(se);
2207
- const oe = Ht(Ne);
2208
- oe && await G({
2209
- code: "GRANT_PERMISSION_USER_MAP",
2210
- parameters: {
2211
- permissionUserMap: JSON.stringify(oe)
2212
- }
2213
- });
2214
- }
2215
- }
2216
- (o = ue == null ? void 0 : ue.result) != null && o.length ? me({
2217
- message: K.value ? "FEATURE EDITED SUCCESFULLY" : "FEATURE ADDED SUCCESFULLY",
2218
- type: "success"
2219
- }) : me({
2220
- message: "FEATURE CONFIGURATION ALREADY EXISTS ",
2221
- type: "error"
2222
- }), Xe(!0);
2223
- } catch (u) {
2224
- me({
2225
- message: u.message,
2226
- type: "error"
2227
- });
2228
- }
2229
- }, Xt = async (e) => {
2230
- P ? Ai(e) : Wi(e);
2231
- }, en = (e) => JSON.stringify(
2232
- e == null ? void 0 : e.reduce((n, i) => (n[i.value] = i.checkbox, n), {})
2233
- ), qi = (e, n) => {
2234
- e && e.type === "change" && Ri(n);
2235
- }, Ri = rr(
2236
- (e) => {
2237
- Zt(e, Oe, Fe);
2238
- },
2239
- [Zt]
2240
- ), Mi = () => {
2241
- at(!Te), Te || (K.value ? a.setValue("updatedFields", [
2242
- { id: 1, value: "", checkbox: !1 }
2243
- ]) : a.setValue("fields", [{ id: 1, value: "", checkbox: !1 }]));
2244
- }, Bi = (e) => {
2245
- const i = (K.value ? a.getValues("updatedFields") : a.getValues("fields")).map((r) => r.id === e ? { ...r, checkbox: !r.checkbox } : r);
2246
- K.value ? a.setValue("updatedFields", i) : a.setValue("fields", i);
2247
- }, Oi = () => {
2248
- const e = K.value ? a.getValues("updatedFields") : a.getValues("fields"), n = e[(e == null ? void 0 : e.length) - 1];
2249
- if ((n == null ? void 0 : n.value.trim()) === "") {
2250
- alert("Enter the right name before adding a new one.");
2251
- return;
2252
- }
2253
- const i = {
2254
- id: e.length + 1,
2255
- value: "",
2256
- checkbox: !1
2257
- };
2258
- K.value ? a.setValue("updatedFields", [...e, i]) : a.setValue("fields", [...e, i]);
2259
- }, Ui = (e) => {
2260
- const i = (K.value ? a.getValues("updatedFields") : a.getValues("fields")).filter((r) => r.id !== e);
2261
- K.value ? a.setValue("updatedFields", i) : a.setValue("fields", i), (i == null ? void 0 : i.length) === 0 && (K.value ? at(!0) : at(!1));
2262
- };
2263
- return /* @__PURE__ */ t(
2264
- "form",
2265
- {
2266
- noValidate: !0,
2267
- ref: M,
2268
- onSubmit: a.handleSubmit(Xt),
2269
- method: "POST",
2270
- children: /* @__PURE__ */ t(c, { sx: { width: "100%", p: 3, borderRadius: 2 }, children: /* @__PURE__ */ s(c, { sx: { display: "flex" }, children: [
2271
- /* @__PURE__ */ t(
2272
- c,
2273
- {
2274
- sx: {
2275
- width: "30%",
2276
- maxHeight: "87vh",
2277
- background: `linear-gradient(to right, ${C.palette.custom.featureList || "#3576BA"}, ${C.palette.custom.black2 || "#1C2128"})`,
2278
- p: 3,
2279
- borderTopLeftRadius: 16,
2280
- borderBottomLeftRadius: 16,
2281
- borderTopRightRadius: 0,
2282
- borderBottomRightRadius: 0,
2283
- display: "flex",
2284
- flexDirection: "column",
2285
- justifyContent: "center",
2286
- gap: 5
2287
- },
2288
- children: q.map((e, n) => {
2289
- const i = n === L, r = oi(n), o = He.some((F) => F.key === e.key) && !r && !i, u = !o && !r && !i;
2290
- let d = "transparent", h = "2px solid rgba(255,255,255,0.5)", y = "white";
2291
- return i ? (d = "#BEE2FD", y = "#1e3a8a", h = "2px solid #BEE2FD") : r ? (d = "white", y = "#4caf50", h = "2px solid #4caf50") : o ? (d = "transparent", y = "white", h = "2px solid #BEE2FD") : u && (d = "transparent", y = "rgba(255,255,255,0.5)", h = "2px solid rgba(255,255,255,0.2)"), /* @__PURE__ */ t(Hi, { sx: { p: 0, m: 0 }, children: /* @__PURE__ */ s(
2292
- c,
2293
- {
2294
- sx: {
2295
- display: "flex",
2296
- alignItems: "center",
2297
- position: "relative",
2298
- backgroundColor: i ? "custom.gray3" : "transparent",
2299
- px: 1,
2300
- py: 1,
2301
- transition: "all 0.3s ease",
2302
- borderRadius: 2,
2303
- minHeight: 64
2304
- },
2305
- children: [
2306
- n < (q == null ? void 0 : q.length) - 1 && /* @__PURE__ */ t(
2307
- c,
2308
- {
2309
- sx: {
2310
- position: "absolute",
2311
- top: "45%",
2312
- left: 22,
2313
- height: "calc(100% + -10px)",
2314
- width: 2,
2315
- backgroundColor: "white",
2316
- opacity: u ? 0.3 : 1,
2317
- zIndex: 0,
2318
- transform: "translateY(50%)"
2319
- }
2320
- }
2321
- ),
2322
- /* @__PURE__ */ t(
2323
- c,
2324
- {
2325
- sx: {
2326
- width: 32,
2327
- height: 32,
2328
- borderRadius: "50%",
2329
- backgroundColor: d,
2330
- border: h,
2331
- color: y,
2332
- fontWeight: "bold",
2333
- fontSize: 14,
2334
- display: "flex",
2335
- alignItems: "center",
2336
- justifyContent: "center",
2337
- zIndex: 1,
2338
- flexShrink: 0
2339
- },
2340
- children: r && !i ? /* @__PURE__ */ t(le, { iconName: "faCheck", size: "lg" }) : n + 1
2341
- }
2342
- ),
2343
- /* @__PURE__ */ s(c, { sx: { ml: 2 }, children: [
2344
- /* @__PURE__ */ s(
2345
- f,
2346
- {
2347
- variant: "caption",
2348
- sx: {
2349
- color: r ? "primary.main" : "white",
2350
- fontWeight: "bold",
2351
- textTransform: "uppercase",
2352
- fontSize: 14,
2353
- opacity: u ? 0.5 : 1
2354
- },
2355
- children: [
2356
- "STEP ",
2357
- n + 1
2358
- ]
2359
- }
2360
- ),
2361
- /* @__PURE__ */ t(
2362
- f,
2363
- {
2364
- variant: "subtitle2",
2365
- sx: {
2366
- color: r ? "primary.main" : "white",
2367
- fontWeight: "bold",
2368
- textTransform: "uppercase",
2369
- fontSize: 14,
2370
- opacity: u ? 0.5 : 1
2371
- },
2372
- children: e.label
2373
- }
2374
- )
2375
- ] })
2376
- ]
2377
- }
2378
- ) }, e.key);
2379
- })
2380
- }
2381
- ),
2382
- /* @__PURE__ */ s(
2383
- c,
2384
- {
2385
- sx: {
2386
- width: "80%",
2387
- backgroundColor: "background.paper",
2388
- padding: 2,
2389
- borderRadius: "10px",
2390
- display: "flex",
2391
- flexDirection: "column",
2392
- maxHeight: "87vh",
2393
- overflowY: "auto"
2394
- },
2395
- children: [
2396
- ((rn = q[L]) == null ? void 0 : rn.key) === "featureDetails" && /* @__PURE__ */ t(c, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ s(c, { width: "80%", children: [
2397
- /* @__PURE__ */ t(
2398
- f,
2399
- {
2400
- variant: "h5",
2401
- sx: {
2402
- fontWeight: "bold",
2403
- textAlign: "center",
2404
- marginBottom: 1,
2405
- marginTop: 2
2406
- },
2407
- children: m("Feature Details")
2408
- }
2409
- ),
2410
- /* @__PURE__ */ t(
2411
- f,
2412
- {
2413
- sx: { textAlign: "center", marginBottom: 4, color: "grey" },
2414
- children: "Please provide the necessary details for the new feature, including its name, constant, and where it should be linked in the menu."
2415
- }
2416
- ),
2417
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2418
- te,
2419
- {
2420
- variant: "outlined",
2421
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
2422
- children: [
2423
- /* @__PURE__ */ s(
2424
- f,
2425
- {
2426
- variant: "subtitle1",
2427
- className: "whitespace-nowrap",
2428
- children: [
2429
- m("Is"),
2430
- " ",
2431
- m("dynamic"),
2432
- " ",
2433
- m("feature? "),
2434
- ":"
2435
- ]
2436
- }
2437
- ),
2438
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2439
- $,
2440
- {
2441
- name: "isDynamicFeature",
2442
- control: a.control,
2443
- rules: { required: "Required field" },
2444
- render: ({ field: e }) => /* @__PURE__ */ t(
2445
- Ie,
2446
- {
2447
- checked: e.value,
2448
- disabled: !!b.get("featureId"),
2449
- onChange: (n) => {
2450
- e.onChange(n.target.checked), Ci(n);
2451
- }
2452
- }
2453
- )
2454
- }
2455
- ) })
2456
- ]
2457
- }
2458
- ) }),
2459
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2460
- te,
2461
- {
2462
- variant: "outlined",
2463
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2464
- children: [
2465
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2466
- m("Feature"),
2467
- " ",
2468
- m("Name"),
2469
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }),
2470
- " :"
2471
- ] }),
2472
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2473
- ne,
2474
- {
2475
- control: a.control,
2476
- id: "menuName",
2477
- name: "menuName",
2478
- errors: a.formState.errors,
2479
- disabled: Et,
2480
- placeholder: "Feature Name"
2481
- }
2482
- ) })
2483
- ]
2484
- }
2485
- ) }),
2486
- P ? /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2487
- te,
2488
- {
2489
- variant: "outlined",
2490
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2491
- children: [
2492
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2493
- m("Feature"),
2494
- " ",
2495
- m("Constant"),
2496
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }),
2497
- " :"
2498
- ] }),
2499
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2500
- ne,
2501
- {
2502
- control: a.control,
2503
- id: "featureConstant",
2504
- name: "featureConstant",
2505
- errors: a.formState.errors,
2506
- successMessage: Se,
2507
- placeholder: "Feature Constant",
2508
- disabled: D,
2509
- onChange: (e) => Di(e.target.value)
2510
- }
2511
- ) })
2512
- ]
2513
- }
2514
- ) }, "static-feature") : /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2515
- te,
2516
- {
2517
- variant: "outlined",
2518
- className: " m-2 flex flex-row items-center w-[80%] justify-between",
2519
- children: [
2520
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2521
- m("Feature"),
2522
- " ",
2523
- m("State"),
2524
- /* @__PURE__ */ t("span", { className: "text-red-500 mx-1", children: "*" }),
2525
- /* @__PURE__ */ t(
2526
- ge,
2527
- {
2528
- title: /* @__PURE__ */ t(
2529
- f,
2530
- {
2531
- fontSize: 12,
2532
- maxWidth: 200,
2533
- sx: { whiteSpace: "pre-line" },
2534
- children: `Must follow one of these formats:
2535
- • techo.*
2536
- • medplat.form.*`
2537
- }
2538
- ),
2539
- size: "sm"
2540
- }
2541
- )
2542
- ] }),
2543
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
2544
- ne,
2545
- {
2546
- control: a.control,
2547
- id: "navigationState",
2548
- name: "navigationState",
2549
- placeholder: "Feature State",
2550
- disabled: Et || D,
2551
- successMessage: Se,
2552
- dataTestId: "managefeature-textfield-feature-state",
2553
- errors: a.formState.errors,
2554
- onChange: (e) => Pi(
2555
- e.target.value
2556
- )
2557
- }
2558
- ) })
2559
- ]
2560
- }
2561
- ) }, "dynamic-feature"),
2562
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2563
- te,
2564
- {
2565
- variant: "outlined",
2566
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2567
- children: [
2568
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2569
- m("Link"),
2570
- " ",
2571
- m("to"),
2572
- " ",
2573
- m("Menu"),
2574
- /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }),
2575
- " :"
2576
- ] }),
2577
- /* @__PURE__ */ t(c, { className: " w-[60%]", children: /* @__PURE__ */ t(
2578
- Ve,
2579
- {
2580
- control: a.control,
2581
- name: "menuType",
2582
- options: Re,
2583
- errors: a.formState.errors,
2584
- disableClearable: !1,
2585
- onChange: (e) => {
2586
- a.setValue("menuType", e.target.value), Ct();
2587
- }
2588
- }
2589
- ) })
2590
- ]
2591
- }
2592
- ) }),
2593
- /* @__PURE__ */ t(H, { children: (Y == null ? void 0 : Y.length) > 0 && /* @__PURE__ */ s(
2594
- te,
2595
- {
2596
- variant: "outlined",
2597
- className: " m-3 flex flex-row items-center w-[80%] justify-between",
2598
- children: [
2599
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
2600
- m("Menu"),
2601
- " ",
2602
- m("SubGroup"),
2603
- " :"
2604
- ] }),
2605
- /* @__PURE__ */ t(c, { className: " w-[60%]", children: /* @__PURE__ */ t(
2606
- Ve,
2607
- {
2608
- control: a.control,
2609
- name: "menuGroup",
2610
- errors: a.formState.errors,
2611
- displayName: "name",
2612
- optionValue: "id",
2613
- options: Y,
2614
- disableClearable: !1,
2615
- onChange: xi
2616
- }
2617
- ) })
2618
- ]
2619
- }
2620
- ) }),
2621
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
2622
- te,
2623
- {
2624
- variant: "outlined",
2625
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
2626
- children: [
2627
- /* @__PURE__ */ s(
2628
- f,
2629
- {
2630
- variant: "subtitle1",
2631
- className: "whitespace-nowrap",
2632
- children: [
2633
- m("Enable"),
2634
- " ",
2635
- m("feature"),
2636
- " ",
2637
- m("for"),
2638
- ":"
2639
- ]
2640
- }
2641
- ),
2642
- /* @__PURE__ */ s(c, { className: "w-[60%] flex flex-row gap-6 items-center", children: [
2643
- /* @__PURE__ */ s(c, { className: "flex items-center gap-1", children: [
2644
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: m("Web") }),
2645
- /* @__PURE__ */ t(
2646
- $,
2647
- {
2648
- name: "isWebFeature",
2649
- control: a.control,
2650
- render: ({ field: e }) => /* @__PURE__ */ t(
2651
- Ie,
2652
- {
2653
- ...e,
2654
- checked: e.value,
2655
- onChange: (n) => e.onChange(n.target.checked)
2656
- }
2657
- )
2658
- }
2659
- )
2660
- ] }),
2661
- /* @__PURE__ */ s(c, { className: "flex items-center gap-1", children: [
2662
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: m("Mobile") }),
2663
- /* @__PURE__ */ t(
2664
- $,
2665
- {
2666
- name: "isMobileFeature",
2667
- control: a.control,
2668
- render: ({ field: e }) => /* @__PURE__ */ t(
2669
- Ie,
2670
- {
2671
- ...e,
2672
- checked: e.value,
2673
- onChange: (n) => {
2674
- e.onChange(n.target.checked), Si(n);
2675
- }
2676
- }
2677
- )
2678
- }
2679
- )
2680
- ] })
2681
- ] })
2682
- ]
2683
- }
2684
- ) })
2685
- ] }) }),
2686
- ((an = q[L]) == null ? void 0 : an.key) === "mobileConfig" && R && /* @__PURE__ */ t(c, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ s(c, { width: "95%", children: [
2687
- /* @__PURE__ */ t(
2688
- f,
2689
- {
2690
- variant: "h5",
2691
- sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
2692
- children: m("Mobile Setup")
2693
- }
2694
- ),
2695
- /* @__PURE__ */ t(
2696
- f,
2697
- {
2698
- sx: { textAlign: "center", mb: 3, color: "grey" },
2699
- children: "Set up how this feature should behave and appear in the mobile app, including its entity, icon and condition query."
2700
- }
2701
- ),
2702
- /* @__PURE__ */ s(
2703
- kt,
2704
- {
2705
- expanded: yt.basicConfig,
2706
- onChange: () => bt((e) => ({
2707
- ...e,
2708
- basicConfig: !e.basicConfig
2709
- })),
2710
- sx: {
2711
- mb: 1.5,
2712
- borderRadius: 2,
2713
- boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
2714
- border: "1px solid rgba(33, 150, 243, 0.2)",
2715
- borderLeft: "4px solid #2196f3",
2716
- "&:before": { display: "none" },
2717
- overflow: "hidden"
2718
- },
2719
- children: [
2720
- /* @__PURE__ */ t(
2721
- It,
2722
- {
2723
- expandIcon: /* @__PURE__ */ t(le, { iconName: "faChevronDown", size: "sm" }),
2724
- sx: {
2725
- backgroundColor: "rgba(33, 150, 243, 0.06)",
2726
- "&:hover": {
2727
- backgroundColor: "rgba(33, 150, 243, 0.12)"
2728
- },
2729
- minHeight: 52
2730
- },
2731
- children: /* @__PURE__ */ t(f, { fontWeight: 700, fontSize: 15, children: "Basic Config" })
2732
- }
2733
- ),
2734
- /* @__PURE__ */ s(
2735
- wt,
2736
- {
2737
- sx: { display: "flex", flexDirection: "column", gap: 2 },
2738
- children: [
2739
- /* @__PURE__ */ s(
2740
- c,
2741
- {
2742
- display: "flex",
2743
- flexDirection: "row",
2744
- alignItems: "center",
2745
- children: [
2746
- /* @__PURE__ */ s(
2747
- c,
2748
- {
2749
- display: "flex",
2750
- alignItems: "center",
2751
- gap: 2,
2752
- sx: { width: "50%" },
2753
- children: [
2754
- /* @__PURE__ */ s(
2755
- f,
2756
- {
2757
- variant: "subtitle1",
2758
- sx: { minWidth: "140px", flexShrink: 0 },
2759
- children: [
2760
- m("Feature Icon"),
2761
- " ",
2762
- /* @__PURE__ */ t("span", { style: { color: "#d32f2f" }, children: "* " }),
2763
- /* @__PURE__ */ t(
2764
- ge,
2765
- {
2766
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Upload Feature Icon" }),
2767
- size: "sm"
2768
- }
2769
- )
2770
- ]
2771
- }
2772
- ),
2773
- /* @__PURE__ */ t(Yi, { title: "Upload Icon", children: /* @__PURE__ */ t(
2774
- c,
2775
- {
2776
- sx: {
2777
- transform: "scale(0.55)",
2778
- transformOrigin: "left center",
2779
- "& svg": {
2780
- fontSize: "2.5rem"
2781
- }
2782
- },
2783
- children: /* @__PURE__ */ t(
2784
- zi,
2785
- {
2786
- onUpload: (e) => a.setValue("icon", e),
2787
- formControl: a,
2788
- name: "icon",
2789
- accept: "image/svg+xml, image/svg",
2790
- errors: R ? a.formState.errors : null,
2791
- triggerType: "icon"
2792
- }
2793
- )
2794
- }
2795
- ) })
2796
- ]
2797
- }
2798
- ),
2799
- /* @__PURE__ */ s(
2800
- c,
2801
- {
2802
- display: "flex",
2803
- alignItems: "center",
2804
- gap: 2,
2805
- my: 4,
2806
- sx: { width: "50%" },
2807
- children: [
2808
- /* @__PURE__ */ s(
2809
- f,
2810
- {
2811
- variant: "subtitle1",
2812
- sx: { minWidth: "140px", flexShrink: 0 },
2813
- children: [
2814
- m("Mode"),
2815
- " ",
2816
- /* @__PURE__ */ t("span", { style: { color: "#d32f2f" }, children: "* " }),
2817
- /* @__PURE__ */ t(
2818
- ge,
2819
- {
2820
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Choose whether this feature should work online or offline" }),
2821
- size: "sm"
2822
- }
2823
- )
2824
- ]
2825
- }
2826
- ),
2827
- /* @__PURE__ */ t(c, { sx: { display: "flex", flex: 1 }, children: /* @__PURE__ */ t(
2828
- $,
2829
- {
2830
- name: "mobileMode",
2831
- control: a.control,
2832
- render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(fe, { children: [
2833
- /* @__PURE__ */ s(
2834
- pn,
2835
- {
2836
- value: e.value ?? "",
2837
- row: !0,
2838
- ...e,
2839
- children: [
2840
- /* @__PURE__ */ t(
2841
- lt,
2842
- {
2843
- value: "ONLINE",
2844
- control: /* @__PURE__ */ t(
2845
- dt,
2846
- {
2847
- disabled: D && Pt !== null
2848
- }
2849
- ),
2850
- label: "Online"
2851
- }
2852
- ),
2853
- /* @__PURE__ */ t(
2854
- lt,
2855
- {
2856
- value: "OFFLINE",
2857
- control: /* @__PURE__ */ t(
2858
- dt,
2859
- {
2860
- disabled: D && Pt !== null
2861
- }
2862
- ),
2863
- label: "Offline"
2864
- }
2865
- )
2866
- ]
2867
- }
2868
- ),
2869
- (n == null ? void 0 : n.message) && /* @__PURE__ */ t(
2870
- f,
2871
- {
2872
- variant: "caption",
2873
- color: "error",
2874
- sx: { mt: 0.5 },
2875
- children: n.message
2876
- }
2877
- )
2878
- ] })
2879
- }
2880
- ) })
2881
- ]
2882
- }
2883
- )
2884
- ]
2885
- }
2886
- ),
2887
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
2888
- /* @__PURE__ */ s(
2889
- f,
2890
- {
2891
- variant: "subtitle1",
2892
- sx: { minWidth: "140px", flexShrink: 0 },
2893
- children: [
2894
- m("Entity Name"),
2895
- " ",
2896
- /* @__PURE__ */ t(
2897
- ge,
2898
- {
2899
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Select Entity Name" }),
2900
- size: "sm"
2901
- }
2902
- )
2903
- ]
2904
- }
2905
- ),
2906
- /* @__PURE__ */ t(
2907
- c,
2908
- {
2909
- sx: {
2910
- display: "flex",
2911
- alignItems: "center",
2912
- gap: 2,
2913
- flex: 1
2914
- },
2915
- children: /* @__PURE__ */ t(
2916
- Ve,
2917
- {
2918
- control: a.control,
2919
- name: "entityName",
2920
- options: v || [],
2921
- errors: R ? a.formState.errors : null,
2922
- size: "small",
2923
- disableClearable: !1,
2924
- sx: { flex: 1 }
2925
- }
2926
- )
2927
- }
2928
- )
2929
- ] }),
2930
- a.getValues("entityName") && ((sn = a.getValues("entityName")) == null ? void 0 : sn.trim().length) > 0 && /* @__PURE__ */ s(
2931
- c,
2932
- {
2933
- display: "flex",
2934
- alignItems: "flex-start",
2935
- gap: 2,
2936
- my: 2,
2937
- children: [
2938
- /* @__PURE__ */ s(
2939
- f,
2940
- {
2941
- variant: "subtitle1",
2942
- sx: {
2943
- minWidth: "140px",
2944
- flexShrink: 0,
2945
- pt: 0.5
2946
- },
2947
- children: [
2948
- m("Condition Query"),
2949
- " :",
2950
- " ",
2951
- /* @__PURE__ */ t(
2952
- ge,
2953
- {
2954
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Write Condition Query in the editor" }),
2955
- size: "sm"
2956
- }
2957
- )
2958
- ]
2959
- }
2960
- ),
2961
- /* @__PURE__ */ t(
2962
- c,
2963
- {
2964
- flex: 1,
2965
- sx: {
2966
- border: "1px solid #bdbdbd",
2967
- borderRadius: 2,
2968
- height: "20vh",
2969
- overflow: "hidden",
2970
- boxShadow: "0 1px 6px rgba(0, 0, 0, 0.08)"
2971
- },
2972
- children: /* @__PURE__ */ t(
2973
- $,
2974
- {
2975
- name: "conditions",
2976
- control: a.control,
2977
- render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(fe, { children: [
2978
- /* @__PURE__ */ t(
2979
- Li,
2980
- {
2981
- height: "100%",
2982
- defaultLanguage: "sql",
2983
- theme: ti == "light" ? "light" : "vs-dark",
2984
- options: {
2985
- fontSize: 13,
2986
- minimap: { enabled: !1 },
2987
- automaticLayout: !0,
2988
- scrollBeyondLastLine: !1,
2989
- wordWrap: "on",
2990
- occurrencesHighlight: !1,
2991
- selectionHighlight: !1
2992
- },
2993
- value: e.value || "",
2994
- onChange: e.onChange,
2995
- editorProps: { $blockScrolling: !0 }
2996
- }
2997
- ),
2998
- (n == null ? void 0 : n.message) && /* @__PURE__ */ t(
2999
- f,
3000
- {
3001
- variant: "caption",
3002
- color: "error",
3003
- sx: { mt: 0.75, ml: 1 },
3004
- children: n.message
3005
- }
3006
- )
3007
- ] })
3008
- }
3009
- )
3010
- }
3011
- )
3012
- ]
3013
- }
3014
- ),
3015
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3016
- /* @__PURE__ */ s(
3017
- f,
3018
- {
3019
- variant: "subtitle1",
3020
- sx: { minWidth: "140px", flexShrink: 0 },
3021
- children: [
3022
- m("Tables to sync"),
3023
- " ",
3024
- /* @__PURE__ */ t(
3025
- ge,
3026
- {
3027
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 200, children: "Select at least one table to sync" }),
3028
- size: "sm"
3029
- }
3030
- )
3031
- ]
3032
- }
3033
- ),
3034
- /* @__PURE__ */ t(
3035
- c,
3036
- {
3037
- sx: {
3038
- display: "flex",
3039
- alignItems: "center",
3040
- gap: 2,
3041
- flex: 1
3042
- },
3043
- children: /* @__PURE__ */ t(
3044
- Ee,
3045
- {
3046
- id: "mobileEntitiesSync",
3047
- name: "mobileEntitiesSync",
3048
- control: a.control,
3049
- options: Z,
3050
- onChange: (e, n) => mi(n),
3051
- getOptionLabel: (e) => e == null ? void 0 : e.tableName,
3052
- checkEquality: "tableName",
3053
- errors: R ? a.formState.errors : null,
3054
- dataTestId: "syncentities-select-table",
3055
- value: T,
3056
- fullWidth: !0
3057
- }
3058
- )
3059
- }
3060
- )
3061
- ] })
3062
- ]
3063
- }
3064
- )
3065
- ]
3066
- }
3067
- ),
3068
- /* @__PURE__ */ s(
3069
- kt,
3070
- {
3071
- expanded: yt.trainingConfig,
3072
- onChange: () => bt((e) => ({
3073
- ...e,
3074
- trainingConfig: !e.trainingConfig
3075
- })),
3076
- sx: {
3077
- mb: 1.5,
3078
- borderRadius: 2,
3079
- boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3080
- border: "1px solid rgba(76, 175, 80, 0.2)",
3081
- borderLeft: "4px solid #4caf50",
3082
- "&:before": { display: "none" },
3083
- overflow: "hidden"
3084
- },
3085
- children: [
3086
- /* @__PURE__ */ t(
3087
- It,
3088
- {
3089
- expandIcon: /* @__PURE__ */ t(le, { iconName: "faChevronDown", size: "sm" }),
3090
- sx: {
3091
- backgroundColor: "rgba(76, 175, 80, 0.06)",
3092
- "&:hover": {
3093
- backgroundColor: "rgba(76, 175, 80, 0.12)"
3094
- },
3095
- minHeight: 52
3096
- },
3097
- children: /* @__PURE__ */ t(f, { fontWeight: 700, fontSize: 15, children: "Training Config" })
3098
- }
3099
- ),
3100
- /* @__PURE__ */ s(
3101
- wt,
3102
- {
3103
- sx: { display: "flex", flexDirection: "column", gap: 2 },
3104
- children: [
3105
- /* @__PURE__ */ s(
3106
- c,
3107
- {
3108
- display: "flex",
3109
- alignItems: "center",
3110
- justifyContent: "space-between",
3111
- children: [
3112
- /* @__PURE__ */ s(
3113
- f,
3114
- {
3115
- variant: "subtitle1",
3116
- sx: { minWidth: "200px", flexShrink: 0 },
3117
- children: [
3118
- m("Training Required"),
3119
- " ",
3120
- /* @__PURE__ */ t(
3121
- ge,
3122
- {
3123
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3124
- "Enable if the user must complete training before accessing this feature"
3125
- ) }),
3126
- size: "sm"
3127
- }
3128
- )
3129
- ]
3130
- }
3131
- ),
3132
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3133
- $,
3134
- {
3135
- name: "trainingRequired",
3136
- control: a.control,
3137
- render: ({ field: e }) => /* @__PURE__ */ t(
3138
- Ie,
3139
- {
3140
- ...e,
3141
- checked: !!e.value,
3142
- onChange: (n) => {
3143
- e.onChange(n.target.checked), n.target.checked || (a.setValue("trainingQuery", ""), je(""));
3144
- }
3145
- }
3146
- )
3147
- }
3148
- ) })
3149
- ]
3150
- }
3151
- ),
3152
- a.watch("trainingRequired") && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3153
- /* @__PURE__ */ s(
3154
- f,
3155
- {
3156
- variant: "subtitle1",
3157
- sx: { minWidth: "200px", flexShrink: 0 },
3158
- children: [
3159
- m("Training Query"),
3160
- " ",
3161
- /* @__PURE__ */ t(
3162
- ge,
3163
- {
3164
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3165
- "Select a query that returns a boolean — true if training is completed, false otherwise"
3166
- ) }),
3167
- size: "sm"
3168
- }
3169
- )
3170
- ]
3171
- }
3172
- ),
3173
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3174
- $,
3175
- {
3176
- name: "trainingQuery",
3177
- control: a.control,
3178
- render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ t(
3179
- Ee,
3180
- {
3181
- id: "trainingQuery",
3182
- name: "trainingQuery",
3183
- control: a.control,
3184
- options: ke,
3185
- getOptionLabel: (i) => (i == null ? void 0 : i.code) || "",
3186
- checkEquality: "code",
3187
- inputValue: Yn,
3188
- disableClearable: !1,
3189
- singleSelect: !0,
3190
- value: (ke == null ? void 0 : ke.find(
3191
- (i) => i.code === e.value
3192
- )) || null,
3193
- onInputChange: (i, r, o) => {
3194
- o === "input" && (je(r), _e(r));
3195
- },
3196
- onChange: (i, r) => {
3197
- e.onChange((r == null ? void 0 : r.code) || ""), je((r == null ? void 0 : r.code) || "");
3198
- },
3199
- placeholder: "Search training query code...",
3200
- errors: n,
3201
- fullWidth: !0,
3202
- freeSolo: !1
3203
- }
3204
- )
3205
- }
3206
- ) })
3207
- ] })
3208
- ]
3209
- }
3210
- )
3211
- ]
3212
- }
3213
- ),
3214
- /* @__PURE__ */ s(
3215
- kt,
3216
- {
3217
- expanded: yt.notificationConfig,
3218
- onChange: () => bt((e) => ({
3219
- ...e,
3220
- notificationConfig: !e.notificationConfig
3221
- })),
3222
- sx: {
3223
- mb: 1.5,
3224
- borderRadius: 2,
3225
- boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3226
- border: "1px solid rgba(255, 152, 0, 0.2)",
3227
- borderLeft: "4px solid #ff9800",
3228
- "&:before": { display: "none" },
3229
- overflow: "hidden"
3230
- },
3231
- children: [
3232
- /* @__PURE__ */ t(
3233
- It,
3234
- {
3235
- expandIcon: /* @__PURE__ */ t(le, { iconName: "faChevronDown", size: "sm" }),
3236
- sx: {
3237
- backgroundColor: "rgba(255, 152, 0, 0.06)",
3238
- "&:hover": {
3239
- backgroundColor: "rgba(255, 152, 0, 0.12)"
3240
- },
3241
- minHeight: 52
3242
- },
3243
- children: /* @__PURE__ */ s(f, { fontWeight: 700, fontSize: 15, children: [
3244
- m("Notification Config"),
3245
- " "
3246
- ] })
3247
- }
3248
- ),
3249
- /* @__PURE__ */ s(
3250
- wt,
3251
- {
3252
- sx: { display: "flex", flexDirection: "column", gap: 2 },
3253
- children: [
3254
- /* @__PURE__ */ s(
3255
- c,
3256
- {
3257
- display: "flex",
3258
- alignItems: "center",
3259
- justifyContent: "space-between",
3260
- children: [
3261
- /* @__PURE__ */ s(
3262
- f,
3263
- {
3264
- variant: "subtitle1",
3265
- sx: { minWidth: "200px", flexShrink: 0 },
3266
- children: [
3267
- m("Enable Notification Badge"),
3268
- " ",
3269
- /* @__PURE__ */ t(
3270
- ge,
3271
- {
3272
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3273
- "Show a count or nudge badge on this feature's icon in the mobile app"
3274
- ) }),
3275
- size: "sm"
3276
- }
3277
- )
3278
- ]
3279
- }
3280
- ),
3281
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3282
- $,
3283
- {
3284
- name: "notificationBadgeEnabled",
3285
- control: a.control,
3286
- render: ({ field: e }) => /* @__PURE__ */ t(
3287
- Ie,
3288
- {
3289
- ...e,
3290
- checked: !!e.value,
3291
- onChange: (n) => {
3292
- e.onChange(n.target.checked), n.target.checked || (a.setValue(
3293
- "notificationBadgeType",
3294
- ""
3295
- ), a.setValue(
3296
- "notificationBadgeQuery",
3297
- ""
3298
- ), Ge(""));
3299
- }
3300
- }
3301
- )
3302
- }
3303
- ) })
3304
- ]
3305
- }
3306
- ),
3307
- a.watch("notificationBadgeEnabled") && /* @__PURE__ */ s(fe, { children: [
3308
- /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3309
- /* @__PURE__ */ s(
3310
- f,
3311
- {
3312
- variant: "subtitle1",
3313
- sx: { minWidth: "200px", flexShrink: 0 },
3314
- children: [
3315
- m("Badge Type"),
3316
- " ",
3317
- /* @__PURE__ */ t(
3318
- ge,
3319
- {
3320
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: ut(
3321
- `Count Based: query returns a number.
3322
-
3323
- Nudge Based: query returns true/false.`
3324
- ) }),
3325
- size: "sm"
3326
- }
3327
- )
3328
- ]
3329
- }
3330
- ),
3331
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3332
- $,
3333
- {
3334
- name: "notificationBadgeType",
3335
- control: a.control,
3336
- render: ({ field: e }) => /* @__PURE__ */ s(pn, { row: !0, ...e, children: [
3337
- /* @__PURE__ */ t(
3338
- lt,
3339
- {
3340
- value: "COUNT",
3341
- control: /* @__PURE__ */ t(dt, {}),
3342
- label: "Count Based"
3343
- }
3344
- ),
3345
- /* @__PURE__ */ t(
3346
- lt,
3347
- {
3348
- value: "NUDGE",
3349
- control: /* @__PURE__ */ t(dt, {}),
3350
- label: "Nudge Based"
3351
- }
3352
- )
3353
- ] })
3354
- }
3355
- ) })
3356
- ] }),
3357
- a.watch("notificationBadgeType") && /* @__PURE__ */ s(c, { display: "flex", alignItems: "center", gap: 2, children: [
3358
- /* @__PURE__ */ s(
3359
- f,
3360
- {
3361
- variant: "subtitle1",
3362
- sx: { minWidth: "200px", flexShrink: 0 },
3363
- children: [
3364
- a.watch("notificationBadgeType") === "COUNT" ? "Count Query" : "Nudge Query",
3365
- " ",
3366
- /* @__PURE__ */ t(
3367
- ge,
3368
- {
3369
- title: /* @__PURE__ */ t(f, { fontSize: 12, maxWidth: 220, children: a.watch(
3370
- "notificationBadgeType"
3371
- ) === "COUNT" ? "Select a query that returns a numeric count for the badge" : "Select a query that returns true/false to show or hide the badge" }),
3372
- size: "sm"
3373
- }
3374
- )
3375
- ]
3376
- }
3377
- ),
3378
- /* @__PURE__ */ t(c, { sx: { flex: 1 }, children: /* @__PURE__ */ t(
3379
- $,
3380
- {
3381
- name: "notificationBadgeQuery",
3382
- control: a.control,
3383
- render: ({
3384
- field: e,
3385
- fieldState: { error: n }
3386
- }) => /* @__PURE__ */ t(
3387
- Ee,
3388
- {
3389
- id: "notificationBadgeQuery",
3390
- name: "notificationBadgeQuery",
3391
- control: a.control,
3392
- options: ke,
3393
- getOptionLabel: (i) => (i == null ? void 0 : i.code) || "",
3394
- checkEquality: "code",
3395
- inputValue: Kn,
3396
- disableClearable: !1,
3397
- singleSelect: !0,
3398
- value: (ke == null ? void 0 : ke.find(
3399
- (i) => i.code === e.value
3400
- )) || null,
3401
- onInputChange: (i, r, o) => {
3402
- o === "input" && (Ge(r), _e(r));
3403
- },
3404
- onChange: (i, r) => {
3405
- e.onChange((r == null ? void 0 : r.code) || ""), Ge(
3406
- (r == null ? void 0 : r.code) || ""
3407
- );
3408
- },
3409
- placeholder: a.watch(
3410
- "notificationBadgeType"
3411
- ) === "COUNT" ? "Search count query code..." : "Search nudge query code...",
3412
- errors: n,
3413
- fullWidth: !0,
3414
- freeSolo: !1
3415
- }
3416
- )
3417
- }
3418
- ) })
3419
- ] })
3420
- ] })
3421
- ]
3422
- }
3423
- )
3424
- ]
3425
- }
3426
- )
3427
- ] }) }),
3428
- ((on = q[L]) == null ? void 0 : on.key) === "formLinking" && P && /* @__PURE__ */ t(c, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ s(c, { width: "80%", children: [
3429
- /* @__PURE__ */ t(
3430
- f,
3431
- {
3432
- variant: "h5",
3433
- sx: {
3434
- fontWeight: "bold",
3435
- textAlign: "center",
3436
- marginBottom: 1,
3437
- marginTop: 2
3438
- },
3439
- children: m("Form Linking")
3440
- }
3441
- ),
3442
- /* @__PURE__ */ t(
3443
- f,
3444
- {
3445
- sx: { textAlign: "center", mb: 4, color: "grey" },
3446
- children: "Link this feature to an existing form, or create a new form to be associated with it."
3447
- }
3448
- ),
3449
- /* @__PURE__ */ s(H, { container: !0, mt: 3, className: "flex flex-col w-[98%]", children: [
3450
- /* @__PURE__ */ t(
3451
- f,
3452
- {
3453
- variant: "subtitle1",
3454
- sx: {
3455
- marginLeft: 1,
3456
- marginBottom: "0.5rem",
3457
- fontWeight: 600
3458
- },
3459
- children: "Use Existing Form"
3460
- }
3461
- ),
3462
- /* @__PURE__ */ t(H, { container: !0, sx: { alignItems: "center" }, children: /* @__PURE__ */ s(
3463
- te,
3464
- {
3465
- variant: "outlined",
3466
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
3467
- children: [
3468
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
3469
- m("Select"),
3470
- " ",
3471
- m("Form"),
3472
- ":"
3473
- ] }),
3474
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
3475
- Ve,
3476
- {
3477
- control: a.control,
3478
- name: "formCode",
3479
- options: he || [],
3480
- getOptionDisabled: (e) => e.menu_config_id && e.menu_config_id !== parseInt(b.get("featureId")),
3481
- displayName: "form_name",
3482
- optionValue: "form_code",
3483
- errors: a.formState.errors,
3484
- size: "small",
3485
- disableClearable: !1,
3486
- onChange: (e) => {
3487
- e.target.value ? (a.setValue(
3488
- "navigationState",
3489
- `medplat.form.${e.target.value}`
3490
- ), ye(e.target.value)) : (a.setValue("version", null), a.setValue(
3491
- "navigationState",
3492
- "medplat.form."
3493
- ));
3494
- }
3495
- }
3496
- ) })
3497
- ]
3498
- }
3499
- ) }),
3500
- /* @__PURE__ */ s(
3501
- te,
3502
- {
3503
- variant: "outlined",
3504
- className: "m-3 flex flex-row items-center w-[80%] justify-between",
3505
- children: [
3506
- /* @__PURE__ */ s(f, { variant: "subtitle1", children: [
3507
- m("Select"),
3508
- " ",
3509
- m("Version"),
3510
- ":"
3511
- ] }),
3512
- /* @__PURE__ */ t(c, { className: "w-[60%]", children: /* @__PURE__ */ t(
3513
- Ve,
3514
- {
3515
- control: a.control,
3516
- name: "version",
3517
- options: Array.isArray(J == null ? void 0 : J[De]) ? J[De].map(
3518
- (e) => e.version
3519
- ) : [],
3520
- errors: a.formState.errors,
3521
- disableClearable: !1,
3522
- size: "small"
3523
- }
3524
- ) })
3525
- ]
3526
- }
3527
- ),
3528
- /* @__PURE__ */ t(
3529
- Ye,
3530
- {
3531
- sx: {
3532
- width: "80%",
3533
- margin: "1rem auto",
3534
- position: "relative"
3535
- },
3536
- children: /* @__PURE__ */ t(
3537
- f,
3538
- {
3539
- variant: "caption",
3540
- sx: {
3541
- position: "absolute",
3542
- top: "-0.6rem",
3543
- left: "50%",
3544
- transform: "translateX(-50%)",
3545
- backgroundColor: "background.paper",
3546
- padding: "0 0.5rem"
3547
- },
3548
- children: "OR"
3549
- }
3550
- )
3551
- }
3552
- ),
3553
- /* @__PURE__ */ s(c, { className: "flex justify-center", children: [
3554
- /* @__PURE__ */ t(
3555
- U,
3556
- {
3557
- variant: "outlined",
3558
- size: "small",
3559
- onClick: () => {
3560
- a.setValue("formCode", null), S(!0);
3561
- },
3562
- children: "Add New Form"
3563
- }
3564
- ),
3565
- N && /* @__PURE__ */ t(
3566
- An,
3567
- {
3568
- mainFormCtrl: a,
3569
- openAddFormModal: N,
3570
- setModal: (e) => {
3571
- S(e);
3572
- },
3573
- reloadForms: Fi
3574
- }
3575
- )
3576
- ] })
3577
- ] })
3578
- ] }) }),
3579
- ((ln = q[L]) == null ? void 0 : ln.key) === "additionalPermissions" && /* @__PURE__ */ t(H, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ s(c, { mt: 3, className: "flex flex-col w-full", children: [
3580
- /* @__PURE__ */ t(
3581
- f,
3582
- {
3583
- variant: "h5",
3584
- sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3585
- children: "Additional Permissions"
3586
- }
3587
- ),
3588
- /* @__PURE__ */ t(
3589
- f,
3590
- {
3591
- sx: { textAlign: "center", mb: 4, color: "grey" },
3592
- children: "Define custom permissions for this feature. These will be used to control fine-grained permissions beyond default roles."
3593
- }
3594
- ),
3595
- !P && (l == null ? void 0 : l.val) === !1 ? /* @__PURE__ */ s(fe, { children: [
3596
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ s(
3597
- te,
3598
- {
3599
- variant: "outlined",
3600
- className: "flex flex-row items-center ml-3 ",
3601
- children: [
3602
- /* @__PURE__ */ t(f, { variant: "body2", children: m("Add feature JSON access rights") }),
3603
- /* @__PURE__ */ t(
3604
- gn,
3605
- {
3606
- disabled: Qn,
3607
- checked: Te,
3608
- onChange: Mi,
3609
- "data-testid": "managefeature-checkbox-access-rights"
3610
- }
3611
- )
3612
- ]
3613
- }
3614
- ) }),
3615
- /* @__PURE__ */ t(H, { children: K.value && Te && /* @__PURE__ */ t(H, { children: /* @__PURE__ */ t(Ki, { className: "ml-2", children: (dn = a.getValues("updatedFields")) == null ? void 0 : dn.map((e, n) => {
3616
- var i;
3617
- return /* @__PURE__ */ s(
3618
- H,
3619
- {
3620
- className: " mb-2.5 flex flex-row items-center ",
3621
- children: [
3622
- /* @__PURE__ */ t(te, { children: /* @__PURE__ */ t(
3623
- $,
3624
- {
3625
- name: `updatedFields[${n}].value`,
3626
- control: a.control,
3627
- render: ({ field: r }) => /* @__PURE__ */ t(
3628
- Vn,
3629
- {
3630
- ...r,
3631
- label: `${m("Right")} ${n + 1}`,
3632
- value: r.value || "",
3633
- sx: {
3634
- "& .MuiInputLabel-root": {
3635
- fontSize: "14px"
3636
- },
3637
- "& .MuiInputBase-input": {
3638
- fontSize: "14px"
3639
- }
3640
- }
3641
- }
3642
- )
3643
- }
3644
- ) }),
3645
- /* @__PURE__ */ t(
3646
- gn,
3647
- {
3648
- disabled: e.updated,
3649
- checked: e.checkbox,
3650
- onChange: () => Bi(e.id),
3651
- className: " mr-2.5",
3652
- "data-testid": `managefeature-checkbox-updated-right-${n + 1}`
3653
- }
3654
- ),
3655
- n + 1 === ((i = a.getValues("updatedFields")) == null ? void 0 : i.length) && /* @__PURE__ */ t(
3656
- U,
3657
- {
3658
- variant: "contained",
3659
- color: "primary",
3660
- onClick: Oi,
3661
- size: "small",
3662
- className: " mr-2.5",
3663
- disabled: !ri.updatedFields.some(
3664
- (r) => r.id === (e == null ? void 0 : e.id) && r.value
3665
- ),
3666
- "data-testid": "managefeature-button-add-updated",
3667
- children: m("Add")
3668
- }
3669
- ),
3670
- !e.updated && /* @__PURE__ */ t(
3671
- U,
3672
- {
3673
- variant: "contained",
3674
- size: "small",
3675
- color: "secondary",
3676
- onClick: () => Ui(e.id),
3677
- "data-testid": `managefeature-button-delete-updated-${n + 1}`,
3678
- children: m("Delete")
3679
- }
3680
- )
3681
- ]
3682
- },
3683
- e.id
3684
- );
3685
- }) }) }) })
3686
- ] }) : /* @__PURE__ */ s(fe, { children: [
3687
- (ce == null ? void 0 : ce.length) === 0 ? /* @__PURE__ */ t(
3688
- f,
3689
- {
3690
- variant: "subtitle1",
3691
- color: "text.secondary",
3692
- align: "center",
3693
- sx: { py: 2 },
3694
- children: "No permissions added yet."
3695
- }
3696
- ) : /* @__PURE__ */ t(
3697
- Wn,
3698
- {
3699
- permissions: ce,
3700
- onEdit: (e) => Ii(e),
3701
- onRemove: (e) => vi(e),
3702
- handleAddChildClick: (e) => ki(e),
3703
- isDynamicFeature: P
3704
- }
3705
- ),
3706
- /* @__PURE__ */ t(
3707
- c,
3708
- {
3709
- sx: {
3710
- display: "flex",
3711
- justifyContent: "flex-end",
3712
- mt: 2
3713
- },
3714
- children: /* @__PURE__ */ t(
3715
- U,
3716
- {
3717
- variant: "outlined",
3718
- size: "small",
3719
- startIcon: /* @__PURE__ */ t(le, { iconName: "faPlus" }),
3720
- onClick: Ni,
3721
- sx: {
3722
- textTransform: "none",
3723
- fontWeight: 500,
3724
- borderRadius: 2,
3725
- px: 2,
3726
- py: 0.75,
3727
- minWidth: 120
3728
- },
3729
- children: "Add Parent Permission"
3730
- }
3731
- )
3732
- }
3733
- ),
3734
- /* @__PURE__ */ t(
3735
- qn,
3736
- {
3737
- open: Bn,
3738
- onClose: () => Qe(!1),
3739
- onSave: wi,
3740
- formCtrl: a,
3741
- editData: On,
3742
- parentPermissionId: Je === "add-child" ? pt : null,
3743
- mode: Je,
3744
- permissionTypes: jn,
3745
- setPermissionTypes: Gn,
3746
- existingPermissionIds: new Set(
3747
- st(ce).map(
3748
- (e) => e.permissionId
3749
- )
3750
- ),
3751
- isDynamicFeature: P
3752
- }
3753
- )
3754
- ] })
3755
- ] }) }),
3756
- ((cn = q[L]) == null ? void 0 : cn.key) === "assignFeatures" && /* @__PURE__ */ s(c, { mt: 3, className: "flex flex-col w-full", children: [
3757
- /* @__PURE__ */ t(
3758
- f,
3759
- {
3760
- variant: "h5",
3761
- sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3762
- children: m("Assign Features")
3763
- }
3764
- ),
3765
- /* @__PURE__ */ t(f, { sx: { textAlign: "center", mb: 4, color: "grey" }, children: "Assign this feature to specific users or roles. You can toggle individual permissions below after assigning." }),
3766
- /* @__PURE__ */ s(c, { display: "flex", gap: 2, flexWrap: "wrap", mb: 3, children: [
3767
- /* @__PURE__ */ s(c, { flex: "1 1 300px", minWidth: 300, children: [
3768
- /* @__PURE__ */ t(f, { variant: "subtitle1", sx: { mb: 1 }, children: m("User") }),
3769
- /* @__PURE__ */ t(
3770
- Ee,
3771
- {
3772
- id: "roles",
3773
- name: "roles",
3774
- control: a.control,
3775
- options: !P && (l == null ? void 0 : l.val) === !1 ? Be.filter(
3776
- (e) => !Ne.some(
3777
- (n) => n.entityType === "user" && n.user_id === e.id
3778
- )
3779
- ) : Be,
3780
- value: _,
3781
- singleSelect: !0,
3782
- onChange: fi,
3783
- onInputChange: qi,
3784
- getOptionLabel: bi,
3785
- "data-testid": "accessrights-autocomplete-user",
3786
- fullWidth: !0
3787
- }
3788
- )
3789
- ] }),
3790
- /* @__PURE__ */ s(c, { flex: "1 1 300px", minWidth: 300, children: [
3791
- /* @__PURE__ */ t(f, { variant: "subtitle1", sx: { mb: 1 }, children: m("Role") }),
3792
- /* @__PURE__ */ t(
3793
- Ee,
3794
- {
3795
- id: "selectedRoles",
3796
- name: "selectedRoles",
3797
- control: a.control,
3798
- options: !P && (l == null ? void 0 : l.val) === !1 ? $t().filter(
3799
- (e) => !Ne.some(
3800
- (n) => n.entityType === "role" && n.role_id === e.id
3801
- )
3802
- ) : $t(),
3803
- onChange: (e, n) => ui(n),
3804
- getOptionLabel: (e) => e == null ? void 0 : e.name,
3805
- dataTestId: "accessrights-select-role",
3806
- value: g,
3807
- fullWidth: !0
3808
- }
3809
- )
3810
- ] }),
3811
- /* @__PURE__ */ t(
3812
- c,
3813
- {
3814
- display: "flex",
3815
- alignItems: "flex-end",
3816
- flexShrink: 0,
3817
- sx: { minWidth: 120 },
3818
- children: /* @__PURE__ */ t(
3819
- U,
3820
- {
3821
- variant: "contained",
3822
- size: "medium",
3823
- fullWidth: !0,
3824
- disabled: !(g.length > 0 || _ != null && _.id),
3825
- "data-testid": "accessrights-add-button",
3826
- onClick: Ti,
3827
- sx: { minWidth: 120, marginBottom: "10px" },
3828
- children: m("Add")
3829
- }
3830
- )
3831
- }
3832
- )
3833
- ] }),
3834
- !P && (l == null ? void 0 : l.val) === !1 ? /* @__PURE__ */ t(yn, { sx: { maxHeight: 360, overflowY: "auto" }, children: /* @__PURE__ */ s(bn, { size: "small", children: [
3835
- /* @__PURE__ */ t(xn, { children: /* @__PURE__ */ s(ct, { children: [
3836
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Type") }),
3837
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Name") }),
3838
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Access Right") }),
3839
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Actions") })
3840
- ] }) }),
3841
- /* @__PURE__ */ t(Sn, { children: Ue.map((e, n) => /* @__PURE__ */ s(ct, { children: [
3842
- /* @__PURE__ */ t(ee, { children: e.designationId ? "Role" : "User" }),
3843
- /* @__PURE__ */ t(ee, { children: e.roleName || e.fullName }),
3844
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3845
- c,
3846
- {
3847
- display: "flex",
3848
- flexDirection: "column",
3849
- gap: 1,
3850
- children: (() => {
3851
- const i = K.value ? a.getValues("updatedFields") : a.getValues("fields"), r = i == null ? void 0 : i.reduce((h, y) => (h[y.value] = y.checkbox, h), {}), o = e.featureJson ? JSON.parse(e.featureJson) : {}, u = Object.fromEntries(
3852
- Object.entries(o).map(
3853
- ([h, y]) => [
3854
- h,
3855
- y === !0 || y === "true"
3856
- ]
3857
- )
3858
- ), d = {
3859
- ...u,
3860
- ...Object.fromEntries(
3861
- Object.entries(
3862
- r || {}
3863
- ).filter(
3864
- ([h]) => !(h in u)
3865
- )
3866
- )
3867
- };
3868
- return Object.entries(d).map(
3869
- ([h, y]) => /* @__PURE__ */ s(
3870
- c,
3871
- {
3872
- display: "flex",
3873
- alignItems: "center",
3874
- gap: 1,
3875
- children: [
3876
- /* @__PURE__ */ t(
3877
- Ie,
3878
- {
3879
- sx: {
3880
- transform: "scale(0.75)",
3881
- transformOrigin: "left center"
3882
- },
3883
- checked: !!y,
3884
- onChange: () => {
3885
- const F = [
3886
- ...Ue
3887
- ];
3888
- let k = {};
3889
- try {
3890
- k = e.featureJson ? JSON.parse(
3891
- e.featureJson
3892
- ) : {};
3893
- } catch (se) {
3894
- console.warn(
3895
- "Invalid JSON in featureJson:",
3896
- se
3897
- );
3898
- }
3899
- const X = (K.value ? a.getValues(
3900
- "updatedFields"
3901
- ) : a.getValues(
3902
- "fields"
3903
- ) || []).reduce(
3904
- (se, oe) => (se[oe.value] = oe.value in k ? k[oe.value] : oe.checkbox, se),
3905
- {}
3906
- );
3907
- X[h] = !y, F[n] = {
3908
- ...e,
3909
- featureJson: JSON.stringify(
3910
- X
3911
- )
3912
- }, ze(F);
3913
- }
3914
- }
3915
- ),
3916
- /* @__PURE__ */ t(f, { variant: "subtitle1", children: h })
3917
- ]
3918
- },
3919
- h
3920
- )
3921
- );
3922
- })()
3923
- }
3924
- ) }),
3925
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3926
- qe,
3927
- {
3928
- size: "small",
3929
- color: "error",
3930
- onClick: () => {
3931
- const i = Ue.filter(
3932
- (r, o) => o !== n
3933
- );
3934
- ze(i);
3935
- },
3936
- children: /* @__PURE__ */ t(
3937
- le,
3938
- {
3939
- iconName: "faTrashAlt",
3940
- size: "sm"
3941
- }
3942
- )
3943
- }
3944
- ) })
3945
- ] }, n)) })
3946
- ] }) }) : /* @__PURE__ */ t(fe, { children: Ne.length > 0 && /* @__PURE__ */ t(
3947
- yn,
3948
- {
3949
- sx: { maxHeight: 360, overflowY: "auto" },
3950
- children: /* @__PURE__ */ s(bn, { size: "small", children: [
3951
- /* @__PURE__ */ t(xn, { children: /* @__PURE__ */ s(ct, { children: [
3952
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Type") }),
3953
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Name") }),
3954
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Permissions") }),
3955
- /* @__PURE__ */ t(ee, { sx: { fontWeight: "bold" }, children: m("Actions") })
3956
- ] }) }),
3957
- /* @__PURE__ */ t(Sn, { children: Ne.map((e, n) => /* @__PURE__ */ s(ct, { children: [
3958
- /* @__PURE__ */ t(ee, { children: e.entityType === "role" ? "Role" : "User" }),
3959
- /* @__PURE__ */ t(ee, { children: e.name }),
3960
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3961
- _t,
3962
- {
3963
- permissions: e.permissions,
3964
- onToggle: (i) => _i(n, i)
3965
- }
3966
- ) }),
3967
- /* @__PURE__ */ t(ee, { children: /* @__PURE__ */ t(
3968
- qe,
3969
- {
3970
- size: "small",
3971
- color: "error",
3972
- onClick: () => {
3973
- const i = Ne.filter(
3974
- (r, o) => o !== n
3975
- );
3976
- We(i);
3977
- },
3978
- children: /* @__PURE__ */ t(
3979
- le,
3980
- {
3981
- iconName: "faTrashAlt",
3982
- size: "sm"
3983
- }
3984
- )
3985
- }
3986
- ) })
3987
- ] }, n)) })
3988
- ] })
3989
- }
3990
- ) }),
3991
- /* @__PURE__ */ t(
3992
- Rn,
3993
- {
3994
- open: zn,
3995
- onClose: () => gt(!1),
3996
- permissions: ce,
3997
- entityData: Ln,
3998
- onSave: (e) => {
3999
- We((n) => [...n, e]), gt(!1);
4000
- }
4001
- }
4002
- )
4003
- ] }),
4004
- ((un = q[L]) == null ? void 0 : un.key) === "submit" && Ae && /* @__PURE__ */ s(
4005
- c,
4006
- {
4007
- sx: {
4008
- mt: 4,
4009
- display: "flex",
4010
- flexDirection: "column",
4011
- alignItems: "center",
4012
- justifyContent: "center",
4013
- textAlign: "center",
4014
- minHeight: "300px",
4015
- px: 3,
4016
- mx: "auto",
4017
- maxWidth: 500,
4018
- backgroundColor: "background.default",
4019
- borderRadius: 3,
4020
- boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
4021
- border: `1px solid ${C.palette.divider}`,
4022
- p: 6
4023
- },
4024
- children: [
4025
- /* @__PURE__ */ t(c, { sx: { color: "success.main", fontSize: 40, mb: 2 }, children: /* @__PURE__ */ t(le, { iconName: "faCheckCircle" }) }),
4026
- /* @__PURE__ */ s(
4027
- f,
4028
- {
4029
- variant: "h6",
4030
- gutterBottom: !0,
4031
- sx: { fontWeight: "bold" },
4032
- children: [
4033
- "Feature was successfully",
4034
- b.get("featureId") ? "updated" : "created",
4035
- "!"
4036
- ]
4037
- }
4038
- ),
4039
- /* @__PURE__ */ t(Ye, { sx: { my: 2, width: "100%" } }),
4040
- /* @__PURE__ */ s(f, { variant: "subtitle1", gutterBottom: !0, children: [
4041
- /* @__PURE__ */ t("strong", { children: "Feature Name:" }),
4042
- " ",
4043
- a.getValues("menuName")
4044
- ] }),
4045
- P && /* @__PURE__ */ s(f, { variant: "subtitle1", gutterBottom: !0, children: [
4046
- /* @__PURE__ */ t("strong", { children: "Feature Constant:" }),
4047
- " ",
4048
- a.getValues("featureConstant")
4049
- ] }),
4050
- /* @__PURE__ */ t(c, { mt: 5, width: "100%", display: "flex", justifyContent: "center", children: a.getValues("formCode") && a.getValues("version") ? /* @__PURE__ */ t(
4051
- U,
4052
- {
4053
- variant: "contained",
4054
- color: "primary",
4055
- onClick: () => {
4056
- var r;
4057
- const e = a.getValues("formCode"), n = a.getValues("version"), i = (r = J == null ? void 0 : J[e]) == null ? void 0 : r.find(
4058
- (o) => o.version === n
4059
- );
4060
- i != null && i.uuid ? E(
4061
- `/ui/medplat/admin/medplatForms/form/${i.uuid}`
4062
- ) : console.warn("Could not find matching version UUID");
4063
- },
4064
- children: "Configure Form"
4065
- }
4066
- ) : /* @__PURE__ */ t(
4067
- U,
4068
- {
4069
- variant: "outlined",
4070
- color: "primary",
4071
- onClick: () => E("/ui/medplat/manage/menu"),
4072
- children: "Go Back to Menu"
4073
- }
4074
- ) })
4075
- ]
4076
- }
4077
- ),
4078
- !Ae && /* @__PURE__ */ s(
4079
- c,
4080
- {
4081
- mt: "auto",
4082
- display: "flex",
4083
- justifyContent: "flex-end",
4084
- gap: 2,
4085
- sx: { paddingTop: 4 },
4086
- children: [
4087
- /* @__PURE__ */ t(
4088
- U,
4089
- {
4090
- variant: "outlined",
4091
- sx: { color: "text.secondary" },
4092
- onClick: si,
4093
- children: "Back"
4094
- }
4095
- ),
4096
- ((mn = q[L]) == null ? void 0 : mn.key) !== "submit" && (() => {
4097
- var h;
4098
- const e = (h = q[L]) == null ? void 0 : h.key, n = ["formLinking"].includes(e), i = et.includes(e), [r, o] = a.getValues(Bt(e)), u = e === "formLinking" ? !!(r != null && r.trim()) || !!(o != null && o.trim()) : e === "additionalPermissions" ? Array.isArray(r) && r.length > 0 : !1, d = a.handleSubmit(
4099
- (y) => {
4100
- Xt(y);
4101
- const F = q.findIndex(
4102
- (k) => k.key === "submit"
4103
- );
4104
- At((k) => new Set(k).add(e)), Ce(F);
4105
- }
4106
- );
4107
- return e === "assignFeatures" || e === "accessRights" ? /* @__PURE__ */ t(
4108
- U,
4109
- {
4110
- variant: "contained",
4111
- onClick: d,
4112
- children: "Save"
4113
- }
4114
- ) : n ? Rt ? /* @__PURE__ */ t(U, { variant: "contained", onClick: xt, children: "Next" }) : u ? /* @__PURE__ */ t(U, { variant: "contained", disabled: !0, children: "Next" }) : /* @__PURE__ */ t(
4115
- U,
4116
- {
4117
- variant: "outlined",
4118
- color: "secondary",
4119
- onClick: () => {
4120
- i || Me((y) => [...y, e]), xt();
4121
- },
4122
- children: "Skip for now"
4123
- }
4124
- ) : /* @__PURE__ */ t(
4125
- U,
4126
- {
4127
- variant: "contained",
4128
- onClick: xt,
4129
- disabled: !Rt,
4130
- children: "Next"
4131
- }
4132
- );
4133
- })()
4134
- ]
4135
- }
4136
- )
4137
- ]
4138
- }
4139
- )
4140
- ] }) })
4141
- }
4142
- );
4143
- }
4144
- Wn.propTypes = {
4145
- permissions: I.any,
4146
- onEdit: I.any,
4147
- onRemove: I.any,
4148
- handleAddChildClick: I.any,
4149
- isDynamicFeature: I.any
4150
- };
4151
- qn.propTypes = {
4152
- open: I.any,
4153
- onClose: I.any,
4154
- onSave: I.any,
4155
- formCtrl: I.any,
4156
- editData: I.any,
4157
- parentPermissionId: I.any,
4158
- mode: I.any,
4159
- permissionTypes: I.any,
4160
- setPermissionTypes: I.any,
4161
- isDynamicFeature: I.any,
4162
- existingPermissionIds: I.any
4163
- };
4164
- Tt.propTypes = {
4165
- permission: I.any,
4166
- index: I.any,
4167
- depth: I.any,
4168
- onEdit: I.any,
4169
- onRemove: I.any,
4170
- handleAddChildClick: I.any,
4171
- isLastChild: I.any,
4172
- isDynamicFeature: I.any
4173
- };
4174
- _t.propTypes = {
4175
- permissions: I.any,
4176
- onToggle: I.any,
4177
- isChild: I.any
4178
- };
4179
- Rn.propTypes = {
4180
- open: I.any,
4181
- onClose: I.any,
4182
- onSave: I.any,
4183
- entityData: I.any,
4184
- permissions: I.any
4185
- };
4186
- export {
4187
- Jr as default
4188
- };
4189
- //# sourceMappingURL=ManageDynamicFeature-BKkCnQvF.js.map