@asaleh37/ui-base 25.8.23 → 25.8.26
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 +3 -1
- 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 +1 -1
- package/src/components/administration/dev/EntityParameterGrid.tsx +1 -0
- package/src/components/administration/dev/MailRecipientGrid.tsx +2 -1
- package/src/components/administration/dev/MailSenderConfigGrid.tsx +1 -0
- package/src/components/administration/dev/ReportGrid.tsx +7 -5
- package/src/components/common/Login.tsx +5 -0
- package/src/components/index.ts +2 -0
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +1 -0
- package/src/components/templates/DataEntryTemplates/DataEntryUtil.ts +30 -0
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +1 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx +2 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +14 -4
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx +2 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid.tsx +16 -15
- package/src/components/templates/report/ExcelReportViewer.tsx +2 -1
- package/src/hooks/UseWindow.tsx +5 -1
- package/src/hooks/useAxios.tsx +10 -0
package/package.json
CHANGED
|
@@ -113,6 +113,7 @@ const MailRecipientGrid: React.FC<MailRecipientGridProps> = (props) => {
|
|
|
113
113
|
options: [{ value: "To" }, { value: "CC" }],
|
|
114
114
|
optionDisplayField: "value",
|
|
115
115
|
optionValueField: "value",
|
|
116
|
+
comboboxValueDataType: "string",
|
|
116
117
|
},
|
|
117
118
|
},
|
|
118
119
|
{
|
|
@@ -142,7 +143,7 @@ const MailRecipientGrid: React.FC<MailRecipientGridProps> = (props) => {
|
|
|
142
143
|
apiActions={apiActions}
|
|
143
144
|
data={data}
|
|
144
145
|
hideInfoBar={true}
|
|
145
|
-
gridLoadParametersValues={{mailTemplateId:props.selectedRecord.id}}
|
|
146
|
+
gridLoadParametersValues={{ mailTemplateId: props.selectedRecord.id }}
|
|
146
147
|
setData={setData}
|
|
147
148
|
editMode={{ editMode: "row" }}
|
|
148
149
|
formElements={formElements}
|
|
@@ -210,6 +210,7 @@ const MailSenderConfigGrid: React.FC = () => {
|
|
|
210
210
|
fieldName: "mailEngine",
|
|
211
211
|
required: true,
|
|
212
212
|
fieldType: "combobox",
|
|
213
|
+
comboboxValueDataType: "string",
|
|
213
214
|
options: [{ value: "Gmail" }, { value: "Azure" }],
|
|
214
215
|
optionDisplayField: "value",
|
|
215
216
|
optionValueField: "value",
|
|
@@ -61,7 +61,7 @@ const adjustFormAccordingToReportType = (
|
|
|
61
61
|
value: any,
|
|
62
62
|
formActions: FormActionProps,
|
|
63
63
|
formManager: UseFormReturn
|
|
64
|
-
) => {
|
|
64
|
+
) => {
|
|
65
65
|
if (value && validationObject[value]) {
|
|
66
66
|
const validationObjects: ReportValidationOptions = validationObject[value];
|
|
67
67
|
const fields = Object.keys(validationObjects);
|
|
@@ -208,6 +208,7 @@ const ReportGrid: React.FC = () => {
|
|
|
208
208
|
optionValueField: "value",
|
|
209
209
|
required: true,
|
|
210
210
|
fieldType: "combobox",
|
|
211
|
+
comboboxValueDataType: "string",
|
|
211
212
|
formProps: {
|
|
212
213
|
onValueChangeCallBack(
|
|
213
214
|
value,
|
|
@@ -247,6 +248,7 @@ const ReportGrid: React.FC = () => {
|
|
|
247
248
|
fieldLabel: "ATTACHMENT_CONFIG_STORAGE_TYPE",
|
|
248
249
|
fieldName: "storageType",
|
|
249
250
|
required: true,
|
|
251
|
+
comboboxValueDataType: "string",
|
|
250
252
|
fieldType: "combobox",
|
|
251
253
|
options: storageTypes,
|
|
252
254
|
optionDisplayField: "value",
|
|
@@ -354,10 +356,10 @@ const ReportGrid: React.FC = () => {
|
|
|
354
356
|
props: {
|
|
355
357
|
fieldLabel: "REPORT_REPORT_EXCEL_DATA_QUERY_ID",
|
|
356
358
|
fieldName: "reportExcelDataQueryId",
|
|
357
|
-
hidden: true,
|
|
358
|
-
gridProps: {
|
|
359
|
-
|
|
360
|
-
},
|
|
359
|
+
// hidden: true,
|
|
360
|
+
// gridProps: {
|
|
361
|
+
// hidden: true,
|
|
362
|
+
// },
|
|
361
363
|
required: false,
|
|
362
364
|
fieldType: "combobox",
|
|
363
365
|
options: SystemDataQueries,
|
|
@@ -53,6 +53,9 @@ const Login: React.FC = () => {
|
|
|
53
53
|
...response.data,
|
|
54
54
|
isAuthenticated: true,
|
|
55
55
|
};
|
|
56
|
+
if (response?.data?.token) {
|
|
57
|
+
localStorage.setItem("TOKEN", response.data.token);
|
|
58
|
+
}
|
|
56
59
|
dispatch(UserSessionActions.setAuthenticated(UserSession));
|
|
57
60
|
}
|
|
58
61
|
} catch (e: any) {
|
|
@@ -101,11 +104,13 @@ const Login: React.FC = () => {
|
|
|
101
104
|
const checkUserSession = async () => {
|
|
102
105
|
if (appInfo?.apiBaseUrl) {
|
|
103
106
|
if (userSession.isAuthenticated == null) {
|
|
107
|
+
const token = localStorage.getItem("TOKEN");
|
|
104
108
|
try {
|
|
105
109
|
let response = await axios.get(
|
|
106
110
|
`${appInfo.apiBaseUrl}/api/auth/userInfo`,
|
|
107
111
|
{
|
|
108
112
|
withCredentials: true,
|
|
113
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
109
114
|
}
|
|
110
115
|
);
|
|
111
116
|
if (response != null && response.data != null) {
|
package/src/components/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataGridPremium } from "@mui/x-data-grid-premium";
|
|
1
2
|
export * from "./BaseApp";
|
|
2
3
|
export * from "@mui/material";
|
|
3
4
|
export * from "@mui/lab";
|
|
@@ -6,3 +7,4 @@ export { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
6
7
|
export type { FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
|
|
7
8
|
export * from "./templates";
|
|
8
9
|
export * from "@mui/x-tree-view/models";
|
|
10
|
+
export { DataGridPremium } ;
|
|
@@ -197,6 +197,36 @@ export const constructValidationSchema = (fields: Array<RecordFieldProps>) => {
|
|
|
197
197
|
} else {
|
|
198
198
|
validationSchemaObj[fieldName] = z.boolean().optional().nullable();
|
|
199
199
|
}
|
|
200
|
+
} else if (field.fieldType === "combobox") {
|
|
201
|
+
if (field?.comboboxValueDataType) {
|
|
202
|
+
if (field?.comboboxValueDataType === "number") {
|
|
203
|
+
if (field?.required === true) {
|
|
204
|
+
validationSchemaObj[fieldName] = z.number({
|
|
205
|
+
required_error: "This field is required",
|
|
206
|
+
invalid_type_error: "This field must be a number",
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
validationSchemaObj[fieldName] = z.number().optional().nullable();
|
|
210
|
+
}
|
|
211
|
+
} else if (field?.comboboxValueDataType === "string") {
|
|
212
|
+
if (field?.required === true) {
|
|
213
|
+
validationSchemaObj[fieldName] = z
|
|
214
|
+
.string({ message: "This field is required" })
|
|
215
|
+
.min(1, "This field is required");
|
|
216
|
+
} else {
|
|
217
|
+
validationSchemaObj[fieldName] = z.string().optional().nullable();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
if (field?.required === true) {
|
|
222
|
+
validationSchemaObj[fieldName] = z.number({
|
|
223
|
+
required_error: "This field is required",
|
|
224
|
+
invalid_type_error: "This field must be a number",
|
|
225
|
+
});
|
|
226
|
+
} else {
|
|
227
|
+
validationSchemaObj[fieldName] = z.number().optional().nullable();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
200
230
|
} else {
|
|
201
231
|
if (field?.required === true) {
|
|
202
232
|
validationSchemaObj[fieldName] = z
|
|
@@ -229,7 +229,7 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
229
229
|
onChangeCallBack={(v: any, selectedRecord: any) => {
|
|
230
230
|
let newValue = null;
|
|
231
231
|
if (v) {
|
|
232
|
-
newValue = v
|
|
232
|
+
newValue = v;
|
|
233
233
|
}
|
|
234
234
|
formManager.setValue(fieldName, newValue);
|
|
235
235
|
if (props?.formProps?.onValueChangeCallBack) {
|
package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx
CHANGED
|
@@ -22,7 +22,7 @@ const ComboBox: React.FC<ComboBoxProps> = (props) => {
|
|
|
22
22
|
const getValue = (v: string) => {
|
|
23
23
|
for (let option of props.options) {
|
|
24
24
|
if (option[props.valueField] == v) {
|
|
25
|
-
return option
|
|
25
|
+
return option;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
return null;
|
|
@@ -41,7 +41,7 @@ const ComboBox: React.FC<ComboBoxProps> = (props) => {
|
|
|
41
41
|
) {
|
|
42
42
|
if (newValue != null) {
|
|
43
43
|
let v = newValue[props.valueField];
|
|
44
|
-
props.onChangeCallBack(v
|
|
44
|
+
props.onChangeCallBack(v, newValue);
|
|
45
45
|
} else {
|
|
46
46
|
props.onChangeCallBack(null, null);
|
|
47
47
|
}
|
|
@@ -100,10 +100,20 @@ const TemplateForm: React.FC<TemplateFormProps> = (
|
|
|
100
100
|
field?.fieldType === "combobox" &&
|
|
101
101
|
retrievedRecord[field.fieldName]
|
|
102
102
|
) {
|
|
103
|
-
|
|
104
|
-
field
|
|
105
|
-
|
|
106
|
-
)
|
|
103
|
+
if (
|
|
104
|
+
field?.comboboxValueDataType &&
|
|
105
|
+
field?.comboboxValueDataType === "string"
|
|
106
|
+
) {
|
|
107
|
+
formManager.setValue(
|
|
108
|
+
field.fieldName,
|
|
109
|
+
retrievedRecord[field.fieldName] + ""
|
|
110
|
+
);
|
|
111
|
+
} else {
|
|
112
|
+
formManager.setValue(
|
|
113
|
+
field.fieldName,
|
|
114
|
+
retrievedRecord[field.fieldName]
|
|
115
|
+
);
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
}
|
package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx
CHANGED
|
@@ -89,7 +89,7 @@ export const generateComboColumn: (
|
|
|
89
89
|
type: "custom",
|
|
90
90
|
valueGetter: (value) => {
|
|
91
91
|
if (value) {
|
|
92
|
-
return value
|
|
92
|
+
return value;
|
|
93
93
|
}
|
|
94
94
|
return value;
|
|
95
95
|
},
|
|
@@ -128,7 +128,7 @@ export const generateComboColumn: (
|
|
|
128
128
|
params.api.setEditCellValue({
|
|
129
129
|
id: params.id,
|
|
130
130
|
field: params.field,
|
|
131
|
-
value: v
|
|
131
|
+
value: v,
|
|
132
132
|
});
|
|
133
133
|
}}
|
|
134
134
|
/>
|
|
@@ -744,23 +744,24 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
|
|
|
744
744
|
}
|
|
745
745
|
};
|
|
746
746
|
|
|
747
|
-
const handleColumnWidthChange: GridEventListener<"columnWidthChange"> = (
|
|
748
|
-
|
|
749
|
-
) => {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
};
|
|
747
|
+
// const handleColumnWidthChange: GridEventListener<"columnWidthChange"> = (
|
|
748
|
+
// params: GridColumnResizeParams
|
|
749
|
+
// ) => {
|
|
750
|
+
// const updatedWidths = {
|
|
751
|
+
// ...columnWidths,
|
|
752
|
+
// [params.colDef.field]: params.width,
|
|
753
|
+
// };
|
|
754
|
+
// setColumnWidths(updatedWidths);
|
|
755
|
+
// if (props?.gridStateKey) {
|
|
756
|
+
// saveGridState(props.gridStateKey, { columnWidths: updatedWidths });
|
|
757
|
+
// }
|
|
758
|
+
// };
|
|
759
759
|
|
|
760
760
|
const adjustedColumns: Array<TemplateGridColDef> = React.useMemo(() => {
|
|
761
761
|
const baseCols = structuredColumns.map((col) => ({
|
|
762
762
|
...col,
|
|
763
|
-
|
|
763
|
+
minWidth: col?.width || 200,
|
|
764
|
+
flex: 1,
|
|
764
765
|
}));
|
|
765
766
|
|
|
766
767
|
// Reorder based on saved columnOrder
|
|
@@ -768,9 +769,9 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
|
|
|
768
769
|
const fieldToCol = new Map(baseCols.map((col) => [col.field, col]));
|
|
769
770
|
return columnOrder.map((field) => fieldToCol.get(field)!).filter(Boolean);
|
|
770
771
|
}
|
|
771
|
-
|
|
772
772
|
return baseCols;
|
|
773
773
|
}, [columnOrder, columnWidths, structuredColumns]);
|
|
774
|
+
|
|
774
775
|
return (
|
|
775
776
|
<>
|
|
776
777
|
<ConfirmationWindow />
|
|
@@ -984,7 +985,7 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
|
|
|
984
985
|
columnVisibilityModel={columnVisibilityModel}
|
|
985
986
|
onColumnVisibilityModelChange={handleColumnVisibilityChange}
|
|
986
987
|
onColumnOrderChange={handleColumnOrderChange}
|
|
987
|
-
onColumnWidthChange={handleColumnWidthChange}
|
|
988
|
+
// onColumnWidthChange={handleColumnWidthChange}
|
|
988
989
|
rowGroupingModel={gridRowGroupingModel}
|
|
989
990
|
onRowGroupingModelChange={(model: GridRowGroupingModel) => {
|
|
990
991
|
handleRowGroupChange(model);
|
package/src/hooks/UseWindow.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "@mui/material";
|
|
11
11
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
12
12
|
import { IconProp } from "@fortawesome/fontawesome-svg-core";
|
|
13
|
+
import { useSelector } from "react-redux";
|
|
13
14
|
|
|
14
15
|
export interface TemplateWindowProp {
|
|
15
16
|
height?: any;
|
|
@@ -27,7 +28,9 @@ interface WindowProps {
|
|
|
27
28
|
|
|
28
29
|
export const useWindow = (props: TemplateWindowProp) => {
|
|
29
30
|
const [windowState, setWindowState] = useState(false);
|
|
30
|
-
|
|
31
|
+
const appDirection = useSelector(
|
|
32
|
+
(state: any) => state.AppLayout.appDirection
|
|
33
|
+
);
|
|
31
34
|
const Window: React.FC<WindowProps> = (windowProps: WindowProps) => {
|
|
32
35
|
return (
|
|
33
36
|
<Modal
|
|
@@ -40,6 +43,7 @@ export const useWindow = (props: TemplateWindowProp) => {
|
|
|
40
43
|
}}
|
|
41
44
|
>
|
|
42
45
|
<Box
|
|
46
|
+
dir={appDirection}
|
|
43
47
|
sx={{
|
|
44
48
|
position: "absolute",
|
|
45
49
|
top: "50%",
|
package/src/hooks/useAxios.tsx
CHANGED
|
@@ -39,6 +39,16 @@ const useAxios = () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
axiosInstance.defaults.withCredentials = true;
|
|
42
|
+
axiosInstance.interceptors.request.use(
|
|
43
|
+
(config) => {
|
|
44
|
+
const token = localStorage.getItem("TOKEN");
|
|
45
|
+
if (token) {
|
|
46
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
47
|
+
}
|
|
48
|
+
return config;
|
|
49
|
+
},
|
|
50
|
+
(error) => Promise.reject(error)
|
|
51
|
+
);
|
|
42
52
|
axiosInstance.interceptors.response.use(
|
|
43
53
|
(response: any) => {
|
|
44
54
|
return response;
|