@asaleh37/ui-base 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -13
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -3
- package/src/components/App.tsx +1 -1
- package/src/components/BaseApp.tsx +2 -19
- package/src/components/administration/admin/OrgMemberRoleForm.tsx +83 -0
- package/src/components/administration/admin/OrganizationApplicationModuleGrid.tsx +131 -0
- package/src/components/administration/admin/OrganizationGrid.tsx +165 -0
- package/src/components/administration/admin/OrganizationMemberGrid.tsx +176 -0
- package/src/components/administration/admin/OrganizationMemberRoleGrid.tsx +87 -0
- package/src/components/{admin → administration/admin}/OrganizationRankGrid.tsx +49 -19
- package/src/components/administration/admin/OrganizationUnitGrid.tsx +139 -0
- package/src/components/administration/admin/OrganizationUnitTypeGrid.tsx +121 -0
- package/src/components/administration/admin/PersonGrid.tsx +195 -0
- package/src/components/{admin → administration/admin}/RoleAuthoritiesForm.tsx +30 -11
- package/src/components/administration/admin/SystemApplicationAuthorityGrid.tsx +142 -0
- package/src/components/administration/admin/SystemApplicationGrid.tsx +161 -0
- package/src/components/administration/admin/SystemApplicationModuleGrid.tsx +109 -0
- package/src/components/administration/admin/SystemApplicationRoleAuthorityGrid.tsx +67 -0
- package/src/components/administration/admin/SystemApplicationRoleGrid.tsx +130 -0
- package/src/components/administration/dev/BluePrintGrid.tsx +129 -0
- package/src/components/administration/dev/DashboardGrid.tsx +173 -0
- package/src/components/administration/dev/DashboardWidgetGrid.tsx +164 -0
- package/src/components/administration/dev/DataQueryGrid.tsx +206 -0
- package/src/components/administration/dev/DataQueryParameterGrid.tsx +191 -0
- package/src/components/administration/dev/DataQueryParametersForm.tsx +84 -0
- package/src/components/administration/dev/DatasourceConnectionGrid.tsx +150 -0
- package/src/components/administration/dev/EntityParameterGrid.tsx +279 -0
- package/src/components/administration/dev/LookupGrid.tsx +131 -0
- package/src/components/administration/dev/MailAttachmentGrid.tsx +155 -0
- package/src/components/administration/dev/MailBodyGrid.tsx +215 -0
- package/src/components/{admin → administration/dev}/MailNotificationQueueGrid.tsx +114 -26
- package/src/components/administration/dev/MailRecipientGrid.tsx +169 -0
- package/src/components/administration/dev/MailSenderConfigGrid.tsx +478 -0
- package/src/components/administration/dev/MailTemplateGrid.tsx +388 -0
- package/src/components/administration/dev/ReportGrid.tsx +504 -0
- package/src/components/administration/dev/ReportParameterGrid.tsx +186 -0
- package/src/components/administration/dev/ReportParametersForm.tsx +84 -0
- package/src/components/administration/dev/WidgetGrid.tsx +431 -0
- package/src/components/administration/dev/WorkflowDocumentActionGrid.tsx +264 -0
- package/src/components/administration/dev/WorkflowDocumentActionHistoryGrid.tsx +172 -0
- package/src/components/administration/dev/WorkflowDocumentActionMailGrid.tsx +161 -0
- package/src/components/administration/dev/WorkflowDocumentGrid.tsx +377 -0
- package/src/components/{admin → administration/dev}/WorkflowDocumentMailLogGrid.tsx +87 -10
- package/src/components/administration/dev/WorkflowDocumentStatusGrid.tsx +243 -0
- package/src/components/common/ChangeOrgForm.tsx +81 -0
- package/src/components/common/Home.tsx +28 -22
- package/src/components/common/LoadingMask.tsx +9 -4
- package/src/components/common/Login.tsx +9 -13
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +30 -6
- package/src/components/templates/DataEntryTemplates/DataEntryUtil.ts +46 -5
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +64 -5
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementGroup.tsx +11 -3
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/CheckBox.tsx +2 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx +1 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/HtmlEditor.tsx +144 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/SystemLookupCombobox.tsx +55 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField.tsx +9 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +45 -5
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx +8 -7
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid.tsx +38 -10
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridRecordAction.tsx +4 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridTopBar.tsx +3 -4
- package/src/components/templates/TransferList.tsx +16 -6
- package/src/components/templates/index.ts +0 -2
- package/src/components/templates/report/ExcelReportViewer.tsx +65 -0
- package/src/components/templates/report/ReportViewer.tsx +382 -0
- package/src/components/templates/visuals/DashboardRouteView.tsx +9 -0
- package/src/components/templates/visuals/DashboardViewer.tsx +148 -0
- package/src/components/templates/visuals/WidgetViewer.tsx +198 -0
- package/src/components/templates/visuals/charts/TemplateBarChart.tsx +9 -2
- package/src/components/templates/visuals/charts/TemplateDataCard.tsx +6 -31
- package/src/components/templates/visuals/charts/TemplateGauge.tsx +8 -3
- package/src/components/templates/visuals/charts/TemplateLineChart.tsx +8 -2
- package/src/components/templates/visuals/charts/TemplateLineProgress.tsx +5 -3
- package/src/components/templates/visuals/charts/TemplatePieChart.tsx +1 -2
- package/src/components/templates/workflow/WorkflowDocumentPanel.tsx +581 -0
- package/src/components/templates/workflow/WorkflowDocumentTimeLine.tsx +134 -0
- package/src/hooks/UseSession.tsx +3 -7
- package/src/hooks/UseWindow.tsx +2 -1
- package/src/hooks/useAxios.tsx +9 -27
- package/src/hooks/useLookupGridColumn.tsx +35 -0
- package/src/layout/Layout.tsx +2 -46
- package/src/layout/MainContent.tsx +60 -7
- package/src/layout/MobileDrawer.tsx +5 -5
- package/src/layout/NavigationTree.tsx +0 -1
- package/src/layout/RouteWrapper.tsx +36 -0
- package/src/layout/SideBar.tsx +15 -10
- package/src/layout/TopBar.tsx +139 -71
- package/src/locales/arabic/adminLocalsAr.json +81 -344
- package/src/locales/arabic/common.json +11 -1
- package/src/locales/arabic/devLocalsAr.json +280 -0
- package/src/locales/arabic/index.ts +2 -0
- package/src/locales/english/adminLocalsEn.json +86 -346
- package/src/locales/english/common.json +11 -1
- package/src/locales/english/devLocalsEn.json +281 -0
- package/src/locales/english/index.ts +3 -0
- package/src/main.tsx +5 -6
- package/src/navigationItems/Administration/adminNavigationItems.tsx +65 -99
- package/src/navigationItems/Administration/index.tsx +10 -65
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +45 -12
- package/src/redux/features/common/AppLayoutSlice.ts +0 -8
- package/src/redux/features/common/CommonStoreSlice.ts +4 -0
- package/src/redux/features/common/SideBarSlice.ts +29 -0
- package/src/redux/features/common/UserSessionSlice.ts +15 -23
- package/src/redux/store.ts +1 -1
- package/src/routes/administration/adminRoutes.tsx +41 -222
- package/src/routes/administration/devRoutes.tsx +90 -0
- package/src/routes/administration/index.ts +5 -1
- package/src/routes/index.ts +1 -0
- package/src/styles/index.css +3 -3
- package/src/util/AppUtils.ts +5 -0
- package/vite.config.ts +14 -0
- package/src/components/admin/AttachmentGrid.tsx +0 -116
- package/src/components/admin/AuthorityGrid.tsx +0 -88
- package/src/components/admin/BluePrintGrid.tsx +0 -55
- package/src/components/admin/BluePrintPageGrid.tsx +0 -85
- package/src/components/admin/BluePrintPointGrid.tsx +0 -85
- package/src/components/admin/DashboardGrid.tsx +0 -95
- package/src/components/admin/DashboardWidgetGrid.tsx +0 -75
- package/src/components/admin/DataQueryGrid.tsx +0 -75
- package/src/components/admin/DataQueryParameterGrid.tsx +0 -98
- package/src/components/admin/DatasourceConnectionGrid.tsx +0 -98
- package/src/components/admin/EmployeeGrid.tsx +0 -105
- package/src/components/admin/EntityParameterGrid.tsx +0 -125
- package/src/components/admin/ExcelUploaderDetailGrid.tsx +0 -78
- package/src/components/admin/ExcelUploaderHeaderGrid.tsx +0 -78
- package/src/components/admin/LookupGrid.tsx +0 -95
- package/src/components/admin/MailAttachmentGrid.tsx +0 -65
- package/src/components/admin/MailBodyGrid.tsx +0 -105
- package/src/components/admin/MailRecipientGrid.tsx +0 -75
- package/src/components/admin/MailTemplateGrid.tsx +0 -145
- package/src/components/admin/NewTableGrid.tsx +0 -65
- package/src/components/admin/NotificationGrid.tsx +0 -115
- package/src/components/admin/NotificationQueueGrid.tsx +0 -125
- package/src/components/admin/OrganizationApplicationGrid.tsx +0 -81
- package/src/components/admin/OrganizationGrid.tsx +0 -65
- package/src/components/admin/OrganizationUnitGrid.tsx +0 -85
- package/src/components/admin/OrganizationUserGrid.tsx +0 -75
- package/src/components/admin/OrganizationUserRoleGrid.tsx +0 -98
- package/src/components/admin/ReportGrid.tsx +0 -155
- package/src/components/admin/ReportParameterGrid.tsx +0 -95
- package/src/components/admin/RoleAuthorityGrid.tsx +0 -65
- package/src/components/admin/RoleGrid.tsx +0 -132
- package/src/components/admin/UserAccountGrid.tsx +0 -65
- package/src/components/admin/UserRequestGrid.tsx +0 -145
- package/src/components/admin/WidgetGrid.tsx +0 -175
- package/src/components/admin/WorkflowDocumentActionGrid.tsx +0 -111
- package/src/components/admin/WorkflowDocumentActionHistoryGrid.tsx +0 -111
- package/src/components/admin/WorkflowDocumentActionMailGrid.tsx +0 -71
- package/src/components/admin/WorkflowDocumentGrid.tsx +0 -185
- package/src/components/admin/WorkflowDocumentStatusGrid.tsx +0 -121
- package/src/components/templates/visuals/TemplateDashboard.tsx +0 -126
- package/src/redux/features/CounterSlice.tsx +0 -13
|
@@ -7,6 +7,8 @@ import CheckBox from "./FormFields/CheckBox";
|
|
|
7
7
|
import { DATE_FORMAT, DATE_TIME_FORMAT } from "../../../../util/constants";
|
|
8
8
|
import { isNumeric } from "../../../../util/AppUtils";
|
|
9
9
|
import { FormElementFieldProps } from "../DataEntryTypes";
|
|
10
|
+
import HtmlEditor from "./FormFields/HtmlEditor";
|
|
11
|
+
import SystemLookupCombobox from "./FormFields/SystemLookupCombobox";
|
|
10
12
|
|
|
11
13
|
const FormElementField: React.FC<FormElementFieldProps> = (
|
|
12
14
|
element: FormElementFieldProps
|
|
@@ -21,8 +23,7 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
21
23
|
if (!(props && formManager && formValues && fieldName && fieldType)) {
|
|
22
24
|
return <></>;
|
|
23
25
|
}
|
|
24
|
-
return (
|
|
25
|
-
!element.hiddenFields.includes(fieldName) ? (
|
|
26
|
+
return !element.hiddenFields.includes(fieldName) ? (
|
|
26
27
|
<Grid2
|
|
27
28
|
size={
|
|
28
29
|
props?.formProps?.fieldSize || {
|
|
@@ -38,6 +39,7 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
38
39
|
>
|
|
39
40
|
{fieldType === "text" || fieldType === "number" ? (
|
|
40
41
|
<TemplateTextField
|
|
42
|
+
{...props.muiTextFieldProps}
|
|
41
43
|
fullWidth
|
|
42
44
|
type={fieldType}
|
|
43
45
|
disabled={
|
|
@@ -66,7 +68,15 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
66
68
|
);
|
|
67
69
|
}
|
|
68
70
|
}}
|
|
69
|
-
sx={
|
|
71
|
+
sx={{
|
|
72
|
+
"& .MuiInputBase-root": {
|
|
73
|
+
height: `${props?.formProps?.fieldHeight}px` || undefined,
|
|
74
|
+
},
|
|
75
|
+
"& .MuiInputBase-input": {
|
|
76
|
+
height: "100% !important", // forces full height usage
|
|
77
|
+
},
|
|
78
|
+
...props?.formProps?.style,
|
|
79
|
+
}}
|
|
70
80
|
error={formManager.formState.errors[fieldName] != undefined}
|
|
71
81
|
helperText={formManager?.formState?.errors[
|
|
72
82
|
fieldName
|
|
@@ -138,8 +148,8 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
138
148
|
}
|
|
139
149
|
}}
|
|
140
150
|
value={formValues[fieldName]}
|
|
141
|
-
checkedValue={props?.checkedValue ||
|
|
142
|
-
unCheckedValue={props?.unCheckedValue ||
|
|
151
|
+
checkedValue={props?.checkedValue || true}
|
|
152
|
+
unCheckedValue={props?.unCheckedValue || false}
|
|
143
153
|
disabled={
|
|
144
154
|
props?.disabled || element.disabledFields.includes(fieldName)
|
|
145
155
|
? true
|
|
@@ -179,6 +189,55 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
179
189
|
fieldName
|
|
180
190
|
]?.message?.toString()}
|
|
181
191
|
/>
|
|
192
|
+
) : props?.fieldType === "lookup" ? (
|
|
193
|
+
<SystemLookupCombobox
|
|
194
|
+
sx={props?.formProps?.style || { width: "100%" }}
|
|
195
|
+
label={props?.fieldLabel}
|
|
196
|
+
disabled={
|
|
197
|
+
props?.disabled || element.disabledFields.includes(fieldName)
|
|
198
|
+
? true
|
|
199
|
+
: false
|
|
200
|
+
}
|
|
201
|
+
onChangeCallBack={(v: any, selectedRecord: any) => {
|
|
202
|
+
let newValue = null;
|
|
203
|
+
if (v) {
|
|
204
|
+
newValue = v + "";
|
|
205
|
+
}
|
|
206
|
+
formManager.setValue(fieldName, newValue);
|
|
207
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
208
|
+
props?.formProps?.onValueChangeCallBack(
|
|
209
|
+
newValue,
|
|
210
|
+
formManager,
|
|
211
|
+
formActions,
|
|
212
|
+
selectedRecord
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}}
|
|
216
|
+
lookupType={props.lookupType}
|
|
217
|
+
value={formValues[fieldName]}
|
|
218
|
+
errorMessage={formManager?.formState?.errors[
|
|
219
|
+
fieldName
|
|
220
|
+
]?.message?.toString()}
|
|
221
|
+
/>
|
|
222
|
+
) : props?.fieldType === "html" ? (
|
|
223
|
+
<HtmlEditor
|
|
224
|
+
label={props.fieldLabel}
|
|
225
|
+
value={formValues[fieldName] || ""}
|
|
226
|
+
errorMessage={formManager?.formState?.errors[
|
|
227
|
+
fieldName
|
|
228
|
+
]?.message?.toString()}
|
|
229
|
+
setValue={(v) => {
|
|
230
|
+
formManager.setValue(fieldName, v);
|
|
231
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
232
|
+
props?.formProps?.onValueChangeCallBack(
|
|
233
|
+
v,
|
|
234
|
+
formManager,
|
|
235
|
+
formActions
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}}
|
|
239
|
+
maxLength={4000}
|
|
240
|
+
/>
|
|
182
241
|
) : (
|
|
183
242
|
<>Unknown field type</>
|
|
184
243
|
)}
|
|
@@ -7,17 +7,25 @@ import {
|
|
|
7
7
|
FormElementProps,
|
|
8
8
|
RecordAction,
|
|
9
9
|
} from "../DataEntryTypes";
|
|
10
|
+
import { useTranslation } from "react-i18next";
|
|
10
11
|
|
|
11
12
|
const FormElementGroup: React.FC<FormElementGroupProps> = (
|
|
12
13
|
props: FormElementGroupProps
|
|
13
14
|
) => {
|
|
15
|
+
const { t } = useTranslation();
|
|
14
16
|
return (
|
|
15
17
|
<>
|
|
16
18
|
<Grid2 container sx={props?.style} alignItems="flex-start">
|
|
17
19
|
{props?.label ? (
|
|
18
20
|
<Grid2
|
|
19
21
|
size={12}
|
|
20
|
-
sx={{
|
|
22
|
+
sx={{
|
|
23
|
+
padding: 1,
|
|
24
|
+
fontWeight: "bold",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "flex-start",
|
|
28
|
+
}}
|
|
21
29
|
>
|
|
22
30
|
{props?.icon ? (
|
|
23
31
|
<>
|
|
@@ -25,10 +33,10 @@ const FormElementGroup: React.FC<FormElementGroupProps> = (
|
|
|
25
33
|
icon={props.icon}
|
|
26
34
|
style={{ marginRight: 5, marginLeft: 5 }}
|
|
27
35
|
/>
|
|
28
|
-
<div>{props.label}</div>
|
|
36
|
+
<div>{t(props.label)}</div>
|
|
29
37
|
</>
|
|
30
38
|
) : (
|
|
31
|
-
<>{props.label}</>
|
|
39
|
+
<>{t(props.label)}</>
|
|
32
40
|
)}
|
|
33
41
|
</Grid2>
|
|
34
42
|
) : (
|
package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/CheckBox.tsx
CHANGED
|
@@ -40,7 +40,7 @@ const CheckBox: React.FC<CheckBoxProps> = (props) => {
|
|
|
40
40
|
) {
|
|
41
41
|
props.onChangeCallBack(props.checkedValue);
|
|
42
42
|
} else {
|
|
43
|
-
props.onChangeCallBack(
|
|
43
|
+
props.onChangeCallBack(true);
|
|
44
44
|
}
|
|
45
45
|
} else {
|
|
46
46
|
if (
|
|
@@ -49,7 +49,7 @@ const CheckBox: React.FC<CheckBoxProps> = (props) => {
|
|
|
49
49
|
) {
|
|
50
50
|
props.onChangeCallBack(props.unCheckedValue);
|
|
51
51
|
} else {
|
|
52
|
-
props.onChangeCallBack(
|
|
52
|
+
props.onChangeCallBack(false);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useSelector } from "react-redux";
|
|
2
|
-
import { RootState } from "../../../../../redux/store";
|
|
3
2
|
import { Autocomplete, Popper, TextField } from "@mui/material";
|
|
4
3
|
import { useTranslation } from "react-i18next";
|
|
5
4
|
|
|
@@ -17,7 +16,7 @@ interface ComboBoxProps {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
const ComboBox: React.FC<ComboBoxProps> = (props) => {
|
|
20
|
-
const AppLayoutState = useSelector((state:
|
|
19
|
+
const AppLayoutState = useSelector((state: any) => state.AppLayout);
|
|
21
20
|
const { t } = useTranslation();
|
|
22
21
|
const getValue = (v: string) => {
|
|
23
22
|
for (let option of props.options) {
|
package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/HtmlEditor.tsx
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { EditorState, convertToRaw } from "draft-js";
|
|
2
|
+
import { Editor } from "react-draft-wysiwyg";
|
|
3
|
+
import draftToHtml from "draftjs-to-html";
|
|
4
|
+
import { stateFromHTML } from "draft-js-import-html";
|
|
5
|
+
import { useState } from "react";
|
|
6
|
+
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
|
|
7
|
+
import { useEffect } from "react";
|
|
8
|
+
import { Box, Paper } from "@mui/material";
|
|
9
|
+
import { useTranslation } from "react-i18next";
|
|
10
|
+
|
|
11
|
+
type HtmlEditorProps = {
|
|
12
|
+
label?: string;
|
|
13
|
+
value: string;
|
|
14
|
+
setValue: (v: any) => void;
|
|
15
|
+
maxLength: number;
|
|
16
|
+
errorMessage?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const HtmlEditor: React.FC<HtmlEditorProps> = ({
|
|
20
|
+
label,
|
|
21
|
+
errorMessage,
|
|
22
|
+
value,
|
|
23
|
+
setValue,
|
|
24
|
+
maxLength,
|
|
25
|
+
}) => {
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
const options = {
|
|
28
|
+
customInlineFn: (element, { Style }) => {
|
|
29
|
+
if (element.style.color) {
|
|
30
|
+
return Style("color-" + element.style.color);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let contentState = stateFromHTML(value, options);
|
|
36
|
+
|
|
37
|
+
const [editorState, setEditorState] = useState(
|
|
38
|
+
EditorState.createWithContent(contentState)
|
|
39
|
+
);
|
|
40
|
+
let onEditorStateChange = (editorState) => {
|
|
41
|
+
let newData = draftToHtml(convertToRaw(editorState.getCurrentContent()));
|
|
42
|
+
console.log("Text Length " + newData.length);
|
|
43
|
+
if (newData.length > maxLength) {
|
|
44
|
+
let contentState = stateFromHTML(
|
|
45
|
+
newData.substring(0, maxLength),
|
|
46
|
+
options
|
|
47
|
+
);
|
|
48
|
+
setEditorState(EditorState.createWithContent(contentState));
|
|
49
|
+
return;
|
|
50
|
+
} else {
|
|
51
|
+
setEditorState(editorState);
|
|
52
|
+
}
|
|
53
|
+
setValue(draftToHtml(convertToRaw(editorState.getCurrentContent())));
|
|
54
|
+
};
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (value != draftToHtml(convertToRaw(editorState.getCurrentContent()))) {
|
|
57
|
+
setEditorState(
|
|
58
|
+
EditorState.createWithContent(stateFromHTML(value, options))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}, [value]);
|
|
62
|
+
const _getLengthOfSelectedText = () => {
|
|
63
|
+
const currentSelection = editorState.getSelection();
|
|
64
|
+
const isCollapsed = currentSelection.isCollapsed();
|
|
65
|
+
|
|
66
|
+
let length = 0;
|
|
67
|
+
|
|
68
|
+
if (!isCollapsed) {
|
|
69
|
+
const currentContent = editorState.getCurrentContent();
|
|
70
|
+
const startKey = currentSelection.getStartKey();
|
|
71
|
+
const endKey = currentSelection.getEndKey();
|
|
72
|
+
const startBlock = currentContent.getBlockForKey(startKey);
|
|
73
|
+
const isStartAndEndBlockAreTheSame = startKey === endKey;
|
|
74
|
+
const startBlockTextLength = startBlock.getLength();
|
|
75
|
+
const startSelectedTextLength =
|
|
76
|
+
startBlockTextLength - currentSelection.getStartOffset();
|
|
77
|
+
const endSelectedTextLength = currentSelection.getEndOffset();
|
|
78
|
+
const keyAfterEnd = currentContent.getKeyAfter(endKey);
|
|
79
|
+
if (isStartAndEndBlockAreTheSame) {
|
|
80
|
+
length +=
|
|
81
|
+
currentSelection.getEndOffset() - currentSelection.getStartOffset();
|
|
82
|
+
} else {
|
|
83
|
+
let currentKey = startKey;
|
|
84
|
+
|
|
85
|
+
while (currentKey && currentKey !== keyAfterEnd) {
|
|
86
|
+
if (currentKey === startKey) {
|
|
87
|
+
length += startSelectedTextLength + 1;
|
|
88
|
+
} else if (currentKey === endKey) {
|
|
89
|
+
length += endSelectedTextLength;
|
|
90
|
+
} else {
|
|
91
|
+
length += currentContent.getBlockForKey(currentKey).getLength() + 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
currentKey = currentContent.getKeyAfter(currentKey);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return length;
|
|
100
|
+
};
|
|
101
|
+
return (
|
|
102
|
+
<Paper
|
|
103
|
+
sx={{
|
|
104
|
+
display: "flex",
|
|
105
|
+
flexDirection: "column",
|
|
106
|
+
padding: 1,
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{label ? <Box>{t(label)}</Box> : <></>}
|
|
110
|
+
<Editor
|
|
111
|
+
editorState={editorState}
|
|
112
|
+
onEditorStateChange={onEditorStateChange}
|
|
113
|
+
handlePastedText={(pastedText) => {
|
|
114
|
+
const currentContent = editorState.getCurrentContent();
|
|
115
|
+
const currentContentLength = currentContent.getPlainText("").length;
|
|
116
|
+
const selectedTextLength = _getLengthOfSelectedText();
|
|
117
|
+
|
|
118
|
+
if (
|
|
119
|
+
currentContentLength + pastedText.length - selectedTextLength >
|
|
120
|
+
maxLength
|
|
121
|
+
) {
|
|
122
|
+
alert("max text length is " + maxLength);
|
|
123
|
+
return "handled";
|
|
124
|
+
}
|
|
125
|
+
}}
|
|
126
|
+
editorStyle={{
|
|
127
|
+
height: "200px", // 👈 set height of content area
|
|
128
|
+
border: "1px solid #F1F1F1",
|
|
129
|
+
padding: "10px",
|
|
130
|
+
overflow: "auto", // scroll if needed
|
|
131
|
+
}}
|
|
132
|
+
wrapperStyle={{ marginBottom: "1rem" }}
|
|
133
|
+
toolbarStyle={{ border: "1px solid #ccc" }}
|
|
134
|
+
/>
|
|
135
|
+
{errorMessage ? (
|
|
136
|
+
<Box sx={{ color: "red" }}>{t(errorMessage)}</Box>
|
|
137
|
+
) : (
|
|
138
|
+
<></>
|
|
139
|
+
)}
|
|
140
|
+
</Paper>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export default HtmlEditor;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useAxios, useSession } from "../../../../../hooks";
|
|
3
|
+
import ComboBox from "./ComboBox";
|
|
4
|
+
import { useSelector } from "react-redux";
|
|
5
|
+
|
|
6
|
+
type SystemLookupListProps = {
|
|
7
|
+
lookupType: string;
|
|
8
|
+
value: any;
|
|
9
|
+
onChangeCallBack: Function;
|
|
10
|
+
label: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
errorMessage?: any;
|
|
14
|
+
sx?: any;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const SystemLookupCombobox: React.FC<SystemLookupListProps> = (props) => {
|
|
18
|
+
const AppLayout = useSelector((state: any) => state.AppLayout);
|
|
19
|
+
const session = useSession();
|
|
20
|
+
const [options, setOptions] = useState<Array<any>>([]);
|
|
21
|
+
const { handleGetRequest } = useAxios();
|
|
22
|
+
|
|
23
|
+
const loadLookupOptions = async () => {
|
|
24
|
+
await handleGetRequest({
|
|
25
|
+
endPointURI: "api/v1/dev/system/lookup",
|
|
26
|
+
showMask: true,
|
|
27
|
+
parameters: { lookupType: props.lookupType },
|
|
28
|
+
successCallBkFn: (response: any) => {
|
|
29
|
+
setOptions(response.data);
|
|
30
|
+
},
|
|
31
|
+
failureCallBkFn: () => {
|
|
32
|
+
setOptions([]);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (props.lookupType) {
|
|
39
|
+
loadLookupOptions();
|
|
40
|
+
}
|
|
41
|
+
}, [props.lookupType, session.UserSession]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<ComboBox
|
|
45
|
+
{...props}
|
|
46
|
+
options={options}
|
|
47
|
+
displayField={
|
|
48
|
+
AppLayout.appDirection === "ltr" ? "lookupEnDisplay" : "lookupArDisplay"
|
|
49
|
+
}
|
|
50
|
+
valueField="lookupValue"
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default SystemLookupCombobox;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { TextField, TextFieldProps } from "@mui/material";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
2
3
|
|
|
3
4
|
const TemplateTextField: React.FC<Omit<TextFieldProps, "outlined">> = (
|
|
4
5
|
props
|
|
5
6
|
) => {
|
|
6
|
-
|
|
7
|
+
const { t } = useTranslation();
|
|
8
|
+
return (
|
|
9
|
+
<TextField
|
|
10
|
+
{...props}
|
|
11
|
+
slotProps={{ inputLabel: { shrink: true } }}
|
|
12
|
+
label={<>{props?.label ? t(props.label) : ""}</>}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
7
15
|
};
|
|
8
16
|
|
|
9
17
|
export default TemplateTextField;
|
|
@@ -16,17 +16,38 @@ import {
|
|
|
16
16
|
TemplateFormProps,
|
|
17
17
|
} from "../DataEntryTypes";
|
|
18
18
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
19
|
+
import { useTranslation } from "react-i18next";
|
|
19
20
|
|
|
20
21
|
const TemplateForm: React.FC<TemplateFormProps> = (
|
|
21
22
|
props: TemplateFormProps
|
|
22
23
|
) => {
|
|
24
|
+
const { t } = useTranslation();
|
|
23
25
|
const fields = getAllFields(props.elements);
|
|
24
|
-
const
|
|
26
|
+
const initiallyHiddenFields = [];
|
|
27
|
+
for (const field of fields) {
|
|
28
|
+
if (field?.hidden) {
|
|
29
|
+
initiallyHiddenFields.push(field.fieldName);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const [hiddenFields, setHiddenFields] = useState<string[]>(
|
|
33
|
+
initiallyHiddenFields
|
|
34
|
+
);
|
|
35
|
+
const initialValues: any = {};
|
|
36
|
+
for (const element of props.elements) {
|
|
37
|
+
if (
|
|
38
|
+
element?.type === "field" &&
|
|
39
|
+
element?.mode === "props" &&
|
|
40
|
+
element?.props?.defaultValue
|
|
41
|
+
) {
|
|
42
|
+
initialValues[element.props.fieldName] = element.props.defaultValue;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
25
45
|
const [disabledFields, setDisabledFields] = useState<string[]>([]);
|
|
26
46
|
const formSchema = z.object(constructValidationSchema(fields));
|
|
27
47
|
type FormData = z.infer<typeof formSchema>;
|
|
28
48
|
const formManager = useForm<FormData>({
|
|
29
49
|
resolver: zodResolver(formSchema),
|
|
50
|
+
defaultValues: initialValues,
|
|
30
51
|
});
|
|
31
52
|
const formValues = formManager.watch();
|
|
32
53
|
const pathParameters = useParams();
|
|
@@ -48,7 +69,23 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
48
69
|
);
|
|
49
70
|
if (retrievedRecord) {
|
|
50
71
|
formManager.reset({ ...retrievedRecord });
|
|
72
|
+
if (props?.formLoadCallBk) {
|
|
73
|
+
props?.formLoadCallBk(formActions, formManager, retrievedRecord);
|
|
74
|
+
}
|
|
75
|
+
for (const field of fields) {
|
|
76
|
+
if (
|
|
77
|
+
field?.fieldType === "combobox" &&
|
|
78
|
+
retrievedRecord[field.fieldName]
|
|
79
|
+
) {
|
|
80
|
+
formManager.setValue(
|
|
81
|
+
field.fieldName,
|
|
82
|
+
retrievedRecord[field.fieldName] + ""
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
51
86
|
}
|
|
87
|
+
} else {
|
|
88
|
+
formManager.reset({});
|
|
52
89
|
}
|
|
53
90
|
};
|
|
54
91
|
|
|
@@ -118,10 +155,11 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
118
155
|
}}
|
|
119
156
|
>
|
|
120
157
|
<Grid2 sx={{ width: "100%" }} container>
|
|
121
|
-
{props.elements.map((formElement: FormElementProps) => {
|
|
158
|
+
{props.elements.map((formElement: FormElementProps, index) => {
|
|
122
159
|
if (formElement.type === "group") {
|
|
123
160
|
return (
|
|
124
161
|
<FormElementGroup
|
|
162
|
+
key={index}
|
|
125
163
|
{...formElement.props}
|
|
126
164
|
formManager={formManager}
|
|
127
165
|
formValues={formValues}
|
|
@@ -136,6 +174,7 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
136
174
|
) {
|
|
137
175
|
return (
|
|
138
176
|
<FormElementField
|
|
177
|
+
key={index}
|
|
139
178
|
fieldInfo={formElement.props}
|
|
140
179
|
formManager={formManager}
|
|
141
180
|
formValues={formValues}
|
|
@@ -150,6 +189,7 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
150
189
|
) {
|
|
151
190
|
return (
|
|
152
191
|
<Grid2
|
|
192
|
+
key={index}
|
|
153
193
|
size={
|
|
154
194
|
formElement?.props?.formProps?.fieldSize || {
|
|
155
195
|
lg: 3,
|
|
@@ -220,7 +260,7 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
220
260
|
}
|
|
221
261
|
)}
|
|
222
262
|
>
|
|
223
|
-
{props?.saveButtonSpecs?.label || "
|
|
263
|
+
{t(props?.saveButtonSpecs?.label || "SAVE_BTN_LABEL")}
|
|
224
264
|
</Button>
|
|
225
265
|
<Button
|
|
226
266
|
variant={
|
|
@@ -243,10 +283,10 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
243
283
|
if (props?.formCloseCallBk) {
|
|
244
284
|
props.formCloseCallBk();
|
|
245
285
|
}
|
|
246
|
-
formManager.reset(
|
|
286
|
+
formManager.reset(initialValues);
|
|
247
287
|
}}
|
|
248
288
|
>
|
|
249
|
-
{props?.cancelButtonSpecs?.label || "
|
|
289
|
+
{t(props?.cancelButtonSpecs?.label || "CANCEL_BTN_LABEL")}
|
|
250
290
|
</Button>
|
|
251
291
|
</Box>
|
|
252
292
|
</>
|
package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx
CHANGED
|
@@ -76,6 +76,7 @@ export const generateDateTimeColumn: any = (colDef: TemplateGridColDef) => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
type ComboBoxColumnProps = TemplateGridColDef & {
|
|
79
|
+
lookupType?: string;
|
|
79
80
|
options: Array<any>;
|
|
80
81
|
displayField: string;
|
|
81
82
|
valueField: string;
|
|
@@ -113,9 +114,9 @@ export const generateComboColumn: (
|
|
|
113
114
|
<ComboBox
|
|
114
115
|
{...params}
|
|
115
116
|
sx={{ width: "100%" }}
|
|
116
|
-
options={colDef.options}
|
|
117
|
-
valueField={colDef.valueField}
|
|
118
|
-
displayField={colDef.displayField}
|
|
117
|
+
options={params.colDef.options}
|
|
118
|
+
valueField={params.colDef.valueField}
|
|
119
|
+
displayField={params.colDef.displayField}
|
|
119
120
|
onChangeCallBack={(v: any, selectedRecord: any) => {
|
|
120
121
|
if (v === null) {
|
|
121
122
|
params.api.setEditCellValue({
|
|
@@ -152,7 +153,7 @@ export const generateCheckBoxColumn: (
|
|
|
152
153
|
if (value == null || value == undefined) {
|
|
153
154
|
return null;
|
|
154
155
|
} else {
|
|
155
|
-
return value
|
|
156
|
+
return value;
|
|
156
157
|
}
|
|
157
158
|
},
|
|
158
159
|
renderCell: (parameters: any) => {
|
|
@@ -172,13 +173,13 @@ export const generateCheckBoxColumn: (
|
|
|
172
173
|
return (
|
|
173
174
|
<CheckBox
|
|
174
175
|
{...params}
|
|
175
|
-
checkedValue={colDef?.checkedValue ||
|
|
176
|
-
unCheckedValue={colDef?.unCheckedValue ||
|
|
176
|
+
checkedValue={colDef?.checkedValue || true}
|
|
177
|
+
unCheckedValue={colDef?.unCheckedValue || false}
|
|
177
178
|
onChangeCallBack={(v: any) => {
|
|
178
179
|
params.api.setEditCellValue({
|
|
179
180
|
id: params.id,
|
|
180
181
|
field: params.field,
|
|
181
|
-
value: v
|
|
182
|
+
value: v,
|
|
182
183
|
});
|
|
183
184
|
}}
|
|
184
185
|
/>
|