impaktapps-ui-builder 0.0.286 → 0.0.287

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,5 +1,6 @@
1
1
  import { handlersProps } from "./interface";
2
2
  export declare const executeEvents: (params: handlersProps) => Promise<any>;
3
+ export declare function executeRefreshHandler(params: handlersProps): Promise<void>;
3
4
  export declare function buildApiPayload(compConfig: any, body: any, headers: any, store: any, dynamicData: any, userValue: any, service: any): Promise<{
4
5
  body: any;
5
6
  headers: any;
@@ -12,7 +12,9 @@ declare const _default: (funcParams: funcParamsProps) => {
12
12
  setPage: () => Promise<void>;
13
13
  onClick: () => Promise<void>;
14
14
  onPaginationChange: (paginationValues: any) => Promise<any>;
15
+ getSelectOptions: (param: any) => Promise<any>;
15
16
  onChange: () => Promise<void>;
17
+ updateConfigApiBody: (paramValue: any, apiBody: any) => Promise<any>;
16
18
  downloadFile: (obj: any) => void;
17
19
  };
18
20
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impaktapps-ui-builder",
3
- "version": "0.0.286",
3
+ "version": "0.0.287",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "tsc && vite build",
@@ -49,11 +49,11 @@ async function executeEventsHandler(params:handlersProps) {
49
49
  params.parentEventOutput, params.componentName, params.config, params.store)
50
50
  }
51
51
  }
52
- async function executeRefreshHandler(params:handlersProps) {
52
+ export async function executeRefreshHandler(params:handlersProps) {
53
53
  const compToRefresh: string[] = getRefreshElements(params.config, params.eventGroups)
54
54
  for (const componentName of compToRefresh) {
55
55
  for (const compEventConfig of params.eventGroups.onLoad[componentName]) {
56
- await executeEvents({...params,config:compEventConfig});
56
+ await executeEvents({...params,config:compEventConfig,componentName});
57
57
  }
58
58
  }
59
59
  }
@@ -94,7 +94,8 @@ async function mergeFormdata(handlerResponse: any, componentName: string, eventC
94
94
  return {
95
95
  ...pre, properties: {
96
96
  ...pre.properties, [componentName]: {
97
- enum: handlerResponse.data
97
+ ...pre.properties?.[componentName],
98
+ oneOf: handlerResponse.data
98
99
  }
99
100
  }
100
101
  }
@@ -145,8 +146,8 @@ const buildHeadersFormat = (headers: any[]) => {
145
146
  async function shouldEventExecute(params:handlersProps) {
146
147
  const startEvent = params.config?.events?.filter(e => e.eventType === "onStart");
147
148
  if (startEvent?.length > 0) {
148
- const { response } = await executeEventsHandler(params);
149
- return response
149
+ const response = await executeEventsHandler({...params,config:startEvent[0]});
150
+ return response;
150
151
  }
151
152
  }
152
153
 
@@ -1,6 +1,6 @@
1
1
  import _ from "lodash";
2
2
  import { downloadFile } from "./downloadFile";
3
- import { executeEvents } from "./events";
3
+ import { executeEvents, executeRefreshHandler } from "./events";
4
4
  import { handlersProps } from "./interface";
5
5
  let compType: string;
6
6
  let eventGroups: any = {};
@@ -29,10 +29,10 @@ export const extractEvents = (eventConfig: any) => {
29
29
  const SuccessEvent = event?.events?.find((elem) => {
30
30
  return elem.eventType === "Success"
31
31
  })
32
- if (!(!!SuccessEvent) && event.eventType === "onLoad" ) {
32
+ if (!(!!SuccessEvent) && event.eventType === "onLoad") {
33
33
  event.events.push({ Handler: "mergeFormdata", eventType: "Success", type: compType })
34
- }
35
- eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
34
+ }
35
+ eventGroups[event.eventType][eventConfigObj.name].push({ ...event, type: compType })
36
36
  });
37
37
  }
38
38
  }
