impaktapps-ui-builder 0.0.104 → 0.0.105

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,87 @@ 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[4] =
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: 3 },
79
+ main: {
80
+ label: "Column Format",
81
+
82
+ },
83
+ },
84
+ };
85
+ UiSchema.elements[1].elements[0].elements[6] =
86
+ {
87
+ type: "Control",
88
+ scope: "#/properties/filteringOptions",
89
+ options: {
90
+ widget: "SelectInputField",
91
+ },
92
+ config: {
93
+ layout: { xs: 6, sm: 6, md: 4, lg: 3 },
94
+ main: {
95
+ label: "Filter Mode",
96
+ multiple: true
97
+ },
98
+ },
99
+ };
100
+ UiSchema.elements[1].elements[0].elements[5] =
101
+ {
102
+ type: "Control",
103
+ scope: "#/properties/enableFilter",
104
+ options: {
105
+ widget: "RadioInputField",
106
+ },
107
+ config: {
108
+ layout: { xs: 6, sm: 6, md: 4, lg: 3 },
109
+ main: {
110
+ label: "Enable Filter",
111
+ options: ["Yes", "No"],
112
+ },
113
+ },
114
+ },
115
+ UiSchema.elements[0].elements[0].elements[7] =
116
+ {
117
+ type: "Control",
118
+ scope: "#/properties/enableSorting",
119
+ options: {
120
+ widget: "RadioInputField",
121
+ },
122
+ config: {
123
+ layout: { xs: 6, sm: 6, md: 4, lg: 3 },
124
+ main: {
125
+ label: "Enable Sorting",
126
+ options: ["Yes", "No"],
127
+ },
128
+ },
129
+ },
130
+ UiSchema.elements[0].elements[0].elements[8] =
131
+ {
132
+ type: "Control",
133
+ scope: "#/properties/proc",
134
+ config: {
135
+ layout: { xs: 6, sm: 6, md: 8, lg: 3 },
136
+ },
137
+ options: {
138
+ widget: "EmptyBox",
139
+ },
140
+ };
141
+ }
142
+ if (sessionStorage.getItem("copiedConfig")) {
62
143
  this.ElementPathSetter(UiSchema);
63
144
  }
64
145
  store.setUiSchema(UiSchema);
@@ -81,7 +162,7 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
81
162
  },
