impaktapps-ui-builder 0.0.409-j → 0.0.409-k

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.
@@ -1,6 +1,6 @@
1
1
  import _, { isEmpty } from "lodash";
2
2
  import { doDownload, downloadFile } from "./downloadFile";
3
- import { executeEvents, executeRefreshHandler } from "./events";
3
+ import { asyncOperation, executeEvents, executeRefreshHandler } from "./events";
4
4
  import { handlersProps } from "./interface";
5
5
  let compType: string;
6
6
  let eventGroups: any = {};
@@ -13,14 +13,6 @@ const notifyUiSchema = {
13
13
  layout: 6,
14
14
  };
15
15
 
16
- interface funcParamsProps {
17
- store: any,
18
- dynamicData: any,
19
- service: any,
20
- userValue: any,
21
- functionsProvider?: Record<string, any>
22
- }
23
-
24
16
  export const extractEvents = (eventConfig: any) => {
25
17
  function extractsConfigEvents(eventConfigObj: any) {
26
18
  if (eventConfigObj.events) {
@@ -54,53 +46,41 @@ export const extractEvents = (eventConfig: any) => {
54
46
  }
55
47
  return eventGroups;
56
48
  };
49
+
50
+ interface funcParamsProps {
51
+ store: any,
52
+ dynamicData: any,
53
+ config: any,
54
+ uiSchema: any,
55
+ schema: any,
56
+ service: any,
57
+ userValue: any,
58
+ }
57
59
  export default (funcParams: funcParamsProps) => {
60
+ eventGroups = {}
61
+ eventGroups = extractEvents(funcParams.config)
58
62
  let executeEventsParameters: handlersProps = {
59
63
  config: {}, componentName: "",
60
64
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
61
- serviceHolder: { downloadFile, download: doDownload, ...funcParams.functionsProvider }, eventGroups,
62
- functionsProvider: funcParams.functionsProvider,
65
+ serviceHolder: { downloadFile, download: doDownload }, eventGroups
63
66
  };
64
67
  return {
65
68
  setPage: async function () {
66
- funcParams.store.setFormdata({})
67
- const data = JSON.stringify({
68
- pageName: funcParams.store.pageName
69
- });
70
- let pageData;
71
- const pageBasicDetailString = localStorage.getItem("pagemasterMetaData")
72
- if (pageBasicDetailString) {
73
- pageData = JSON.parse(pageBasicDetailString)
74
- } else {
75
- const pageId = await funcParams.service
76
- .post("/page/getByName", data, {
77
- headers: {
78
- "Content-Type": "application/json",
79
- },
80
- });
81
- const response = await funcParams.service.get(
82
- `/page/getById?id=${pageId?.data?.id}`,
83
- {
84
- headers: {
85
- "Content-Type": "application/json",
86
- },
69
+ funcParams.store.setFormdata({});
70
+ funcParams.store.setSchema(
71
+ (pre: any) => {
72
+ return {
73
+ ...funcParams.schema, properties:
74
+ { ...funcParams.schema.properties, ...pre.properties, }
87
75
  }
88
- );
89
- pageData = response.data;
90
- localStorage.setItem("pagemasterMetaData", JSON.stringify({
91
- schema: pageData?.schema,
92
- uiSchema: pageData?.uiSchema, config: pageData?.config
93
- }))
94
- }
95
- const config = pageData?.config;
96
- const uiSchema = pageData?.uiSchema;
97
- const schema = pageData?.schema ?? { type: "object", properties: {} };
98
- eventGroups = {}
99
- eventGroups = extractEvents(config);
76
+ }
77
+ )
78
+ funcParams.uiSchema.elements.push(notifyUiSchema);
79
+ funcParams.store.setUiSchema(funcParams.uiSchema);
80
+ await asyncOperation()
100
81
  executeEventsParameters = {
101
82
  config: {}, componentName: "",
102
83
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
103
- functionsProvider: funcParams.functionsProvider,
104
84
  serviceHolder: this, eventGroups
105
85
  }
106
86
  await executeRefreshHandler({
@@ -108,47 +88,15 @@ export default (funcParams: funcParamsProps) => {
108
88
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
109
89
  serviceHolder: this, eventGroups
110
90
  })
111
- funcParams.store.setSchema(
112
- (pre: any) => {
113
- return {
114
- ...schema, properties:
115
- { ...schema.properties, ...pre.properties, }
116
- }
117
- }
118
- )
119
- uiSchema.elements.push(notifyUiSchema);
120
- funcParams.store.setUiSchema(uiSchema);
121
-
122
- },
123
- onCellRenderer: (cellParams) => {
124
- let finalResponse = {};
125
- // cellParams.spanRef.current.style.color = "yellow";
126
- const path = funcParams.dynamicData?.tableButtonPath || funcParams.dynamicData.path.split(".")[0];
127
- for (const eventConfig of eventGroups?.onCellRenderer[path]) {
128
- executeEventsParameters.store.functionParameters = cellParams
129
- finalResponse = executeEvents({
130
- ...executeEventsParameters,
131
- config: eventConfig,
132
- componentName: path
133
- })
134
- }
135
- console.log("finalResponse >> >> >> ", finalResponse)
136
- return finalResponse
137
- },
138
- onClick: function () {
139
- this.callHandler("onClick")
140
91
  },
141
- onMount: function () {
142
- this.callHandler("onMount")
92
+ onClick: async function () {
93
+ await this.callHandler("onClick")
143
94
  },
144
- onFileDownload: function () {
145
- this.callHandler("onDownload")
95
+ onFileDownload: async function () {
96
+ await this.callHandler("onDownload")
146
97
  },
147
- onFileUpload: function () {
148
- this.callHandler("onUpload")
149
- },
150
- backHandler: function () {
151
- funcParams.store.navigate(-1)
98
+ onFileUpload: async function () {
99
+ await this.callHandler("onUpload")
152
100
  },
153
101
  onPaginationChange: async function (paginationValues) {
154
102
  const apiBody = [
@@ -167,8 +115,7 @@ export default (funcParams: funcParamsProps) => {
167
115
  { key: "searchValue", value: param.serachValue },
168
116
  { key: "currentValue", value: param.currentValue }
169
117
  ]
170
- const response = await this.updateConfigApiBody(param, apiBody);
171
- return response?.data;
118
+ return await this.updateConfigApiBody(param, apiBody)
172
119
  }
173
120
  },
174
121
  onChange: async function () {
@@ -237,7 +184,7 @@ export default (funcParams: funcParamsProps) => {
237
184
  if (eventGroups?.[eventType]?.[path] !== undefined) {
238
185
  for (const eventConfig of eventGroups?.[eventType]?.[path]) {
239
186
  executeEventsParameters.store.functionParameters = functionParameters
240
- executeEvents({
187
+ await executeEvents({
241
188
  ...executeEventsParameters,
242
189
  config: eventConfig,
243
190
  componentName: path
@@ -245,10 +192,8 @@ export default (funcParams: funcParamsProps) => {
245
192
  }
246
193
  }
247
194
  },
248
-
249
195
  downloadFile: downloadFile,
250
196
  download: doDownload,
251
- ...funcParams.functionsProvider
252
197
  };
253
198
  };
254
199
 
@@ -256,3 +201,9 @@ export default (funcParams: funcParamsProps) => {
256
201
 
257
202
 
258
203
 
204
+
205
+
206
+
207
+
208
+
209
+