@asaleh37/ui-base 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/App.tsx +31 -0
- package/src/components/BaseApp.tsx +2 -3
- package/src/components/admin/AttachmentGrid.tsx +116 -0
- package/src/components/admin/AuthorityGrid.tsx +88 -0
- package/src/components/admin/BluePrintGrid.tsx +55 -0
- package/src/components/admin/BluePrintPageGrid.tsx +85 -0
- package/src/components/admin/BluePrintPointGrid.tsx +85 -0
- package/src/components/admin/DashboardGrid.tsx +95 -0
- package/src/components/admin/DashboardWidgetGrid.tsx +75 -0
- package/src/components/admin/DataQueryGrid.tsx +75 -0
- package/src/components/admin/DataQueryParameterGrid.tsx +98 -0
- package/src/components/admin/DatasourceConnectionGrid.tsx +98 -0
- package/src/components/admin/EmployeeGrid.tsx +105 -0
- package/src/components/admin/EntityParameterGrid.tsx +125 -0
- package/src/components/admin/ExcelUploaderDetailGrid.tsx +78 -0
- package/src/components/admin/ExcelUploaderHeaderGrid.tsx +78 -0
- package/src/components/admin/LookupGrid.tsx +95 -0
- package/src/components/admin/MailAttachmentGrid.tsx +65 -0
- package/src/components/admin/MailBodyGrid.tsx +105 -0
- package/src/components/admin/MailNotificationQueueGrid.tsx +131 -0
- package/src/components/admin/MailRecipientGrid.tsx +75 -0
- package/src/components/admin/MailTemplateGrid.tsx +145 -0
- package/src/components/admin/NewTableGrid.tsx +65 -0
- package/src/components/admin/NotificationGrid.tsx +115 -0
- package/src/components/admin/NotificationQueueGrid.tsx +125 -0
- package/src/components/admin/OrganizationApplicationGrid.tsx +81 -0
- package/src/components/admin/OrganizationGrid.tsx +65 -0
- package/src/components/admin/OrganizationRankGrid.tsx +85 -0
- package/src/components/admin/OrganizationUnitGrid.tsx +85 -0
- package/src/components/admin/OrganizationUserGrid.tsx +75 -0
- package/src/components/admin/OrganizationUserRoleGrid.tsx +98 -0
- package/src/components/admin/ReportGrid.tsx +155 -0
- package/src/components/admin/ReportParameterGrid.tsx +95 -0
- package/src/components/admin/RoleAuthorityGrid.tsx +65 -0
- package/src/components/admin/RoleGrid.tsx +78 -0
- package/src/components/admin/UserAccountGrid.tsx +65 -0
- package/src/components/admin/UserRequestGrid.tsx +145 -0
- package/src/components/admin/WidgetGrid.tsx +175 -0
- package/src/components/admin/WorkflowDocumentActionGrid.tsx +111 -0
- package/src/components/admin/WorkflowDocumentActionHistoryGrid.tsx +111 -0
- package/src/components/admin/WorkflowDocumentActionMailGrid.tsx +71 -0
- package/src/components/admin/WorkflowDocumentGrid.tsx +185 -0
- package/src/components/admin/WorkflowDocumentMailLogGrid.tsx +141 -0
- package/src/components/admin/WorkflowDocumentStatusGrid.tsx +121 -0
- package/src/components/common/Home.tsx +31 -0
- package/src/components/common/LanguageSwitcher.tsx +25 -0
- package/src/components/common/LayoutHandlers.tsx +12 -0
- package/src/components/common/LoadingMask.tsx +19 -0
- package/src/components/common/Login.tsx +183 -0
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +288 -0
- package/src/components/templates/DataEntryTemplates/DataEntryUtil.ts +201 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormAction.tsx +60 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +194 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementGroup.tsx +98 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/CheckBox.tsx +64 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx +94 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/Datefield.tsx +65 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/DatetimeField.tsx +64 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/FiltersPanel.tsx +237 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/TemplateTextField.tsx +9 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +256 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx +188 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid.tsx +844 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridMultiRecordAction.tsx +89 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridRecordAction.tsx +92 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridTopBar.tsx +228 -0
- package/src/components/templates/DataEntryTemplates/useApiActions.ts +125 -0
- package/src/components/templates/TransferList.tsx +250 -0
- package/src/components/templates/Window/ConfirmationWindow.tsx +55 -0
- package/src/components/templates/visuals/TemplateDashboard.tsx +126 -0
- package/src/components/templates/visuals/charts/TemplateBarChart.tsx +16 -0
- package/src/components/templates/visuals/charts/TemplateDataCard.tsx +60 -0
- package/src/components/templates/visuals/charts/TemplateGauge.tsx +16 -0
- package/src/components/templates/visuals/charts/TemplateLineChart.tsx +16 -0
- package/src/components/templates/visuals/charts/TemplateLineProgress.tsx +40 -0
- package/src/components/templates/visuals/charts/TemplatePieChart.tsx +25 -0
- package/src/hooks/UseConfirmationWindow.tsx +54 -0
- package/src/hooks/UseMobile.tsx +13 -0
- package/src/hooks/UseSession.tsx +26 -0
- package/src/hooks/UseWindow.tsx +106 -0
- package/src/hooks/useAxios.tsx +271 -0
- package/src/hooks/useLoadingMask.tsx +16 -0
- package/src/layout/DrawerHeader.tsx +10 -0
- package/src/layout/Layout.tsx +122 -0
- package/src/layout/MainContent.tsx +43 -0
- package/src/layout/MobileDrawer.tsx +103 -0
- package/src/layout/NavigationTree.tsx +284 -0
- package/src/layout/SideBar.tsx +80 -0
- package/src/layout/TopBar.tsx +142 -0
- package/src/locales/arabic/adminLocalsAr.json +356 -0
- package/src/locales/arabic/common.json +34 -0
- package/src/locales/arabic/index.ts +7 -0
- package/src/locales/english/adminLocalsEn.json +356 -0
- package/src/locales/english/common.json +33 -0
- package/src/locales/english/index.ts +6 -0
- package/src/locales/english/index.tsx +0 -0
- package/src/locales/i18n.ts +15 -0
- package/src/locales/index.ts +9 -0
- package/src/navigationItems/Administration/adminNavigationItems.tsx +182 -0
- package/src/navigationItems/Administration/index.tsx +71 -0
- package/src/navigationItems/common/CommonNavigationItems.tsx +12 -0
- package/src/navigationItems/common/index.tsx +7 -0
- package/src/navigationItems/index.tsx +34 -0
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +72 -0
- package/src/redux/features/business/BusinessStoresMetaData.ts +3 -0
- package/src/redux/features/business/CommonStoreSlice.ts +37 -0
- package/src/redux/features/common/AppInfoSlice.ts +30 -0
- package/src/redux/features/common/AppLayoutSlice.ts +37 -0
- package/src/redux/features/common/LoadingMaskSlice.ts +30 -0
- package/src/redux/features/common/UserSessionSlice.ts +62 -0
- package/src/redux/store.ts +10 -10
- package/src/routes/administration/adminRoutes.tsx +259 -0
- package/src/routes/administration/index.ts +4 -0
- package/src/routes/index.ts +11 -0
- package/src/routes/types/index.ts +5 -0
- package/src/styles/index.css +20 -0
- package/src/theme/DarkThemeOptions.ts +30 -0
- package/src/theme/LightThemeOptions.ts +34 -0
- package/src/util/AppUtils.ts +18 -0
- package/src/util/constants.ts +2 -0
- package/tsconfig.json +2 -2
- package/src/MyComponent1.tsx +0 -16
- package/src/components/Counter.tsx +0 -32
- package/src/redux/CounterSlice.ts +0 -17
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Button } from "@mui/material";
|
|
2
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
3
|
+
import { RecordAction } from "../DataEntryTypes";
|
|
4
|
+
import useSession from "../../../../hooks/UseSession";
|
|
5
|
+
import { useConfirmationWindow } from "../../../../hooks/UseConfirmationWindow";
|
|
6
|
+
|
|
7
|
+
const FormAction: React.FC<RecordAction> = (action: RecordAction) => {
|
|
8
|
+
const session = useSession();
|
|
9
|
+
const { ConfirmationWindow, setOpen: setConfirmationWindowState } =
|
|
10
|
+
useConfirmationWindow({
|
|
11
|
+
body: action?.confirmationMessage || "",
|
|
12
|
+
title: "Confirmation",
|
|
13
|
+
onConfirmationCallBk: () => {
|
|
14
|
+
action?.actionFn(action?.record);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (
|
|
18
|
+
action?.authority === undefined ||
|
|
19
|
+
action?.authority === null ||
|
|
20
|
+
session.isUserAuthorized(action.authority)
|
|
21
|
+
) {
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<ConfirmationWindow />
|
|
25
|
+
<Button
|
|
26
|
+
variant={action?.formActionProps?.actionButtonVariant}
|
|
27
|
+
color={action?.formActionProps?.actionButtonColor}
|
|
28
|
+
onClick={() => {
|
|
29
|
+
if (action?.actionFn) {
|
|
30
|
+
if (action?.preActionValidation) {
|
|
31
|
+
if (!action.preActionValidation(action.record)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (action?.isConfirmationRequired === true) {
|
|
36
|
+
setConfirmationWindowState(true);
|
|
37
|
+
} else {
|
|
38
|
+
action?.actionFn(action.record);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{action?.icon ? (
|
|
44
|
+
<FontAwesomeIcon
|
|
45
|
+
icon={action.icon}
|
|
46
|
+
style={{ marginRight: 5, marginLeft: 5 }}
|
|
47
|
+
/>
|
|
48
|
+
) : (
|
|
49
|
+
<></>
|
|
50
|
+
)}
|
|
51
|
+
<div>{action?.label}</div>
|
|
52
|
+
</Button>
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
return <></>;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default FormAction;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Grid2 } from "@mui/material";
|
|
2
|
+
import TemplateTextField from "./FormFields/TemplateTextField";
|
|
3
|
+
import Datefield from "./FormFields/Datefield";
|
|
4
|
+
import DatetimeField from "./FormFields/DatetimeField";
|
|
5
|
+
import ComboBox from "./FormFields/ComboBox";
|
|
6
|
+
import CheckBox from "./FormFields/CheckBox";
|
|
7
|
+
import { DATE_FORMAT, DATE_TIME_FORMAT } from "../../../../util/constants";
|
|
8
|
+
import { isNumeric } from "../../../../util/AppUtils";
|
|
9
|
+
import { FormElementFieldProps } from "../DataEntryTypes";
|
|
10
|
+
|
|
11
|
+
const FormElementField: React.FC<FormElementFieldProps> = (
|
|
12
|
+
element: FormElementFieldProps
|
|
13
|
+
) => {
|
|
14
|
+
if (element?.fieldInfo) {
|
|
15
|
+
const props = element.fieldInfo;
|
|
16
|
+
const formManager = element?.formManager || null;
|
|
17
|
+
const formActions = element?.formActions || null;
|
|
18
|
+
const formValues = element?.formValues || null;
|
|
19
|
+
const fieldName: any = element?.fieldInfo?.fieldName || null;
|
|
20
|
+
const fieldType = element?.fieldInfo?.fieldType || null;
|
|
21
|
+
if (!(props && formManager && formValues && fieldName && fieldType)) {
|
|
22
|
+
return <></>;
|
|
23
|
+
}
|
|
24
|
+
return (props?.hidden === undefined || !props?.hidden) &&
|
|
25
|
+
!element.hiddenFields.includes(fieldName) ? (
|
|
26
|
+
<Grid2
|
|
27
|
+
size={
|
|
28
|
+
props?.formProps?.fieldSize || {
|
|
29
|
+
lg: 12,
|
|
30
|
+
md: 12,
|
|
31
|
+
sm: 12,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
sx={{
|
|
35
|
+
padding: 1,
|
|
36
|
+
width: "100%",
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
{fieldType === "text" || fieldType === "number" ? (
|
|
40
|
+
<TemplateTextField
|
|
41
|
+
fullWidth
|
|
42
|
+
type={fieldType}
|
|
43
|
+
disabled={
|
|
44
|
+
props?.disabled || element.disabledFields.includes(fieldName)
|
|
45
|
+
? true
|
|
46
|
+
: false
|
|
47
|
+
}
|
|
48
|
+
hidden={props?.hidden || false}
|
|
49
|
+
label={props?.fieldLabel}
|
|
50
|
+
value={formValues[fieldName]}
|
|
51
|
+
onChange={(event) => {
|
|
52
|
+
let newValue = null;
|
|
53
|
+
if (event.target.value != "") {
|
|
54
|
+
if (fieldType === "number" && isNumeric(event.target.value)) {
|
|
55
|
+
newValue = Number(event.target.value);
|
|
56
|
+
} else {
|
|
57
|
+
newValue = event.target.value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
formManager.setValue(fieldName, newValue);
|
|
61
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
62
|
+
props?.formProps?.onValueChangeCallBack(
|
|
63
|
+
newValue,
|
|
64
|
+
formManager,
|
|
65
|
+
formActions
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
69
|
+
sx={props?.formProps?.style}
|
|
70
|
+
error={formManager.formState.errors[fieldName] != undefined}
|
|
71
|
+
helperText={formManager?.formState?.errors[
|
|
72
|
+
fieldName
|
|
73
|
+
]?.message?.toString()}
|
|
74
|
+
/>
|
|
75
|
+
) : props?.fieldType === "date" ? (
|
|
76
|
+
<Datefield
|
|
77
|
+
format={props?.dateFormat || DATE_FORMAT}
|
|
78
|
+
sx={props?.formProps?.style || { width: "100%" }}
|
|
79
|
+
disabled={
|
|
80
|
+
props?.disabled || element.disabledFields.includes(fieldName)
|
|
81
|
+
? true
|
|
82
|
+
: false
|
|
83
|
+
}
|
|
84
|
+
label={props?.fieldLabel}
|
|
85
|
+
onChangeCallBack={(v: any) => {
|
|
86
|
+
formManager.setValue(fieldName, v);
|
|
87
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
88
|
+
props?.formProps?.onValueChangeCallBack(
|
|
89
|
+
v,
|
|
90
|
+
formManager,
|
|
91
|
+
formActions
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}}
|
|
95
|
+
value={formValues[fieldName]}
|
|
96
|
+
error={formManager.formState.errors[fieldName] != undefined}
|
|
97
|
+
errorMessage={formManager?.formState?.errors[
|
|
98
|
+
fieldName
|
|
99
|
+
]?.message?.toString()}
|
|
100
|
+
/>
|
|
101
|
+
) : props?.fieldType === "datetime" ? (
|
|
102
|
+
<DatetimeField
|
|
103
|
+
format={props?.dateFormat || DATE_TIME_FORMAT}
|
|
104
|
+
sx={props?.formProps?.style || { width: "100%" }}
|
|
105
|
+
disabled={
|
|
106
|
+
props?.disabled || element.disabledFields.includes(fieldName)
|
|
107
|
+
? true
|
|
108
|
+
: false
|
|
109
|
+
}
|
|
110
|
+
label={props?.fieldLabel}
|
|
111
|
+
onChangeCallBack={(v: any) => {
|
|
112
|
+
formManager.setValue(fieldName, v);
|
|
113
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
114
|
+
props?.formProps?.onValueChangeCallBack(
|
|
115
|
+
v,
|
|
116
|
+
formManager,
|
|
117
|
+
formActions
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}}
|
|
121
|
+
value={formValues[fieldName]}
|
|
122
|
+
error={formManager.formState.errors[fieldName] != undefined}
|
|
123
|
+
errorMessage={formManager?.formState?.errors[
|
|
124
|
+
fieldName
|
|
125
|
+
]?.message?.toString()}
|
|
126
|
+
/>
|
|
127
|
+
) : props?.fieldType === "checkbox" ? (
|
|
128
|
+
<CheckBox
|
|
129
|
+
label={props?.fieldLabel}
|
|
130
|
+
onChangeCallBack={(v: any) => {
|
|
131
|
+
formManager.setValue(fieldName, v);
|
|
132
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
133
|
+
props?.formProps?.onValueChangeCallBack(
|
|
134
|
+
v,
|
|
135
|
+
formManager,
|
|
136
|
+
formActions
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}}
|
|
140
|
+
value={formValues[fieldName]}
|
|
141
|
+
checkedValue={props?.checkedValue || "true"}
|
|
142
|
+
unCheckedValue={props?.unCheckedValue || "false"}
|
|
143
|
+
disabled={
|
|
144
|
+
props?.disabled || element.disabledFields.includes(fieldName)
|
|
145
|
+
? true
|
|
146
|
+
: false
|
|
147
|
+
}
|
|
148
|
+
sx={props?.formProps?.style}
|
|
149
|
+
/>
|
|
150
|
+
) : props?.fieldType === "combobox" ? (
|
|
151
|
+
<ComboBox
|
|
152
|
+
sx={props?.formProps?.style || { width: "100%" }}
|
|
153
|
+
label={props?.fieldLabel}
|
|
154
|
+
disabled={
|
|
155
|
+
props?.disabled || element.disabledFields.includes(fieldName)
|
|
156
|
+
? true
|
|
157
|
+
: false
|
|
158
|
+
}
|
|
159
|
+
onChangeCallBack={(v: any, selectedRecord: any) => {
|
|
160
|
+
let newValue = null;
|
|
161
|
+
if (v) {
|
|
162
|
+
newValue = v + "";
|
|
163
|
+
}
|
|
164
|
+
formManager.setValue(fieldName, newValue);
|
|
165
|
+
if (props?.formProps?.onValueChangeCallBack) {
|
|
166
|
+
props?.formProps?.onValueChangeCallBack(
|
|
167
|
+
newValue,
|
|
168
|
+
formManager,
|
|
169
|
+
formActions,
|
|
170
|
+
selectedRecord
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}}
|
|
174
|
+
options={props?.options || []}
|
|
175
|
+
displayField={props?.optionDisplayField || ""}
|
|
176
|
+
valueField={props?.optionValueField || ""}
|
|
177
|
+
value={formValues[fieldName]}
|
|
178
|
+
errorMessage={formManager?.formState?.errors[
|
|
179
|
+
fieldName
|
|
180
|
+
]?.message?.toString()}
|
|
181
|
+
/>
|
|
182
|
+
) : (
|
|
183
|
+
<>Unknown field type</>
|
|
184
|
+
)}
|
|
185
|
+
</Grid2>
|
|
186
|
+
) : (
|
|
187
|
+
<></>
|
|
188
|
+
);
|
|
189
|
+
} else {
|
|
190
|
+
return <></>;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export default FormElementField;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Grid2 } from "@mui/material";
|
|
2
|
+
import FormElementField from "./FormElementField";
|
|
3
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
4
|
+
import FormAction from "./FormAction";
|
|
5
|
+
import {
|
|
6
|
+
FormElementGroupProps,
|
|
7
|
+
FormElementProps,
|
|
8
|
+
RecordAction,
|
|
9
|
+
} from "../DataEntryTypes";
|
|
10
|
+
|
|
11
|
+
const FormElementGroup: React.FC<FormElementGroupProps> = (
|
|
12
|
+
props: FormElementGroupProps
|
|
13
|
+
) => {
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<Grid2 container sx={props?.style} alignItems="flex-start">
|
|
17
|
+
{props?.label ? (
|
|
18
|
+
<Grid2
|
|
19
|
+
size={12}
|
|
20
|
+
sx={{ padding: 1, fontWeight: "bold", display: "flex" }}
|
|
21
|
+
>
|
|
22
|
+
{props?.icon ? (
|
|
23
|
+
<>
|
|
24
|
+
<FontAwesomeIcon
|
|
25
|
+
icon={props.icon}
|
|
26
|
+
style={{ marginRight: 5, marginLeft: 5 }}
|
|
27
|
+
/>
|
|
28
|
+
<div>{props.label}</div>
|
|
29
|
+
</>
|
|
30
|
+
) : (
|
|
31
|
+
<>{props.label}</>
|
|
32
|
+
)}
|
|
33
|
+
</Grid2>
|
|
34
|
+
) : (
|
|
35
|
+
<></>
|
|
36
|
+
)}
|
|
37
|
+
{props?.elements
|
|
38
|
+
? props.elements.map((element: FormElementProps) => {
|
|
39
|
+
if (element.type === "group") {
|
|
40
|
+
return (
|
|
41
|
+
<FormElementGroup
|
|
42
|
+
{...element.props}
|
|
43
|
+
formManager={props.formManager}
|
|
44
|
+
formValues={props.formValues}
|
|
45
|
+
formActions={props.formActions}
|
|
46
|
+
hiddenFields={props.hiddenFields}
|
|
47
|
+
disabledFields={props.disabledFields}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
} else if (element.type === "field" && element.mode === "props") {
|
|
51
|
+
return (
|
|
52
|
+
<FormElementField
|
|
53
|
+
fieldInfo={element.props}
|
|
54
|
+
formManager={props.formManager}
|
|
55
|
+
formValues={props.formValues}
|
|
56
|
+
formActions={props.formActions}
|
|
57
|
+
hiddenFields={props.hiddenFields}
|
|
58
|
+
disabledFields={props.disabledFields}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
} else if (element.type === "field" && element.mode === "node") {
|
|
62
|
+
return (
|
|
63
|
+
<Grid2
|
|
64
|
+
size={
|
|
65
|
+
element?.props?.formProps?.fieldSize || {
|
|
66
|
+
lg: 3,
|
|
67
|
+
md: 6,
|
|
68
|
+
sm: 12,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
sx={{ padding: 1, width: "100%" }}
|
|
72
|
+
>
|
|
73
|
+
<element.node
|
|
74
|
+
formManager={props.formManager}
|
|
75
|
+
formValues={props.formValues}
|
|
76
|
+
formActions={props.formActions}
|
|
77
|
+
/>
|
|
78
|
+
</Grid2>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
: null}
|
|
83
|
+
|
|
84
|
+
{props?.actions ? (
|
|
85
|
+
<Grid2 size={{ sm: 12 }} sx={{ padding: 1 }}>
|
|
86
|
+
{props.actions.map((action: RecordAction) => {
|
|
87
|
+
return <FormAction {...action} record={props.formValues} />;
|
|
88
|
+
})}
|
|
89
|
+
</Grid2>
|
|
90
|
+
) : (
|
|
91
|
+
<></>
|
|
92
|
+
)}
|
|
93
|
+
</Grid2>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default FormElementGroup;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Checkbox, FormControlLabel } from "@mui/material";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
|
|
4
|
+
interface CheckBoxProps {
|
|
5
|
+
value: any;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
label: string;
|
|
9
|
+
checkedValue?: any;
|
|
10
|
+
unCheckedValue?: any;
|
|
11
|
+
onChangeCallBack: Function;
|
|
12
|
+
sx?: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CheckBox: React.FC<CheckBoxProps> = (props) => {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
return (
|
|
18
|
+
<FormControlLabel
|
|
19
|
+
sx={props.sx}
|
|
20
|
+
disabled={props.disabled || false}
|
|
21
|
+
required={props.required || false}
|
|
22
|
+
control={
|
|
23
|
+
<Checkbox
|
|
24
|
+
checked={
|
|
25
|
+
props?.checkedValue == props.value ||
|
|
26
|
+
props.value === "true" ||
|
|
27
|
+
props.value == "1"
|
|
28
|
+
? true
|
|
29
|
+
: false
|
|
30
|
+
}
|
|
31
|
+
onChange={(e) => {
|
|
32
|
+
if (
|
|
33
|
+
props.onChangeCallBack !== undefined &&
|
|
34
|
+
props.onChangeCallBack != null
|
|
35
|
+
) {
|
|
36
|
+
if (e.target.checked) {
|
|
37
|
+
if (
|
|
38
|
+
props.checkedValue !== undefined &&
|
|
39
|
+
props.checkedValue != null
|
|
40
|
+
) {
|
|
41
|
+
props.onChangeCallBack(props.checkedValue);
|
|
42
|
+
} else {
|
|
43
|
+
props.onChangeCallBack("true");
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
if (
|
|
47
|
+
props.unCheckedValue !== undefined &&
|
|
48
|
+
props.unCheckedValue != null
|
|
49
|
+
) {
|
|
50
|
+
props.onChangeCallBack(props.unCheckedValue);
|
|
51
|
+
} else {
|
|
52
|
+
props.onChangeCallBack("false");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
58
|
+
}
|
|
59
|
+
label={t(props.label)}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default CheckBox;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useSelector } from "react-redux";
|
|
2
|
+
import { RootState } from "../../../../../redux/store";
|
|
3
|
+
import { Autocomplete, Popper, TextField } from "@mui/material";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
|
|
6
|
+
interface ComboBoxProps {
|
|
7
|
+
value: any;
|
|
8
|
+
onChangeCallBack: Function;
|
|
9
|
+
label: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
options: Array<any>;
|
|
13
|
+
errorMessage?: any;
|
|
14
|
+
displayField: string;
|
|
15
|
+
valueField: string;
|
|
16
|
+
sx?: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ComboBox: React.FC<ComboBoxProps> = (props) => {
|
|
20
|
+
const AppLayoutState = useSelector((state: RootState) => state.AppLayout);
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
const getValue = (v: string) => {
|
|
23
|
+
for (let option of props.options) {
|
|
24
|
+
if (option[props.valueField] == v) {
|
|
25
|
+
return option;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
return (
|
|
31
|
+
<Autocomplete
|
|
32
|
+
sx={props.sx}
|
|
33
|
+
value={getValue(props.value)}
|
|
34
|
+
options={props.options}
|
|
35
|
+
disabled={props.disabled}
|
|
36
|
+
onChange={(event, newValue) => {
|
|
37
|
+
if (
|
|
38
|
+
props.onChangeCallBack !== undefined &&
|
|
39
|
+
props.onChangeCallBack != null
|
|
40
|
+
) {
|
|
41
|
+
if (newValue != null) {
|
|
42
|
+
let v = newValue[props.valueField];
|
|
43
|
+
props.onChangeCallBack(v, newValue);
|
|
44
|
+
} else {
|
|
45
|
+
props.onChangeCallBack(null, null);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
clearOnBlur
|
|
50
|
+
handleHomeEndKeys
|
|
51
|
+
getOptionLabel={(option) => {
|
|
52
|
+
return option != null ? t(option[props.displayField]) : "";
|
|
53
|
+
}}
|
|
54
|
+
renderOption={(props1, option) => {
|
|
55
|
+
return (
|
|
56
|
+
<li {...props1}>
|
|
57
|
+
{option != null ? t(option[props.displayField]) : ""}
|
|
58
|
+
</li>
|
|
59
|
+
);
|
|
60
|
+
}}
|
|
61
|
+
slots={{
|
|
62
|
+
popper: (props: any) => (
|
|
63
|
+
<Popper
|
|
64
|
+
{...props}
|
|
65
|
+
style={{ ...props.style, direction: AppLayoutState.appDirection }}
|
|
66
|
+
/>
|
|
67
|
+
),
|
|
68
|
+
}}
|
|
69
|
+
renderInput={(params) => {
|
|
70
|
+
return (
|
|
71
|
+
<TextField
|
|
72
|
+
{...params}
|
|
73
|
+
required={props.required || false}
|
|
74
|
+
variant="outlined"
|
|
75
|
+
InputLabelProps={{ shrink: true }}
|
|
76
|
+
label={t(props.label)}
|
|
77
|
+
error={
|
|
78
|
+
props.errorMessage != null && props.errorMessage !== undefined
|
|
79
|
+
? true
|
|
80
|
+
: false
|
|
81
|
+
}
|
|
82
|
+
helperText={
|
|
83
|
+
props.errorMessage != null && props.errorMessage !== undefined
|
|
84
|
+
? t(props.errorMessage)
|
|
85
|
+
: ""
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default ComboBox;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers";
|
|
2
|
+
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
|
|
3
|
+
import moment from "moment";
|
|
4
|
+
import { DATE_FORMAT } from "../../../../../util/constants";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
|
|
7
|
+
interface DatefieldProps {
|
|
8
|
+
value: string | null;
|
|
9
|
+
label: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
sx?: any;
|
|
13
|
+
format?: string;
|
|
14
|
+
errorMessage?: any;
|
|
15
|
+
onChangeCallBack: Function;
|
|
16
|
+
[x: string | number | symbol]: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Datefield: React.FC<DatefieldProps> = (props) => {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
return (
|
|
22
|
+
<LocalizationProvider dateAdapter={AdapterMoment}>
|
|
23
|
+
<DatePicker
|
|
24
|
+
value={
|
|
25
|
+
props.value != null && props.value !== undefined && props.value !== ""
|
|
26
|
+
? moment(props.value, props?.format || DATE_FORMAT)
|
|
27
|
+
: null
|
|
28
|
+
}
|
|
29
|
+
sx={props.sx}
|
|
30
|
+
label={t(props.label)}
|
|
31
|
+
format={props?.format || DATE_FORMAT}
|
|
32
|
+
disabled={props.disabled}
|
|
33
|
+
onChange={(momentValue) => {
|
|
34
|
+
let v = null;
|
|
35
|
+
if (momentValue != null && momentValue.isValid()) {
|
|
36
|
+
v = momentValue.format(props?.format || DATE_FORMAT);
|
|
37
|
+
}
|
|
38
|
+
if (
|
|
39
|
+
props.onChangeCallBack !== undefined &&
|
|
40
|
+
props.onChangeCallBack != null
|
|
41
|
+
) {
|
|
42
|
+
props.onChangeCallBack(v);
|
|
43
|
+
}
|
|
44
|
+
}}
|
|
45
|
+
slotProps={{
|
|
46
|
+
textField: {
|
|
47
|
+
InputLabelProps: { shrink: true },
|
|
48
|
+
variant: "outlined",
|
|
49
|
+
required: props.required,
|
|
50
|
+
error:
|
|
51
|
+
props.errorMessage !== undefined && props.errorMessage != null,
|
|
52
|
+
helperText:
|
|
53
|
+
props.errorMessage !== undefined && props.errorMessage != null ? (
|
|
54
|
+
<>{t(props.errorMessage)}</>
|
|
55
|
+
) : (
|
|
56
|
+
<></>
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
</LocalizationProvider>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default Datefield;
|
package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/DatetimeField.tsx
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DateTimePicker, LocalizationProvider } from "@mui/x-date-pickers";
|
|
2
|
+
import { AdapterMoment } from "@mui/x-date-pickers/AdapterMoment";
|
|
3
|
+
import moment from "moment";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { DATE_TIME_FORMAT } from "../../../../../util/constants";
|
|
6
|
+
|
|
7
|
+
interface DatetimeFieldProps {
|
|
8
|
+
value: string | null;
|
|
9
|
+
label: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
format?: string;
|
|
13
|
+
sx?: any;
|
|
14
|
+
errorMessage?: any;
|
|
15
|
+
onChangeCallBack: Function;
|
|
16
|
+
[x: string | number | symbol]: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DatetimeField: React.FC<DatetimeFieldProps> = (props) => {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
return (
|
|
22
|
+
<LocalizationProvider dateAdapter={AdapterMoment}>
|
|
23
|
+
<DateTimePicker
|
|
24
|
+
value={
|
|
25
|
+
props.value != null && props.value !== undefined && props.value !== ""
|
|
26
|
+
? moment(props.value, props?.format || DATE_TIME_FORMAT)
|
|
27
|
+
: null
|
|
28
|
+
}
|
|
29
|
+
label={t(props.label)}
|
|
30
|
+
sx={props.sx}
|
|
31
|
+
format={props?.format || DATE_TIME_FORMAT}
|
|
32
|
+
disabled={props.disabled}
|
|
33
|
+
onChange={(momentValue) => {
|
|
34
|
+
let v = null;
|
|
35
|
+
if (momentValue != null && momentValue.isValid()) {
|
|
36
|
+
v = momentValue.format(props?.format || DATE_TIME_FORMAT);
|
|
37
|
+
}
|
|
38
|
+
if (
|
|
39
|
+
props.onChangeCallBack !== undefined &&
|
|
40
|
+
props.onChangeCallBack != null
|
|
41
|
+
) {
|
|
42
|
+
props.onChangeCallBack(v);
|
|
43
|
+
}
|
|
44
|
+
}}
|
|
45
|
+
slotProps={{
|
|
46
|
+
textField: {
|
|
47
|
+
variant: "outlined",
|
|
48
|
+
required: props.required,
|
|
49
|
+
error:
|
|
50
|
+
props.errorMessage !== undefined && props.errorMessage != null,
|
|
51
|
+
helperText:
|
|
52
|
+
props.errorMessage !== undefined && props.errorMessage != null ? (
|
|
53
|
+
<>{t(props.errorMessage)}</>
|
|
54
|
+
) : (
|
|
55
|
+
<></>
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
</LocalizationProvider>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default DatetimeField;
|