@asaleh37/ui-base 25.8.26 → 25.8.31-1

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.
Files changed (35) hide show
  1. package/dist/index.d.ts +22 -6
  2. package/dist/index.js +5 -5
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +6 -6
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/administration/dev/AttachmentConfigGrid.tsx +1 -0
  8. package/src/components/administration/dev/DataQueryGrid.tsx +26 -16
  9. package/src/components/administration/dev/DatasourceConnectionGrid.tsx +1 -0
  10. package/src/components/administration/dev/EntityParameterGrid.tsx +94 -67
  11. package/src/components/administration/dev/MailSenderConfigGrid.tsx +1 -0
  12. package/src/components/administration/dev/MailTemplateGrid.tsx +1 -0
  13. package/src/components/administration/dev/NotificationGrid.tsx +5 -2
  14. package/src/components/administration/dev/ReportGrid.tsx +102 -111
  15. package/src/components/administration/dev/WidgetGrid.tsx +96 -147
  16. package/src/components/administration/dev/WorkflowDocumentGrid.tsx +2 -23
  17. package/src/components/templates/DataEntryTemplates/DataEntryTypes.ts +41 -16
  18. package/src/components/templates/DataEntryTemplates/DataEntryUtil.ts +20 -10
  19. package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormElementField.tsx +80 -60
  20. package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/Datefield.tsx +1 -1
  21. package/src/components/templates/DataEntryTemplates/TemplateDataForm/FormFields/DatetimeField.tsx +1 -1
  22. package/src/components/templates/DataEntryTemplates/TemplateDataForm/TemplateForm.tsx +83 -65
  23. package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGrid.tsx +8 -5
  24. package/src/components/templates/DataEntryTemplates/TemplateDataGrid/TemplateGridTopBar.tsx +3 -1
  25. package/src/components/templates/report/ReportViewer.tsx +24 -138
  26. package/src/components/templates/visuals/DashboardViewer.tsx +49 -5
  27. package/src/components/templates/visuals/WidgetViewer.tsx +24 -14
  28. package/src/examples/ExampleGrid.tsx +134 -0
  29. package/src/hooks/useParameterPanel.tsx +168 -0
  30. package/src/layout/MainContent.tsx +47 -50
  31. package/src/locales/arabic/devLocalsAr.json +2 -2
  32. package/src/locales/english/devLocalsEn.json +2 -2
  33. package/src/navigationItems/index.tsx +1 -1
  34. package/src/routes/index.ts +1 -1
  35. package/src/util/AppUtils.ts +2 -0
