@asaleh37/ui-base 25.10.19 → 25.10.22

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.10.19",
3
+ "version": "25.10.22",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -144,8 +144,11 @@ export const constructGridColumnsFromFields: (
144
144
  searchable: tableField?.gridProps?.searchable,
145
145
  valueField: tableField?.optionValueField || "value",
146
146
  displayField: tableField?.optionDisplayField || "display",
147
- options: tableField?.options || [],
148
-
147
+ options: tableField?.options,
148
+ commonStoreKey: tableField?.commonStoreKey,
149
+ dataQueryId: tableField?.dataQueryId,
150
+ storeUrl: tableField?.storeUrl,
151
+ storeLoadParam: tableField?.storeLoadParam,
149
152
  flex: tableField?.gridProps?.muiProps?.flex || 1,
150
153
  minWidth: tableField?.gridProps?.muiProps?.width
151
154
  ? tableField?.gridProps?.muiProps?.width
@@ -77,13 +77,14 @@ export const generateDateTimeColumn: any = (colDef: TemplateGridColDef) => {
77
77
 
78
78
  type ComboBoxColumnProps = TemplateGridColDef & {
79
79
  lookupType?: string;
80
- options: Array<any>;
80
+ options?: Array<any>;
81
81
  displayField: string;
82
82
  valueField: string;
83
83
  };
84
84
  export const generateComboColumn: (
85
85
  props: ComboBoxColumnProps
86
86
  ) => TemplateGridColDef = (colDef: ComboBoxColumnProps) => {
87
+ debugger;
87
88
  const column: TemplateGridColDef = {
88
89
  ...colDef,
89
90
  type: "custom",
@@ -93,32 +94,36 @@ export const generateComboColumn: (
93
94
  }
94
95
  return value;
95
96
  },
96
- // renderCell: (parameters: any) => {
97
- // let record = null;
98
- // try {
99
- // record = parameters.colDef.options.find(
100
- // (item: any) => item[parameters.colDef.valueField] == parameters.value
101
- // );
102
- // } catch (e) {}
103
- // return (
104
- // <div>
105
- // {record != null
106
- // ? record[parameters.colDef.displayField]
107
- // : parameters.value}
108
- // </div>
109
- // );
110
- // },
111
-
97
+ renderCell: (parameters: any) => {
98
+ let record = null;
99
+ try {
100
+ record = parameters.colDef.options.find(
101
+ (item: any) => item[parameters.colDef.valueField] == parameters.value
102
+ );
103
+ } catch (e) {}
104
+ return (
105
+ <div>
106
+ {record != null
107
+ ? record[parameters.colDef.displayField]
108
+ : parameters.value}
109
+ </div>
110
+ );
111
+ },
112
+ commonStoreKey: colDef?.commonStoreKey,
113
+ dataQueryId: colDef?.dataQueryId,
114
+ storeUrl: colDef?.storeUrl,
115
+ storeLoadParam: colDef?.storeLoadParam,
112
116
  renderEditCell: (params: any) => {
117
+ debugger;
113
118
  return (
114
119
  <ComboBox
115
120
  {...params}
116
121
  sx={{ width: "100%" }}
117
122
  options={params?.colDef?.options}
118
- commonStoreKey={params?.colDef?.commonStoreKey}
119
- dataQueryId={params?.colDef?.dataQueryId}
120
- storeUrl={params?.colDef?.storeUrl}
121
- storeLoadParam={params?.colDef?.storeLoadParam}
123
+ // commonStoreKey={params?.colDef?.commonStoreKey}
124
+ // dataQueryId={params?.colDef?.dataQueryId}
125
+ // storeUrl={params?.colDef?.storeUrl}
126
+ // storeLoadParam={params?.colDef?.storeLoadParam}
122
127
  valueField={params?.colDef?.valueField}
123
128
  displayField={params?.colDef?.displayField}
124
129
  onChangeCallBack={(v: any, selectedRecord: any) => {
@@ -81,6 +81,8 @@ const PIN_FIXED_COLUMNS = ["__check__", "actions"];
81
81
 
82
82
  const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
83
83
  const { t } = useTranslation();
84
+ const { handleGetRequest } = useAxios();
85
+ const stores = useSelector((state: any) => state.commonStores.stores);
84
86
  const AppLayout = useSelector((state: any) => state.AppLayout);
85
87
  const [selectedRecord, setSelectedRecord] = useState<any>({});
86
88
  const [attachmentPanelEnabledForRecord, setAttachmentPanelEnabledForRecord] =
@@ -101,11 +103,11 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
101
103
  const { Window: WorkFlowWindow, setWindowState: setWorkFlowWindowState } =
102
104
  useWindow({
103
105
  windowTitle: t(props.gridTitle) + " Approvals",
104
- windowIcon: "stamp",
106
+ windowIcon: "stamp",
105
107
  height: "fit-content",
106
108
  minHeight: 500,
107
109
  width: "fit-content",
108
- // width:1100,
110
+ // width:1100,
109
111
  onCloseCallBack: () => {
110
112
  props?.apiActions?.reloadData(props.gridLoadParametersValues);
111
113
  },
@@ -188,6 +190,33 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
188
190
  const [recordToDelete, setRecordToDelete] = useState<any>(null);
189
191
  const [recordToEdit, setRecordToEdit] = useState<any>(null);
190
192
  const [rowModesModel, setRowModesModel] = useState<GridRowModesModel>({});
193
+ const loadComboboxData: (
194
+ storeUrl: any,
195
+ storeLoadParam: any,
196
+ dataQueryId: any
197
+ ) => Promise<Array<any>> = async (storeUrl, storeLoadParam, dataQueryId) => {
198
+ let comboboxData: Array<any> = [];
199
+ if (storeUrl) {
200
+ await handleGetRequest({
201
+ endPointURI: storeUrl,
202
+ showMask: false,
203
+ parameters: storeLoadParam,
204
+ successCallBkFn: (response) => {
205
+ comboboxData = response.data;
206
+ },
207
+ });
208
+ } else if (dataQueryId) {
209
+ await handleGetRequest({
210
+ endPointURI: "api/v1/dev/query/result",
211
+ showMask: false,
212
+ parameters: { queryId: dataQueryId, ...storeLoadParam },
213
+ successCallBkFn: (response) => {
214
+ comboboxData = response.data;
215
+ },
216
+ });
217
+ }
218
+ return comboboxData;
219
+ };
191
220
  const adjustGridColumns = async () => {
192
221
  let gridColumns = constructGridColumnsFromFields(
193
222
  fields,
@@ -203,6 +232,20 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
203
232
  gridColumn.options = await getLookupOptions(gridColumn.lookupType);
204
233
  gridColumn.valueField = "lookupValue";
205
234
  }
235
+ if (gridColumn.type === "custom") {
236
+ debugger;
237
+ if (gridColumn?.options) {
238
+ continue;
239
+ } else if (gridColumn?.commonStoreKey) {
240
+ gridColumn.options = stores[gridColumn.commonStoreKey]?.data || [];
241
+ } else {
242
+ gridColumn.options = await loadComboboxData(
243
+ gridColumn?.storeUrl,
244
+ gridColumn?.storeLoadParam,
245
+ gridColumn?.dataQueryId
246
+ );
247
+ }
248
+ }
206
249
  }
207
250
  setGeneratedColumns(gridColumns);
208
251
  };
@@ -929,7 +972,7 @@ const TemplateGrid: React.FC<TemplateGridProps> = (props) => {
929
972
  <></>
930
973
  )}
931
974
  {props?.workFlowDocumentCode ? (
932
- <WorkFlowWindow >
975
+ <WorkFlowWindow>
933
976
  <WorkflowDocumentPanel
934
977
  workFlowDocumentCode={props.workFlowDocumentCode}
935
978
  refDocumentId={selectedRecord[props?.keyColumnName || "id"]}
package/src/main.tsx CHANGED
@@ -11,8 +11,8 @@ createRoot(document.getElementById("root")!).render(
11
11
  themeMode: "dark",
12
12
  backgroundImageNameInPublicFolder: "bg.jpg",
13
13
  }}
14
- appVersion="25.10.19"
15
- authenticationMethod="AZURE"
14
+ appVersion="25.10.22"
15
+ authenticationMethod="APP"
16
16
  azureConfiguration={{
17
17
  frontEndClientId: "c3bbbdbd-f392-4459-b3dd-2351cb07f924",
18
18
  tenantId: "9f136fef-4529-475f-98e6-d271eb04eb00",