impaktapps-ui-builder 0.0.408 → 0.0.409-c

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 { asyncOperation, executeEvents, executeRefreshHandler } from "./events";
3
+ import { executeEvents, executeRefreshHandler } from "./events";
4
4
  import { handlersProps } from "./interface";
5
5
  let compType: string;
6
6
  let eventGroups: any = {};
@@ -13,6 +13,14 @@ 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
+
16
24
  export const extractEvents = (eventConfig: any) => {
17
25
  function extractsConfigEvents(eventConfigObj: any) {
18
26
  if (eventConfigObj.events) {
@@ -46,30 +54,49 @@ export const extractEvents = (eventConfig: any) => {
46
54
  }
47
55
  return eventGroups;
48
56
  };
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
- functionsProvider?: Record<string, any>
59
- }
60
57
  export default (funcParams: funcParamsProps) => {
61
- eventGroups = {}
62
- eventGroups = extractEvents(funcParams.config)
63
58
  let executeEventsParameters: handlersProps = {
64
59
  config: {}, componentName: "",
65
60
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
66
- serviceHolder: { downloadFile, download: doDownload ,...funcParams.functionsProvider}, eventGroups,
61
+ serviceHolder: { downloadFile, download: doDownload, ...funcParams.functionsProvider }, eventGroups,
67
62
  functionsProvider: funcParams.functionsProvider,
68
63
  };
69
64
  return {
70
65
  setPage: async function () {
71
- funcParams.store.setFormdata({});
72
- const demoData = await asyncOperation();
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
+ },
87
+ }
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);
73
100
  executeEventsParameters = {
74
101
  config: {}, componentName: "",
75
102
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
@@ -81,33 +108,47 @@ export default (funcParams: funcParamsProps) => {
81
108
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
82
109
  serviceHolder: this, eventGroups
83
110
  })
84
- const demoData2 = await asyncOperation();
85
111
  funcParams.store.setSchema(
86
112
  (pre: any) => {
87
113
  return {
88
- ...funcParams.schema, properties:
89
- { ...funcParams.schema.properties, ...pre.properties, }
114
+ ...schema, properties:
115
+ { ...schema.properties, ...pre.properties, }
90
116
  }
91
117
  }
92
118
  )
93
- funcParams.uiSchema.elements.push(notifyUiSchema);
94
- funcParams.store.setUiSchema(funcParams.uiSchema);
95
-
119
+ uiSchema.elements.push(notifyUiSchema);
120
+ funcParams.store.setUiSchema(uiSchema);
121
+
96
122
  },
97
- onClick: async function () {
98
- await this.callHandler("onClick")
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
99
137
  },
100
- onMount: async function () {
101
- await this.callHandler("onMount")
138
+ onClick: function () {
139
+ this.callHandler("onClick")
102
140
  },
103
- onFileDownload: async function () {
104
- await this.callHandler("onDownload")
141
+ onMount: function () {
142
+ this.callHandler("onMount")
105
143
  },
106
- onFileUpload: async function () {
107
- await this.callHandler("onUpload")
144
+ onFileDownload: function () {
145
+ this.callHandler("onDownload")
108
146
  },
109
- backHandler:function(){
110
- funcParams.store.navigate(-1)
147
+ onFileUpload: function () {
148
+ this.callHandler("onUpload")
149
+ },
150
+ backHandler: function () {
151
+ funcParams.store.navigate(-1)
111
152
  },
112
153
  onPaginationChange: async function (paginationValues) {
113
154
  const apiBody = [
@@ -126,7 +167,8 @@ export default (funcParams: funcParamsProps) => {
126
167
  { key: "searchValue", value: param.serachValue },
127
168
  { key: "currentValue", value: param.currentValue }
128
169
  ]
129
- return await this.updateConfigApiBody(param, apiBody)
170
+ const response = await this.updateConfigApiBody(param, apiBody);
171
+ return response?.data;
130
172
  }
131
173
  },
132
174
  onChange: async function () {
@@ -195,7 +237,7 @@ export default (funcParams: funcParamsProps) => {
195
237
  if (eventGroups?.[eventType]?.[path] !== undefined) {
196
238
  for (const eventConfig of eventGroups?.[eventType]?.[path]) {
197
239
  executeEventsParameters.store.functionParameters = functionParameters
198
- await executeEvents({
240
+ executeEvents({
199
241
  ...executeEventsParameters,
200
242
  config: eventConfig,
201
243
  componentName: path
@@ -203,6 +245,7 @@ export default (funcParams: funcParamsProps) => {
203
245
  }
204
246
  }
205
247
  },
248
+
206
249
  downloadFile: downloadFile,
207
250
  download: doDownload,
208
251
  ...funcParams.functionsProvider
@@ -213,9 +256,3 @@ export default (funcParams: funcParamsProps) => {
213
256
 
214
257
 
215
258
 
216
-
217
-
218
-
219
-
220
-
221
-