@@ -22,6 +22,14 @@ const FormElementField: React.FC<FormElementFieldProps> = (
22
22
  if (!(props && formManager && formValues && fieldName && fieldType)) {
23
23
  return <></>;
24
24
  }
25
+
26
+ const getFieldLabel = () => {
27
+ if (element?.fieldInfo?.formProps?.fieldLabelFn) {
28
+ return element.fieldInfo.formProps.fieldLabelFn(formValues);
29
+ } else if (element?.fieldInfo?.fieldLabel) {
30
+ return element?.fieldInfo?.fieldLabel;
31
+ }
32
+ };
25
33
  return !element.hiddenFields.includes(fieldName) ? (
26
34
  <Grid2
27
35
  size={
@@ -46,12 +54,12 @@ const FormElementField: React.FC<FormElementFieldProps> = (
46
54
  ? true
47
55
  : false
48
56
  }
49
- hidden={
50
- props?.hidden || element.hiddenFields.includes(fieldName)
51
- ? true
52
- : false
53
- }
54
- label={props?.fieldLabel}
57
+ // hidden={
58
+ // props?.hidden || element.hiddenFields.includes(fieldName)
59
+ // ? true
60
+ // : false
61
+ // }
62
+ label={getFieldLabel()}
55
63
  value={formValues[fieldName]}
56
64
  onChange={(event) => {
57
65
  let newValue = null;
@@ -63,11 +71,13 @@ const FormElementField: React.FC<FormElementFieldProps> = (
63
71
  }
64
72
  }
65
73
  formManager.setValue(fieldName, newValue);
66
- if (props?.formProps?.onValueChangeCallBack) {
67
- props?.formProps?.onValueChangeCallBack(
68
- newValue,
74
+ if (element?.formValuesChangeCallBk) {
75
+ element?.formValuesChangeCallBk(
76
+ formValues,
77
+ formActions,
69
78
  formManager,
70
- formActions
79
+ fieldName,
80
+ newValue
71
81
  );
72
82
  }
73
83
  }}
@@ -94,19 +104,21 @@ const FormElementField: React.FC<FormElementFieldProps> = (
94
104
  ? true
95
105
  : false
96
106
  }
97
- hidden={
98
- props?.hidden || element.hiddenFields.includes(fieldName)
99
- ? true
100
- : false
101
- }
102
- label={props?.fieldLabel}
107
+ // hidden={
108
+ // props?.hidden || element.hiddenFields.includes(fieldName)
109
+ // ? true
110
+ // : false
111
+ // }
112
+ label={getFieldLabel()}
103
113
  onChangeCallBack={(v: any) => {
104
114
  formManager.setValue(fieldName, v);
105
- if (props?.formProps?.onValueChangeCallBack) {
106
- props?.formProps?.onValueChangeCallBack(
107
- v,
115
+ if (element?.formValuesChangeCallBk) {
116
+ element?.formValuesChangeCallBk(
117
+ formValues,
118
+ formActions,
108
119
  formManager,
109
- formActions
120
+ fieldName,
121
+ v
110
122
  );
111
123
  }
112
124
  }}
@@ -125,22 +137,24 @@ const FormElementField: React.FC<FormElementFieldProps> = (
125
137
  ? true
126
138
  : false
127
139
  }
128
- label={props?.fieldLabel}
140
+ label={getFieldLabel()}
129
141
  onChangeCallBack={(v: any) => {
130
142
  formManager.setValue(fieldName, v);
131
- if (props?.formProps?.onValueChangeCallBack) {
132
- props?.formProps?.onValueChangeCallBack(
133
- v,
143
+ if (element?.formValuesChangeCallBk) {
144
+ element?.formValuesChangeCallBk(
145
+ formValues,
146
+ formActions,
134
147
  formManager,
135
- formActions
148
+ fieldName,
149
+ v
136
150
  );
137
151
  }
138
152
  }}
139
- hidden={
140
- props?.hidden || element.hiddenFields.includes(fieldName)
141
- ? true
142
- : false
143
- }
153
+ // hidden={
154
+ // props?.hidden || element.hiddenFields.includes(fieldName)
155
+ // ? true
156
+ // : false
157
+ // }
144
158
  value={formValues[fieldName]}
145
159
  error={formManager.formState.errors[fieldName] != undefined}
146
160
  errorMessage={formManager?.formState?.errors[
@@ -149,22 +163,24 @@ const FormElementField: React.FC<FormElementFieldProps> = (
149
163
  />
150
164
  ) : props?.fieldType === "checkbox" ? (
151
165
  <CheckBox
152
- label={props?.fieldLabel}
166
+ label={getFieldLabel()}
153
167
  onChangeCallBack={(v: any) => {
154
168
  formManager.setValue(fieldName, v);
155
- if (props?.formProps?.onValueChangeCallBack) {
156
- props?.formProps?.onValueChangeCallBack(
157
- v,
169
+ if (element?.formValuesChangeCallBk) {
170
+ element?.formValuesChangeCallBk(
171
+ formValues,
172
+ formActions,
158
173
  formManager,
159
- formActions
174
+ fieldName,
175
+ v
160
176
  );
161
177
  }
162
178
  }}
163
- hidden={
164
- props?.hidden || element.hiddenFields.includes(fieldName)
165
- ? true
166
- : false
167
- }
179
+ // hidden={
180
+ // props?.hidden || element.hiddenFields.includes(fieldName)
181
+ // ? true
182
+ // : false
183
+ // }
168
184
  value={formValues[fieldName]}
169
185
  checkedValue={props?.checkedValue || true}
170
186
  unCheckedValue={props?.unCheckedValue || false}
@@ -178,28 +194,30 @@ const FormElementField: React.FC<FormElementFieldProps> = (
178
194
  ) : props?.fieldType === "combobox" ? (
179
195
  <ComboBox
180
196
  sx={props?.formProps?.style || { width: "100%" }}
181
- label={props?.fieldLabel}
197
+ label={getFieldLabel()}
182
198
  disabled={
183
199
  props?.disabled || element.disabledFields.includes(fieldName)
184
200
  ? true
185
201
  : false
186
202
  }
187
- hidden={
188
- props?.hidden || element.hiddenFields.includes(fieldName)
189
- ? true
190
- : false
191
- }
203
+ // hidden={
204
+ // props?.hidden || element.hiddenFields.includes(fieldName)
205
+ // ? true
206
+ // : false
207
+ // }
192
208
  onChangeCallBack={(v: any, selectedRecord: any) => {
193
209
  let newValue = null;
194
210
  if (v) {
195
211
  newValue = v;
196
212
  }
197
213
  formManager.setValue(fieldName, newValue);
198
- if (props?.formProps?.onValueChangeCallBack) {
199
- props?.formProps?.onValueChangeCallBack(
200
- newValue,
201
- formManager,
214
+ if (element?.formValuesChangeCallBk) {
215
+ element?.formValuesChangeCallBk(
216
+ formValues,
202
217
  formActions,
218
+ formManager,
219
+ fieldName,
220
+ v,
203
221
  selectedRecord
204
222
  );
205
223
  }
@@ -215,28 +233,30 @@ const FormElementField: React.FC<FormElementFieldProps> = (
215
233
  ) : props?.fieldType === "lookup" ? (
216
234
  <SystemLookupCombobox
217
235
  sx={props?.formProps?.style || { width: "100%" }}
218
- label={props?.fieldLabel}
236
+ label={getFieldLabel()}
219
237
  disabled={
220
238
  props?.disabled || element.disabledFields.includes(fieldName)
221
239
  ? true
222
240
  : false
223
241
  }
224
- hidden={
225
- props?.hidden || element.hiddenFields.includes(fieldName)
226
- ? true
227
- : false
228
- }
242
+ // hidden={
243
+ // props?.hidden || element.hiddenFields.includes(fieldName)
244
+ // ? true
245
+ // : false
246
+ // }
229
247
  onChangeCallBack={(v: any, selectedRecord: any) => {
230
248
  let newValue = null;
231
249
  if (v) {
232
250
  newValue = v;
233
251
  }
234
252
  formManager.setValue(fieldName, newValue);
235
- if (props?.formProps?.onValueChangeCallBack) {
236
- props?.formProps?.onValueChangeCallBack(
237
- newValue,
238
- formManager,
253
+ if (element?.formValuesChangeCallBk) {
254
+ element?.formValuesChangeCallBk(
255
+ formValues,
239
256
  formActions,
257
+ formManager,
258
+ fieldName,
259
+ v,
240
260
  selectedRecord
241
261
  );
242
262
  }
@@ -31,7 +31,7 @@ const Datefield: React.FC<DatefieldProps> = (props) => {
31
31
  ? moment(props.value, props?.format || DATE_FORMAT)
32
32
  : null
33
33
  }
34
- sx={props.sx}
34
+ sx={{ ...props.sx, display: props?.hidden ? "none" : undefined }}
35
35
  label={t(props.label)}
36
36
  format={props?.format || DATE_FORMAT}
37
37
  disabled={props.disabled}
@@ -33,7 +33,7 @@ const DatetimeField: React.FC<DatetimeFieldProps> = (props) => {
33
33
  : null
34
34
  }
35
35
  label={t(props.label)}
36
- sx={props.sx}
36
+ sx={{ ...props.sx, display: props?.hidden ? "none" : undefined }}
37
37
  format={props?.format || DATE_TIME_FORMAT}
38
38
  disabled={props.disabled}
39
39
  onChange={(momentValue) => {
@@ -66,7 +66,12 @@ const TemplateForm: React.FC<TemplateFormProps> = (
66
66
  }
67
67
  }
68
68
  const [disabledFields, setDisabledFields] = useState<string[]>([]);
69
- const formSchema = z.object(constructValidationSchema(fields));
69
+ let formSchema = null;
70
+ if (props?.validationSchema) {
71
+ formSchema = props.validationSchema;
72
+ } else {
73
+ formSchema = z.object(constructValidationSchema(fields));
74
+ }
70
75
  type FormData = z.infer<typeof formSchema>;
71
76
  const formManager = useForm<FormData>({
72
77
  resolver: zodResolver(formSchema),
@@ -92,8 +97,12 @@ const TemplateForm: React.FC<TemplateFormProps> = (
92
97
  );
93
98
  if (retrievedRecord) {
94
99
  formManager.reset({ ...retrievedRecord });
95
- if (props?.formLoadCallBk) {
96
- props?.formLoadCallBk(formActions, formManager, retrievedRecord);
100
+ if (props?.formValuesChangeCallBk) {
101
+ props?.formValuesChangeCallBk(
102
+ { ...retrievedRecord },
103
+ formActions,
104
+ formManager
105
+ );
97
106
  }
98
107
  for (const field of fields) {
99
108
  if (
@@ -183,7 +192,6 @@ const TemplateForm: React.FC<TemplateFormProps> = (
183
192
  setAttachmentPanelEnabledForRecord(true);
184
193
  }
185
194
  }, [formValues]);
186
-
187
195
  return (
188
196
  <>
189
197
  {props?.attachment ? (
@@ -253,6 +261,7 @@ const TemplateForm: React.FC<TemplateFormProps> = (
253
261
  formActions={formActions}
254
262
  hiddenFields={hiddenFields}
255
263
  disabledFields={disabledFields}
264
+ formValuesChangeCallBk={props.formValuesChangeCallBk}
256
265
  />
257
266
  );
258
267
  } else if (
@@ -317,78 +326,87 @@ const TemplateForm: React.FC<TemplateFormProps> = (
317
326
  ) : null
318
327
  ) : null}
319
328
  {props?.actions ? (
320
- formValues[props?.keyColumnName || "id"] ? (
321
- props.actions.map((action: RecordAction) => {
329
+ props.actions.map((action: RecordAction) => {
330
+ if (action?.isIdRequired === false) {
331
+ return <FormAction {...action} record={formValues} />;
332
+ } else if (formValues[props?.keyColumnName || "id"]) {
322
333
  if (action?.formActionProps?.enabled === true) {
323
334
  return <FormAction {...action} record={formValues} />;
324
335
  } else {
325
336
  return <></>;
326
337
  }
327
- })
328
- ) : (
329
- <></>
330
- )
338
+ }
339
+ })
331
340
  ) : (
332
341
  <></>
333
342
  )}
334
343
  <div style={{ flex: 1 }}></div>
335
- <Button
336
- variant={
337
- props?.saveButtonSpecs?.actionButtonVariant
338
- ? props.saveButtonSpecs.actionButtonVariant
339
- : "contained"
340
- }
341
- sx={{ m: 1 }}
342
- startIcon={
343
- props?.saveButtonSpecs?.icon ? (
344
- <FontAwesomeIcon icon={props.saveButtonSpecs.icon} />
345
- ) : null
346
- }
347
- color={
348
- props?.saveButtonSpecs?.actionButtonColor
349
- ? props.saveButtonSpecs.actionButtonColor
350
- : "primary"
351
- }
352
- onClick={formManager.handleSubmit(
353
- (values) => {
354
- saveRecord(values);
355
- },
356
- (errors) => {
357
- toast.error(
358
- "Form Data is not valid, make sure you have all field with valid data"
359
- );
360
- console.log("form validation error", errors);
344
+ {props?.saveButtonSpecs?.hidden ? (
345
+ <></>
346
+ ) : (
347
+ <Button
348
+ variant={
349
+ props?.saveButtonSpecs?.actionButtonVariant
350
+ ? props.saveButtonSpecs.actionButtonVariant
351
+ : "contained"
361
352
  }
362
- )}
363
- >
364
- {t(props?.saveButtonSpecs?.label || "SAVE_BTN_LABEL")}
365
- </Button>
366
- <Button
367
- variant={
368
- props?.cancelButtonSpecs?.actionButtonVariant
369
- ? props.cancelButtonSpecs.actionButtonVariant
370
- : "contained"
371
- }
372
- startIcon={
373
- props?.cancelButtonSpecs?.icon ? (
374
- <FontAwesomeIcon icon={props.cancelButtonSpecs.icon} />
375
- ) : null
376
- }
377
- color={
378
- props?.cancelButtonSpecs?.actionButtonColor
379
- ? props.cancelButtonSpecs.actionButtonColor
380
- : "error"
381
- }
382
- sx={{ m: 1 }}
383
- onClick={() => {
384
- if (props?.formCloseCallBk) {
385
- props.formCloseCallBk();
353
+ sx={{ m: 1 }}
354
+ startIcon={
355
+ props?.saveButtonSpecs?.icon ? (
356
+ <FontAwesomeIcon icon={props.saveButtonSpecs.icon} />
357
+ ) : null
386
358
  }
387
- formManager.reset(initialValues);
388
- }}
389
- >
390
- {t(props?.cancelButtonSpecs?.label || "CANCEL_BTN_LABEL")}
391
- </Button>
359
+ color={
360
+ props?.saveButtonSpecs?.actionButtonColor
361
+ ? props.saveButtonSpecs.actionButtonColor
362
+ : "primary"
363
+ }
364
+ onClick={formManager.handleSubmit(
365
+ (values) => {
366
+ saveRecord(values);
367
+ },
368
+ (errors) => {
369
+ toast.error(
370
+ "Form Data is not valid, make sure you have all field with valid data"
371
+ );
372
+ console.log("form validation error", errors);
373
+ }
374
+ )}
375
+ >
376
+ {t(props?.saveButtonSpecs?.label || "SAVE_BTN_LABEL")}
377
+ </Button>
378
+ )}
379
+
380
+ {props?.cancelButtonSpecs?.hidden ? (
381
+ <></>
382
+ ) : (
383
+ <Button
384
+ variant={
385
+ props?.cancelButtonSpecs?.actionButtonVariant
386
+ ? props.cancelButtonSpecs.actionButtonVariant
387
+ : "contained"
388
+ }
389
+ startIcon={
390
+ props?.cancelButtonSpecs?.icon ? (
391
+ <FontAwesomeIcon icon={props.cancelButtonSpecs.icon} />
392
+ ) : null
393
+ }
394
+ color={
395
+ props?.cancelButtonSpecs?.actionButtonColor
396
+ ? props.cancelButtonSpecs.actionButtonColor
397
+ : "error"
398
+ }
399
+ sx={{ m: 1 }}
400
+ onClick={() => {
401
+ if (props?.formCloseCallBk) {
402
+ props.formCloseCallBk();
403
+ }
404
+ formManager.reset(initialValues);
405
+ }}
406
+ >
407
+ {t(props?.cancelButtonSpecs?.label || "CANCEL_BTN_LABEL")}
408
+ </Button>
409
+ )}
392
410
  </Box>
393
411
  </>
394
412
  );
@@ -213,7 +213,13 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
213
213
  keyColumnName = props?.keyColumnName;
214
214
  }
215
215
  const setData = props.setData;
216
- const validationSchema = z.object(constructValidationSchema(fields));
216
+ let validationSchema = null;
217
+ if (props?.validationSchema) {
218
+ validationSchema = props.validationSchema;
219
+ } else {
220
+ validationSchema = z.object(constructValidationSchema(fields));
221
+ }
222
+
217
223
  let isEditAllowed = true;
218
224
  if (props?.editAction?.authority) {
219
225
  isEditAllowed = session.isUserAuthorized(props.editAction.authority);
@@ -760,8 +766,6 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
760
766
  const adjustedColumns: Array<TemplateGridColDef> = React.useMemo(() => {
761
767
  const baseCols = structuredColumns.map((col) => ({
762
768
  ...col,
763
- minWidth: col?.width || 200,
764
- flex: 1,
765
769
  }));
766
770
 
767
771
  // Reorder based on saved columnOrder
@@ -791,7 +795,7 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
791
795
  <TemplateForm
792
796
  keyColumnName={props.keyColumnName}
793
797
  attachment={props.attachment}
794
- formLoadCallBk={props.formLoadCallBk}
798
+ formValuesChangeCallBk={props?.formProps?.formValuesChangeCallBk}
795
799
  recordIdToEdit={
796
800
  recordToEdit ? recordToEdit[keyColumnName] : undefined
797
801
  }
@@ -930,7 +934,6 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
930
934
  workFlowDocumentCode={props.workFlowDocumentCode}
931
935
  refDocumentId={selectedRecord[props?.keyColumnName || "id"]}
932
936
  postActionCallBk={() => {
933
- debugger;
934
937
  setWorkFlowWindowState(false);
935
938
  props.apiActions.reloadData(props.gridLoadParametersValues);
936
939
  }}
@@ -112,7 +112,9 @@ const TemplateGridTopBar: React.FC<TemplateGridTopBarProps> = (
112
112
  ) : (
113
113
  <></>
114
114
  )}
115
- <Box sx={{ flex: 1, mx: 0.5 }}>{props?.templateProps?.tBar}</Box>
115
+ <Box sx={{ flex: 1, mx: 0.5, my: 0.5, padding: 1 }}>
116
+ {props?.templateProps?.tBar}
117
+ </Box>
116
118
 
117
119
  <Tooltip title="Columns">
118
120
  <ColumnsPanelTrigger render={<ToolbarButton />}>