@argusoft/medplat-form-engine 1.0.13 → 1.0.15

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