@asaleh37/ui-base 25.9.5 → 25.9.6-2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asaleh37/ui-base",
3
- "version": "25.9.5",
3
+ "version": "25.9.6-2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -35,7 +35,7 @@ const WorkflowDocumentGrid: React.FC = () => {
35
35
  const { t } = useTranslation();
36
36
  const [data, setData] = useState([]);
37
37
  const apiActions = useApiActions({
38
- findAll: "api/v1/dev/workflowdocument/all",
38
+ commonStoreKey:'SystemWorkflows',
39
39
  deleteById: "api/v1/dev/workflowdocument",
40
40
  save: "api/v1/dev/workflowdocument",
41
41
  findById: "api/v1/dev/workflowdocument",
@@ -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 = {
@@ -49,16 +49,7 @@ const FormElementField: React.FC<FormElementFieldProps> = (
49
49
  {...props.muiTextFieldProps}
50
50
  fullWidth
51
51
  type={fieldType}
52
- disabled={
53
- props?.disabled || element.disabledFields.includes(fieldName)
54
- ? true
55
- : false
56
- }
57
- // hidden={
58
- // props?.hidden || element.hiddenFields.includes(fieldName)
59
- // ? true
60
- // : false
61
- // }
52
+ disabled={element.disabledFields.includes(fieldName)}
62
53
  label={getFieldLabel()}
63
54
  value={formValues[fieldName]}
64
55
  onChange={(event) => {
@@ -89,6 +80,9 @@ const FormElementField: React.FC<FormElementFieldProps> = (
89
80
  height: "100% !important", // forces full height usage
90
81
  },
91
82
  ...props?.formProps?.style,
83
+ display: element.hiddenFields.includes(fieldName)
84
+ ? "none"
85
+ : undefined,
92
86
  }}
93
87
  error={formManager.formState.errors[fieldName] != undefined}
94
88
  helperText={formManager?.formState?.errors[
@@ -99,16 +93,8 @@ const FormElementField: React.FC<FormElementFieldProps> = (
99
93
  <Datefield
100
94
  format={props?.dateFormat || DATE_FORMAT}
101
95
  sx={props?.formProps?.style || { width: "100%" }}
102
- disabled={
103
- props?.disabled || element.disabledFields.includes(fieldName)
104
- ? true
105
- : false
106
- }
107
- // hidden={
108
- // props?.hidden || element.hiddenFields.includes(fieldName)
109
- // ? true
110
- // : false
111
- // }
96
+ disabled={element.disabledFields.includes(fieldName)}
97
+ hidden={element.hiddenFields.includes(fieldName)}
112
98
  label={getFieldLabel()}
113
99
  onChangeCallBack={(v: any) => {
114
100
  formManager.setValue(fieldName, v);
@@ -132,11 +118,8 @@ const FormElementField: React.FC<FormElementFieldProps> = (
132
118
  <DatetimeField
133
119
  format={props?.dateFormat || DATE_TIME_FORMAT}
134
120
  sx={props?.formProps?.style || { width: "100%" }}
135
- disabled={
136
- props?.disabled || element.disabledFields.includes(fieldName)
137
- ? true
138
- : false
139
- }
121
+ disabled={element.disabledFields.includes(fieldName)}
122
+ hidden={element.hiddenFields.includes(fieldName)}
140
123
  label={getFieldLabel()}
141
124
  onChangeCallBack={(v: any) => {
142
125
  formManager.setValue(fieldName, v);
@@ -150,11 +133,6 @@ const FormElementField: React.FC<FormElementFieldProps> = (
150
133
  );
151
134
  }
152
135
  }}
153
- // hidden={
154
- // props?.hidden || element.hiddenFields.includes(fieldName)
155
- // ? true
156
- // : false
157
- // }
158
136
  value={formValues[fieldName]}
159
137
  error={formManager.formState.errors[fieldName] != undefined}
160
138
  errorMessage={formManager?.formState?.errors[
@@ -176,35 +154,23 @@ const FormElementField: React.FC<FormElementFieldProps> = (
176
154
  );
177
155
  }
178
156
  }}
179
- // hidden={
180
- // props?.hidden || element.hiddenFields.includes(fieldName)
181
- // ? true
182
- // : false
183
- // }
184
157
  value={formValues[fieldName]}
185
158
  checkedValue={props?.checkedValue || true}
186
159
  unCheckedValue={props?.unCheckedValue || false}
187
- disabled={
188
- props?.disabled || element.disabledFields.includes(fieldName)
189
- ? true
190
- : false
191
- }
160
+ disabled={element.disabledFields.includes(fieldName)}
161
+ hidden={element.hiddenFields.includes(fieldName)}
192
162
  sx={props?.formProps?.style}
193
163
  />
194
164
  ) : props?.fieldType === "combobox" ? (
195
165
  <ComboBox
196
166
  sx={props?.formProps?.style || { width: "100%" }}
197
167
  label={getFieldLabel()}
198
- disabled={
199
- props?.disabled || element.disabledFields.includes(fieldName)
200
- ? true
201
- : false
202
- }
203
- // hidden={
204
- // props?.hidden || element.hiddenFields.includes(fieldName)
205
- // ? true
206
- // : false
207
- // }
168
+ commonStoreKey={props?.commonStoreKey}
169
+ dataQueryId={props?.dataQueryId}
170
+ storeUrl={props?.storeUrl}
171
+ storeLoadParam={props?.storeLoadParam}
172
+ disabled={element.disabledFields.includes(fieldName)}
173
+ hidden={element.hiddenFields.includes(fieldName)}
208
174
  onChangeCallBack={(v: any, selectedRecord: any) => {
209
175
  let newValue = null;
210
176
  if (v) {
@@ -234,16 +200,8 @@ const FormElementField: React.FC<FormElementFieldProps> = (
234
200
  <SystemLookupCombobox
235
201
  sx={props?.formProps?.style || { width: "100%" }}
236
202
  label={getFieldLabel()}
237
- disabled={
238
- props?.disabled || element.disabledFields.includes(fieldName)
239
- ? true
240
- : false
241
- }
242
- // hidden={
243
- // props?.hidden || element.hiddenFields.includes(fieldName)
244
- // ? true
245
- // : false
246
- // }
203
+ disabled={element.disabledFields.includes(fieldName)}
204
+ hidden={element.hiddenFields.includes(fieldName)}
247
205
  onChangeCallBack={(v: any, selectedRecord: any) => {
248
206
  let newValue = null;
249
207
  if (v) {
@@ -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
- options: Array<any>;
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={props.options}
89
+ options={comboboxData}
35
90
  disabled={props.disabled}
36
91
  hidden={props?.hidden || false}
37
92
  onChange={(event, newValue) => {
@@ -8,6 +8,7 @@ const TemplateTextField: React.FC<Omit<TextFieldProps, "outlined">> = (
8
8
  return (
9
9
  <TextField
10
10
  {...props}
11
+ hidden={true}
11
12
  slotProps={{ inputLabel: { shrink: true, sx: { fontWeight: "bold" } } }}
12
13
  label={<>{props?.label ? t(props.label) : ""}</>}
13
14
  helperText={props?.helperText ? t(props.helperText) : undefined}
@@ -33,28 +33,14 @@ const TemplateForm: React.FC<TemplateFormProps> = (
33
33
  minHeight: 500,
34
34
  minWidth: 400,
35
35
  });
36
- const { Window: WorkflowWindow, setWindowState: setWorkflowWindowState } =
37
- useWindow({
38
- windowTitle: "Approvals",
39
- windowIcon: "stamp",
40
- width: "fit-content",
41
- height: "fit-content",
42
- minHeight: 500,
43
- minWidth: 400,
44
- });
36
+
45
37
  const [attachmentPanelEnabledForRecord, setAttachmentPanelEnabledForRecord] =
46
38
  useState<boolean>(true);
47
39
  const { t } = useTranslation();
48
40
  const fields = getAllFields(props.elements);
49
- const initiallyHiddenFields = [];
50
- for (const field of fields) {
51
- if (field?.hidden) {
52
- initiallyHiddenFields.push(field.fieldName);
53
- }
54
- }
55
- const [hiddenFields, setHiddenFields] = useState<string[]>(
56
- initiallyHiddenFields
57
- );
41
+
42
+ const [disabledFields, setDisabledFields] = useState<string[]>([]);
43
+ const [hiddenFields, setHiddenFields] = useState<string[]>([]);
58
44
  const initialValues: any = {};
59
45
  for (const element of props.elements) {
60
46
  if (
@@ -65,7 +51,7 @@ const TemplateForm: React.FC<TemplateFormProps> = (
65
51
  initialValues[element.props.fieldName] = element.props.defaultValue;
66
52
  }
67
53
  }
68
- const [disabledFields, setDisabledFields] = useState<string[]>([]);
54
+
69
55
  let formSchema = null;
70
56
  if (props?.validationSchema) {
71
57
  formSchema = props.validationSchema;
@@ -149,6 +135,19 @@ const TemplateForm: React.FC<TemplateFormProps> = (
149
135
  }
150
136
  };
151
137
 
138
+ const { Window: WorkflowWindow, setWindowState: setWorkflowWindowState } =
139
+ useWindow({
140
+ windowTitle: "Approvals",
141
+ windowIcon: "stamp",
142
+ height: "fit-content",
143
+ minHeight: 500,
144
+ width: "fit-content",
145
+ // width: 1100,
146
+ onCloseCallBack: async () => {
147
+ await loadRecord();
148
+ },
149
+ });
150
+
152
151
  const formActions = {
153
152
  setFieldValue: (fieldName: string, fieldValue: any) => {
154
153
  formManager.setValue(fieldName, fieldValue);
@@ -179,6 +178,20 @@ const TemplateForm: React.FC<TemplateFormProps> = (
179
178
  },
180
179
  };
181
180
 
181
+ useEffect(() => {
182
+ const initiallyHiddenFields = [];
183
+ const initiallyDisabledFields = [];
184
+ for (const field of fields) {
185
+ if (field?.hidden) {
186
+ initiallyHiddenFields.push(field.fieldName);
187
+ }
188
+ if (field?.disabled) {
189
+ initiallyDisabledFields.push(field.fieldName);
190
+ }
191
+ }
192
+ setHiddenFields(initiallyHiddenFields);
193
+ setDisabledFields(initiallyDisabledFields);
194
+ }, [props.elements]);
182
195
  useEffect(() => {
183
196
  loadRecord();
184
197
  }, [props?.recordIdToEdit]);
@@ -114,9 +114,13 @@ export const generateComboColumn: (
114
114
  <ComboBox
115
115
  {...params}
116
116
  sx={{ width: "100%" }}
117
- options={params.colDef.options}
118
- valueField={params.colDef.valueField}
119
- displayField={params.colDef.displayField}
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({
@@ -101,11 +101,11 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
101
101
  const { Window: WorkFlowWindow, setWindowState: setWorkFlowWindowState } =
102
102
  useWindow({
103
103
  windowTitle: t(props.gridTitle) + " Approvals",
104
- windowIcon: "stamp",
105
- width: "fit-content",
104
+ windowIcon: "stamp",
106
105
  height: "fit-content",
107
106
  minHeight: 500,
108
- minWidth: "80%",
107
+ width: "fit-content",
108
+ // width:1100,
109
109
  onCloseCallBack: () => {
110
110
  props?.apiActions?.reloadData(props.gridLoadParametersValues);
111
111
  },
@@ -929,7 +929,7 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
929
929
  <></>
930
930
  )}
931
931
  {props?.workFlowDocumentCode ? (
932
- <WorkFlowWindow>
932
+ <WorkFlowWindow >
933
933
  <WorkflowDocumentPanel
934
934
  workFlowDocumentCode={props.workFlowDocumentCode}
935
935
  refDocumentId={selectedRecord[props?.keyColumnName || "id"]}
@@ -93,8 +93,7 @@ const AttachmentPanel: React.FC<AttachmentPanelProps> = (props) => {
93
93
  if (!files) {
94
94
  toast.error("You must add files to upload");
95
95
  return;
96
- }
97
- debugger;
96
+ }
98
97
  for (const file of files) {
99
98
  if (file.type.startsWith("image/")) {
100
99
  const MAX_SIZE_KB = 600;
@@ -176,6 +175,7 @@ const AttachmentPanel: React.FC<AttachmentPanelProps> = (props) => {
176
175
  display: "flex",
177
176
  flexDirection: "column",
178
177
  width: "100%",
178
+ minHeight:400,
179
179
  alignItems: "center",
180
180
  justifyContent: "flex-start",
181
181
  overflow: "hidden",
@@ -347,7 +347,7 @@ const WorkflowDocumentPanel: React.FC<WorkflowDocumentPanelProps> = (props) => {
347
347
  <Box
348
348
  sx={{
349
349
  flex: 1,
350
- width: "100%",
350
+ width: "100%",
351
351
  overflow: "hidden",
352
352
  display: "flex",
353
353
  // flexDirection: "column",
@@ -358,7 +358,7 @@ const WorkflowDocumentPanel: React.FC<WorkflowDocumentPanelProps> = (props) => {
358
358
  sx={{
359
359
  padding: 2,
360
360
  display: "flex",
361
- flex: 1,
361
+ // flex: 1,
362
362
  margin: 1,
363
363
  flexDirection: "column",
364
364
  alignItems: "center",
@@ -562,8 +562,8 @@ const WorkflowDocumentPanel: React.FC<WorkflowDocumentPanelProps> = (props) => {
562
562
  <Paper
563
563
  sx={{
564
564
  display: "flex",
565
- flexDirection: "column",
566
- flexGrow: 1,
565
+ flexDirection: "column",
566
+ width:600,
567
567
  padding: 2,
568
568
  margin: 1,
569
569
  alignItems: "center",
@@ -20,7 +20,8 @@ const WorkflowDocumentTimeLine: React.FC<WorkflowDocumentTimeLineProp> = (
20
20
  sx={{
21
21
  display: "flex",
22
22
  flexDirection: "column",
23
- flexGrow: 1,
23
+ // flexGrow: 1,
24
+ width: 600,
24
25
  padding: 1,
25
26
  margin: 1,
26
27
  alignItems: "center",
@@ -25,6 +25,11 @@ export const ADMINISTRATION_STORES: CommonStores = {
25
25
  url: "",
26
26
  data: [{ value: "Excel" }, { value: "Jasper" }, { value: "Blueprint" }],
27
27
  },
28
+ SystemWorkflows: {
29
+ autoLoad: true,
30
+ url: "api/v1/dev/workflowdocument/all",
31
+ data: [],
32
+ },
28
33
  SystemWidgetTypes: {
29
34
  autoLoad: false,
30
35
  url: "",