impaktapps-ui-builder 0.0.104 → 0.0.105-4.alpha-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.
@@ -42,8 +42,9 @@ const sectionLabels = {
42
42
  Thought: ["Core", "Properties", "Event", "Style", "Validation"]
43
43
  }
44
44
 
45
- export function refreshPage (type: string, store: any) {
45
+ export function refreshPage(type: string, store: any) {
46
46
  const UiSchema = _.cloneDeep(componentBasicUiSchema(store.theme.myTheme))
47
+ const currentConfig = JSON.parse(sessionStorage.getItem("pageFormdata"));
47
48
  if (type) {
48
49
  const sectionUiSchema = {
49
50
  Core: CoreSection,
@@ -58,7 +59,95 @@ export function refreshPage (type: string, store: any) {
58
59
  UiSchema.elements[1].config.main.tabLabels = sectionLabels[type] || ["Core", "Style", "Event", "Validation"];
59
60
  UiSchema.elements[1].elements = elements || [CoreSection, StyleSection, EventSection(store.theme.myTheme), ValidationSection];
60
61
  }
61
- if (sessionStorage.getItem("copiedConfig") ) {
62
+ // Get Widget Type of parent
63
+ const path = store.searchParams?.get("path");
64
+ const lastDotIndex = path.lastIndexOf('.')
65
+ const parentPath = path.slice(0, lastDotIndex)
66
+
67
+ const parentObj = _.get(currentConfig, parentPath)
68
+
69
+ if (parentObj?.type === "Table") {
70
+ UiSchema.elements[1].elements[0].elements[3] =
71
+ {
72
+ type: "Control",
73
+ scope: "#/properties/columnFormat",
74
+ options: {
75
+ widget: "SelectInputField",
76
+ },
77
+ config: {
78
+ layout: { xs: 6, sm: 6, md: 4, lg: 4 },
79
+ main: {
80
+ label: "Column Format",
81
+
82
+ },
83
+ },
84
+ };
85
+ UiSchema.elements[1].elements[0].elements[4] =
86
+ {
87
+ type: "Control",
88
+ scope: "#/properties/enableFilter",
89
+ options: {
90
+ widget: "RadioInputField",
91
+ },
92
+ config: {
93
+ layout: { xs: 6, sm: 6, md: 4, lg: 4 },
94
+ main: {
95
+ label: "Enable Filter",
96
+ options: ["Yes", "No"],
97
+ },
98
+ },
99
+ },
100
+ UiSchema.elements[1].elements[0].elements[5] =
101
+ {
102
+ type: "Control",
103
+ scope: "#/properties/filteringOptions",
104
+ options: {
105
+ widget: "SelectInputField",
106
+ },
107
+ config: {
108
+ layout: { xs: 6, sm: 6, md: 4, lg: 4 },
109
+ main: {
110
+ label: "Filter Mode",
111
+ multiple: true
112
+ },
113
+ },
114
+ };
115
+
116
+ UiSchema.elements[1].elements[0].elements[6] =
117
+ {
118
+ type: "Control",
119
+ scope: "#/properties/enableSorting",
120
+ options: {
121
+ widget: "RadioInputField",
122
+ },
123
+ config: {
124
+ layout: { xs: 6, sm: 6, md: 4, lg: 4 },
125
+ main: {
126
+ label: "Enable Sorting",
127
+ options: ["Yes", "No"],
128
+ },
129
+ },
130
+ },
131
+ UiSchema.elements[1].elements[0].elements[7] =
132
+ {
133
+ type: "Control",
134
+ scope: "#/properties/columnKey",
135
+
136
+ options: {
137
+ widget: "InputField",
138
+ },
139
+ config: {
140
+ layout: { xs: 6, sm: 6, md: 4, lg: 4 },
141
+ main: {
142
+ label: "Column Key",
143
+ options: [],
144
+ color: "secondary",
145
+ required: true,
146
+ },
147
+ },
148
+ }
149
+ }
150
+ if (sessionStorage.getItem("copiedConfig")) {
62
151
  this.ElementPathSetter(UiSchema);
63
152
  }
64
153
  store.setUiSchema(UiSchema);
@@ -81,7 +170,7 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
81
170
  },
82
171
  getSchema: function () {
83
172
  const schema = _.cloneDeep(ComponentSchema);
84
- if (sessionStorage.getItem("copiedConfig") ) {
173
+ if (sessionStorage.getItem("copiedConfig")) {
85
174
  schema.properties.RemoveItemButton.disabled = false;
86
175
  }
87
176
  return schema;
@@ -169,22 +258,22 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
169
258
  },
170
259
  deletePopUpComponent: function () {
171
260
  const rowId = dynamicData.path.split(".")[1];
172
- sessionStorage.setItem('rowId',rowId);
261
+ sessionStorage.setItem('rowId', rowId);
173
262
  store.updateDialog("popUpComponentSection");
174
263
  },
175
264
  deletePopUpEvent: function () {
176
265
  const rowId = dynamicData.path.split(".")[1];
177
- sessionStorage.setItem('rowId',rowId);
266
+ sessionStorage.setItem('rowId', rowId);
178
267
  store.updateDialog("popUpEventSection");
179
268
  },
180
269
 
181
- copyPasteElement: function(paramStore: any, setPage: any = this.setPage.bind(this) ){
270
+ copyPasteElement: function (paramStore: any, setPage: any = this.setPage.bind(this)) {
182
271
  const [actionType, elementType] = dynamicData.path.split('.').pop()?.split('_');
183
272
  actionType === "Copy" ? this.CopyElement(paramStore, elementType) : this.PasteElement(setPage, elementType);
184
273
  },
185
- CopyElement: function(paramStore: any = store, elementType: string){
186
- const schema = cloneDeep(paramStore.schema );
187
- const uiSchema = cloneDeep(paramStore.uiSchema );
274
+ CopyElement: function (paramStore: any = store, elementType: string) {
275
+ const schema = cloneDeep(paramStore.schema);
276
+ const uiSchema = cloneDeep(paramStore.uiSchema);
188
277
  schema.properties.RemoveItemButton.disabled = false;
189
278
 
190
279
  const rowId = dynamicData.path.split(".")[1];
@@ -192,13 +281,13 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
192
281
  const copiedElementPath = this.elementPathHandler(parentPathOfCopiedComponent, rowId, elementType);
193
282
  const copiedFormData = getFormdataFromSessionStorage(copiedElementPath);
194
283
 
195
- this.ElementPathSetter(uiSchema,copiedFormData);
196
- sessionStorage.setItem('copiedConfig',JSON.stringify(copiedFormData));
284
+ this.ElementPathSetter(uiSchema, copiedFormData);
285
+ sessionStorage.setItem('copiedConfig', JSON.stringify(copiedFormData));
197
286
  store.setSchema(schema);
198
287
  store.setUiSchema(uiSchema);
199
- },
200
- PasteElement: function( setPage: any , elementType: string){
201
- if (!sessionStorage.getItem("copiedConfig") ) {
288
+ },
289
+ PasteElement: function (setPage: any, elementType: string) {
290
+ if (!sessionStorage.getItem("copiedConfig")) {
202
291
  store.setNotify({
203
292
  FailMessage: "No item has been copied.",
204
293
  Fail: true,
@@ -206,15 +295,15 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
206
295
  return;
207
296
  }
208
297
  const pastedElementParentPath = store.searchParams?.get("path");
209
- if (!Array.isArray(store.formData.elements) ) {
298
+ if (!Array.isArray(store.formData.elements)) {
210
299
  store.formData.elements = []
211
300
  }
212
301
  if (!Array.isArray(store.formData.events)) {
213
302
  store.formData.events = []
214
303
  }
215
304
  saveFormdataInSessionStorage(store.ctx.core.data, pastedElementParentPath);
216
- const formData = getFormdataFromSessionStorage(pastedElementParentPath);
217
- const insertElementIndex = elementType === "Component" ? formData.elements.length : formData.events.length;
305
+ const formData = getFormdataFromSessionStorage(pastedElementParentPath);
306
+ const insertElementIndex = elementType === "Component" ? formData.elements.length : formData.events.length;
218
307
  const pastedElementPath = this.elementPathHandler(pastedElementParentPath, insertElementIndex, elementType);
219
308
 
220
309
  const copiedConfig = JSON.parse(sessionStorage.getItem("copiedConfig"));
@@ -222,25 +311,25 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
222
311
  Event: " The event cannot be integrated into the component section.",
223
312
  Component: "The component cannot be integrated into the event section."
224
313
  };
225
- if(copiedConfig.Handler && elementType === "Component"){
314
+ if (copiedConfig.Handler && elementType === "Component") {
226
315
  store.setNotify({
227
316
  FailMessage: notificationMessages.Event,
228
317
  Fail: true,
229
318
  });
230
319
  }
231
- else if(copiedConfig.name && elementType === "Event"){
320
+ else if (copiedConfig.name && elementType === "Event") {
232
321
  store.setNotify({
233
322
  FailMessage: notificationMessages.Component,
234
323
  Fail: true,
235
324
  });
236
325
  }
237
- else{
326
+ else {
238
327
  saveFormdataInSessionStorage(copiedConfig, pastedElementPath);
239
328
  setPage();
240
329
  }
241
- },
242
- RemoveItemButton: function(paramStore: any = store){
243
- const schema = cloneDeep(paramStore.schema );
330
+ },
331
+ RemoveItemButton: function (paramStore: any = store) {
332
+ const schema = cloneDeep(paramStore.schema);
244
333
  const uiSchema = cloneDeep(paramStore.uiSchema);
245
334
  schema.properties.RemoveItemButton.disabled = true;
246
335
  uiSchema.elements[2].elements[1].config.main.heading = `No element copied`;
@@ -248,15 +337,15 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
248
337
  store.setSchema(schema);
249
338
  store.setUiSchema(uiSchema);
250
339
  },
251
- elementPathHandler: function(parentPath: string, rowId: any, elementType: string){
252
- if(elementType === "Component"){
253
- return parentPath ? `${parentPath}.elements[${rowId}]` : `elements[${rowId}]`;
340
+ elementPathHandler: function (parentPath: string, rowId: any, elementType: string) {
341
+ if (elementType === "Component") {
342
+ return parentPath ? `${parentPath}.elements[${rowId}]` : `elements[${rowId}]`;
254
343
  }
255
- return parentPath ? `${parentPath}.events[${rowId}]` : `events[${rowId}]`;
344
+ return parentPath ? `${parentPath}.events[${rowId}]` : `events[${rowId}]`;
256
345
  },
257
- ElementPathSetter: function(uiSchema: any,copiedFormData?: any){
346
+ ElementPathSetter: function (uiSchema: any, copiedFormData?: any) {
258
347
  const formData = copiedFormData || JSON.parse(sessionStorage.getItem("copiedConfig"));
259
- uiSchema.elements[2].elements[1].config.main.heading = `Copied Path: ${formData.pageName}`;
348
+ uiSchema.elements[2].elements[1].config.main.heading = `Copied Path: ${formData.pageName}`;
260
349
  }
261
350
  }
262
351
  };
@@ -89,6 +89,15 @@ export default (funcParams: funcParamsProps) => {
89
89
  }))
90
90
  }
91
91
  const config = pageData?.config;
92
+
93
+ const pathParts = funcParams.store.location.pathname.split("/");
94
+ const programId = JSON.parse(window.sessionStorage.getItem("ProgramID") || "{}")?.value || "programID";
95
+ if (pathParts?.[1] === "page") {
96
+ if(programId !== "programID"){
97
+ funcParams.store.setFormdata((pre) => ({ ...pre, programId: programId }));
98
+ }
99
+ }
100
+
92
101
  const uiSchema = pageData?.uiSchema;
93
102
  const event = new CustomEvent('pageNameChanged', {
94
103
  detail: { pageName: config.label }