@@ -69,12 +69,7 @@ export default (funcParams: funcParamsProps) => {
69
69
  store: funcParams.store, dynamicData: funcParams.dynamicData, userValue: funcParams.userValue, service: funcParams.service,
70
70
  serviceHolder: this, eventGroups
71
71
  }
72
- await executeEvents({
73
- ...executeEventsParameters,
74
- config: { Handler: "refresh", eventType: "onPageRefresh" },
75
- componentName: "all"
76
- })
77
-
72
+ await executeRefreshHandler(executeEventsParameters)
78
73
  funcParams.store.setSchema(
79
74
  (pre: any) => {
80
75
  return {
@@ -95,31 +90,23 @@ export default (funcParams: funcParamsProps) => {
95
90
  })
96
91
  }
97
92
  },
98
- onPaginationChange: async (paginationValues) => {
99
- for (const eventConfig of eventGroups?.onLoad[paginationValues.path]) {
100
- const bodyValues = [
101
- { key: "size", value: paginationValues.pagination.pageSize },
102
- { key: "start", value: paginationValues.pagination.pageIndex * paginationValues.pagination.pageSize },
103
- { key: "sorting", value: paginationValues.sorting || [] },
104
- { key: "filters", value: paginationValues.columnFilters || [] },
105
- { key: "globalFilter", value: paginationValues.globalFilter ?? '' }
93
+ onPaginationChange: async function (paginationValues) {
94
+ const apiBody = [
95
+ { key: "size", value: paginationValues.pagination.pageSize },
96
+ { key: "start", value: paginationValues.pagination.pageIndex * paginationValues.pagination.pageSize },
97
+ { key: "sorting", value: paginationValues.sorting || [] },
98
+ { key: "filters", value: paginationValues.columnFilters || [] },
99
+ { key: "globalFilter", value: paginationValues.globalFilter ?? '' }
100
+ ]
101
+ return await this.updateConfigApiBody(paginationValues, apiBody)
102
+ },
103
+ getSelectOptions: async function (param) {
104
+ if (param.serachValue !== "" && param.serachValue !== undefined) {
105
+ const apiBody = [
106
+ { key: "serachValue", value: param.serachValue },
107
+ { key: "currentValue", value: param.currentValue }
106
108
  ]
107
- if (eventConfig.body) {
108
- eventConfig.body = [
109
- ...eventConfig.body,
110
- ...bodyValues
111
- ]
112
- } else { eventConfig.body = bodyValues; };
113
- const responseEvent = eventConfig?.events?.filter((elem) => {
114
- return elem.Handler !== "mergeFormdata"
115
- })
116
- eventConfig.events = responseEvent??[]
117
- const data = await executeEvents({
118
- ...executeEventsParameters,
119
- config: eventConfig,
120
- componentName: paginationValues.path
121
- })
122
- return data;
109
+ return await this.updateConfigApiBody(param, apiBody)
123
110
  }
124
111
  },
125
112
  onChange: async function () {
@@ -141,6 +128,27 @@ export default (funcParams: funcParamsProps) => {
141
128
  }))
142
129
  }
143
130
  },
131
+ updateConfigApiBody: async function (paramValue, apiBody) {
132
+ let LastCallResponse = undefined;
133
+ for (const eventConfig of eventGroups?.onLoad[paramValue.path]) {
134
+ if (eventConfig.body) {
135
+ eventConfig.body = [
136
+ ...eventConfig.body,
137
+ ...apiBody
138
+ ]
139
+ } else { eventConfig.body = apiBody; };
140
+ const responseEvent = eventConfig?.events?.filter((elem) => {
141
+ return elem.Handler !== "mergeFormdata"
142
+ })
143
+ eventConfig.events = responseEvent ?? []
144
+ LastCallResponse = await executeEvents({
145
+ ...executeEventsParameters,
146
+ config: eventConfig,
147
+ componentName: paramValue.path
148
+ })
149
+ }
150
+ return LastCallResponse
151
+ },
144
152
  downloadFile: downloadFile
145
153
  };
146
154
  };