@asaleh37/ui-base 25.9.5-3 → 25.9.5-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 +9 -1
- package/dist/index.js +32 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +4 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +7 -1
- package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx +57 -2
- package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx +7 -3
package/package.json
CHANGED
|
@@ -202,6 +202,10 @@ export type RecordFieldProps = {
|
|
|
202
202
|
| "custom";
|
|
203
203
|
lookupType?: string;
|
|
204
204
|
comboboxValueDataType?: "number" | "string";
|
|
205
|
+
commonStoreKey?: string;
|
|
206
|
+
dataQueryId?: number;
|
|
207
|
+
storeUrl?: string;
|
|
208
|
+
storeLoadParam?: any;
|
|
205
209
|
required?: boolean;
|
|
206
210
|
disabled?: boolean;
|
|
207
211
|
hidden?: boolean;
|
|
@@ -252,7 +256,6 @@ export type FormElementFieldProps = {
|
|
|
252
256
|
hiddenFields?: string[];
|
|
253
257
|
disabledFields?: string[];
|
|
254
258
|
formValuesChangeCallBk?: FormValueChangeCallBk;
|
|
255
|
-
|
|
256
259
|
};
|
|
257
260
|
|
|
258
261
|
export type FormElementNodeProps = {
|
|
@@ -30,7 +30,7 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
30
30
|
return element?.fieldInfo?.fieldLabel;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
return (
|
|
33
|
+
return !element.hiddenFields.includes(fieldName) ? (
|
|
34
34
|
<Grid2
|
|
35
35
|
size={
|
|
36
36
|
props?.formProps?.fieldSize || {
|
|
@@ -165,6 +165,10 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
165
165
|
<ComboBox
|
|
166
166
|
sx={props?.formProps?.style || { width: "100%" }}
|
|
167
167
|
label={getFieldLabel()}
|
|
168
|
+
commonStoreKey={props?.commonStoreKey}
|
|
169
|
+
dataQueryId={props?.dataQueryId}
|
|
170
|
+
storeUrl={props?.storeUrl}
|
|
171
|
+
storeLoadParam={props?.storeLoadParam}
|
|
168
172
|
disabled={element.disabledFields.includes(fieldName)}
|
|
169
173
|
hidden={element.hiddenFields.includes(fieldName)}
|
|
170
174
|
onChangeCallBack={(v: any, selectedRecord: any) => {
|
|
@@ -223,6 +227,8 @@ const FormElementField: React.FC<FormElementFieldProps> = (
|
|
|
223
227
|
/>
|
|
224
228
|
) : null}
|
|
225
229
|
</Grid2>
|
|
230
|
+
) : (
|
|
231
|
+
<></>
|
|
226
232
|
);
|
|
227
233
|
} else {
|
|
228
234
|
return <></>;
|
package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/ComboBox.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useSelector } from "react-redux";
|
|
2
2
|
import { Autocomplete, Popper, TextField } from "@mui/material";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { useAxios } from "../../../../../hooks";
|
|
4
6
|
|
|
5
7
|
interface ComboBoxProps {
|
|
6
8
|
value: any;
|
|
@@ -8,7 +10,13 @@ interface ComboBoxProps {
|
|
|
8
10
|
label: string;
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
required?: boolean;
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
commonStoreKey?: string;
|
|
15
|
+
dataQueryId?: number;
|
|
16
|
+
storeUrl?: string;
|
|
17
|
+
storeLoadParam?: any;
|
|
18
|
+
|
|
19
|
+
options?: Array<any>;
|
|
12
20
|
errorMessage?: any;
|
|
13
21
|
hidden?: boolean;
|
|
14
22
|
displayField: string;
|
|
@@ -18,6 +26,53 @@ interface ComboBoxProps {
|
|
|
18
26
|
|
|
19
27
|
const ComboBox: React.FC<ComboBoxProps> = (props) => {
|
|
20
28
|
const AppLayoutState = useSelector((state: any) => state.AppLayout);
|
|
29
|
+
const [comboboxData, setComboboxData] = useState<Array<any>>(
|
|
30
|
+
props?.options || []
|
|
31
|
+
);
|
|
32
|
+
const commonStoreData = useSelector(
|
|
33
|
+
(state: any) => state?.commonStores?.stores[props?.commonStoreKey]?.data
|
|
34
|
+
);
|
|
35
|
+
const { handleGetRequest } = useAxios();
|
|
36
|
+
const loadComboboxData = async () => {
|
|
37
|
+
if (props?.storeUrl) {
|
|
38
|
+
await handleGetRequest({
|
|
39
|
+
endPointURI: props.storeUrl,
|
|
40
|
+
showMask: false,
|
|
41
|
+
parameters: props?.storeLoadParam,
|
|
42
|
+
successCallBkFn: (response) => {
|
|
43
|
+
setComboboxData(response.data);
|
|
44
|
+
},
|
|
45
|
+
failureCallBkFn: () => {
|
|
46
|
+
setComboboxData([]);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
} else if (props?.dataQueryId) {
|
|
50
|
+
await handleGetRequest({
|
|
51
|
+
endPointURI: "api/v1/dev/query/result",
|
|
52
|
+
showMask: false,
|
|
53
|
+
parameters: { queryId: props.dataQueryId, ...props?.storeLoadParam },
|
|
54
|
+
successCallBkFn: (response) => {
|
|
55
|
+
setComboboxData(response.data);
|
|
56
|
+
},
|
|
57
|
+
failureCallBkFn: () => {
|
|
58
|
+
setComboboxData([]);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (props?.commonStoreKey) {
|
|
65
|
+
setComboboxData(commonStoreData);
|
|
66
|
+
} else {
|
|
67
|
+
loadComboboxData();
|
|
68
|
+
}
|
|
69
|
+
}, [
|
|
70
|
+
props?.storeUrl,
|
|
71
|
+
props?.storeLoadParam,
|
|
72
|
+
props?.dataQueryId,
|
|
73
|
+
props?.commonStoreKey,
|
|
74
|
+
]);
|
|
75
|
+
|
|
21
76
|
const { t } = useTranslation();
|
|
22
77
|
const getValue = (v: string) => {
|
|
23
78
|
for (let option of props.options) {
|
|
@@ -31,7 +86,7 @@ const ComboBox: React.FC<ComboBoxProps> = (props) => {
|
|
|
31
86
|
<Autocomplete
|
|
32
87
|
sx={props.sx}
|
|
33
88
|
value={getValue(props.value)}
|
|
34
|
-
options={
|
|
89
|
+
options={comboboxData}
|
|
35
90
|
disabled={props.disabled}
|
|
36
91
|
hidden={props?.hidden || false}
|
|
37
92
|
onChange={(event, newValue) => {
|
package/src/components/templates/DataEntryTemplates/TemplateDataGrid/DataGridColumnsUtil.tsx
CHANGED
|
@@ -114,9 +114,13 @@ export const generateComboColumn: (
|
|
|
114
114
|
<ComboBox
|
|
115
115
|
{...params}
|
|
116
116
|
sx={{ width: "100%" }}
|
|
117
|
-
options={params
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
options={params?.colDef?.options}
|
|
118
|
+
commonStoreKey={params?.colDef?.commonStoreKey}
|
|
119
|
+
dataQueryId={params?.colDef?.dataQueryId}
|
|
120
|
+
storeUrl={params?.colDef?.storeUrl}
|
|
121
|
+
storeLoadParam={params?.colDef?.storeLoadParam}
|
|
122
|
+
valueField={params?.colDef?.valueField}
|
|
123
|
+
displayField={params?.colDef?.displayField}
|
|
120
124
|
onChangeCallBack={(v: any, selectedRecord: any) => {
|
|
121
125
|
if (v === null) {
|
|
122
126
|
params.api.setEditCellValue({
|