82
163
  getSchema: function () {
83
164
  const schema = _.cloneDeep(ComponentSchema);
84
- if (sessionStorage.getItem("copiedConfig") ) {
165
+ if (sessionStorage.getItem("copiedConfig")) {
85
166
  schema.properties.RemoveItemButton.disabled = false;
86
167
  }
87
168
  return schema;
@@ -169,22 +250,22 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
169
250
  },
170
251
  deletePopUpComponent: function () {
171
252
  const rowId = dynamicData.path.split(".")[1];
172
- sessionStorage.setItem('rowId',rowId);
253
+ sessionStorage.setItem('rowId', rowId);
173
254
  store.updateDialog("popUpComponentSection");
174
255
  },
175
256
  deletePopUpEvent: function () {
176
257
  const rowId = dynamicData.path.split(".")[1];
177
- sessionStorage.setItem('rowId',rowId);
258
+ sessionStorage.setItem('rowId', rowId);
178
259
  store.updateDialog("popUpEventSection");
179
260
  },
180
261
 
181
- copyPasteElement: function(paramStore: any, setPage: any = this.setPage.bind(this) ){
262
+ copyPasteElement: function (paramStore: any, setPage: any = this.setPage.bind(this)) {
182
263
  const [actionType, elementType] = dynamicData.path.split('.').pop()?.split('_');
183
264
  actionType === "Copy" ? this.CopyElement(paramStore, elementType) : this.PasteElement(setPage, elementType);
184
265
  },
185
- CopyElement: function(paramStore: any = store, elementType: string){
186
- const schema = cloneDeep(paramStore.schema );
187
- const uiSchema = cloneDeep(paramStore.uiSchema );
266
+ CopyElement: function (paramStore: any = store, elementType: string) {
267
+ const schema = cloneDeep(paramStore.schema);
268
+ const uiSchema = cloneDeep(paramStore.uiSchema);
188
269
  schema.properties.RemoveItemButton.disabled = false;
189
270
 
190
271
  const rowId = dynamicData.path.split(".")[1];
@@ -192,13 +273,13 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
192
273
  const copiedElementPath = this.elementPathHandler(parentPathOfCopiedComponent, rowId, elementType);
193
274
  const copiedFormData = getFormdataFromSessionStorage(copiedElementPath);
194
275
 
195
- this.ElementPathSetter(uiSchema,copiedFormData);
196
- sessionStorage.setItem('copiedConfig',JSON.stringify(copiedFormData));
276
+ this.ElementPathSetter(uiSchema, copiedFormData);
277
+ sessionStorage.setItem('copiedConfig', JSON.stringify(copiedFormData));
197
278
  store.setSchema(schema);
198
279
  store.setUiSchema(uiSchema);
199
- },
200
- PasteElement: function( setPage: any , elementType: string){
201
- if (!sessionStorage.getItem("copiedConfig") ) {
280
+ },
281
+ PasteElement: function (setPage: any, elementType: string) {
282
+ if (!sessionStorage.getItem("copiedConfig")) {
202
283
  store.setNotify({
203
284
  FailMessage: "No item has been copied.",
204
285
  Fail: true,
@@ -206,15 +287,15 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
206
287
  return;
207
288
  }
208
289
  const pastedElementParentPath = store.searchParams?.get("path");
209
- if (!Array.isArray(store.formData.elements) ) {
290
+ if (!Array.isArray(store.formData.elements)) {
210
291
  store.formData.elements = []
211
292
  }
212
293
  if (!Array.isArray(store.formData.events)) {
213
294
  store.formData.events = []
214
295
  }
215
296
  saveFormdataInSessionStorage(store.ctx.core.data, pastedElementParentPath);
216
- const formData = getFormdataFromSessionStorage(pastedElementParentPath);
217
- const insertElementIndex = elementType === "Component" ? formData.elements.length : formData.events.length;
297
+ const formData = getFormdataFromSessionStorage(pastedElementParentPath);
298
+ const insertElementIndex = elementType === "Component" ? formData.elements.length : formData.events.length;
218
299
  const pastedElementPath = this.elementPathHandler(pastedElementParentPath, insertElementIndex, elementType);
219
300
 
220
301
  const copiedConfig = JSON.parse(sessionStorage.getItem("copiedConfig"));
@@ -222,25 +303,25 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
222
303
  Event: " The event cannot be integrated into the component section.",
223
304
  Component: "The component cannot be integrated into the event section."
224
305
  };
225
- if(copiedConfig.Handler && elementType === "Component"){
306
+ if (copiedConfig.Handler && elementType === "Component") {
226
307
  store.setNotify({
227
308
  FailMessage: notificationMessages.Event,
228
309
  Fail: true,
229
310
  });
230
311
  }
231
- else if(copiedConfig.name && elementType === "Event"){
312
+ else if (copiedConfig.name && elementType === "Event") {
232
313
  store.setNotify({
233
314
  FailMessage: notificationMessages.Component,
234
315
  Fail: true,
235
316
  });
236
317
  }
237
- else{
318
+ else {
238
319
  saveFormdataInSessionStorage(copiedConfig, pastedElementPath);
239
320
  setPage();
240
321
  }
241
- },
242
- RemoveItemButton: function(paramStore: any = store){
243
- const schema = cloneDeep(paramStore.schema );
322
+ },
323
+ RemoveItemButton: function (paramStore: any = store) {
324
+ const schema = cloneDeep(paramStore.schema);
244
325
  const uiSchema = cloneDeep(paramStore.uiSchema);
245
326
  schema.properties.RemoveItemButton.disabled = true;
246
327
  uiSchema.elements[2].elements[1].config.main.heading = `No element copied`;
@@ -248,15 +329,15 @@ export default (store: any, dynamicData: any, submitHandler: any, service: any)
248
329
  store.setSchema(schema);
249
330
  store.setUiSchema(uiSchema);
250
331
  },
251
- elementPathHandler: function(parentPath: string, rowId: any, elementType: string){
252
- if(elementType === "Component"){
253
- return parentPath ? `${parentPath}.elements[${rowId}]` : `elements[${rowId}]`;
332
+ elementPathHandler: function (parentPath: string, rowId: any, elementType: string) {
333
+ if (elementType === "Component") {
334
+ return parentPath ? `${parentPath}.elements[${rowId}]` : `elements[${rowId}]`;
254
335
  }
255
- return parentPath ? `${parentPath}.events[${rowId}]` : `events[${rowId}]`;
336
+ return parentPath ? `${parentPath}.events[${rowId}]` : `events[${rowId}]`;
256
337
  },
257
- ElementPathSetter: function(uiSchema: any,copiedFormData?: any){
338
+ ElementPathSetter: function (uiSchema: any, copiedFormData?: any) {
258
339
  const formData = copiedFormData || JSON.parse(sessionStorage.getItem("copiedConfig"));
259
- uiSchema.elements[2].elements[1].config.main.heading = `Copied Path: ${formData.pageName}`;
340
+ uiSchema.elements[2].elements[1].config.main.heading = `Copied Path: ${formData.pageName}`;
260
341
  }
261
342
  }
262
343
  };