@processmaker/screen-builder 2.85.1 → 2.85.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "2.85.1",
3
+ "version": "2.85.3",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -57,6 +57,13 @@ export default {
57
57
  boundary: 'window',
58
58
  };
59
59
  },
60
+ buttonInfo() {
61
+ return {
62
+ name: this.name,
63
+ label: this.label,
64
+ value: this.fieldValue
65
+ };
66
+ }
60
67
  },
61
68
  methods: {
62
69
  setValue(parent, name, value) {
@@ -83,7 +90,7 @@ export default {
83
90
  }
84
91
  this.$emit('input', this.fieldValue);
85
92
  this.$nextTick(() => {
86
- this.$emit('submit', this.eventData, this.loading);
93
+ this.$emit('submit', this.eventData, this.loading, this.buttonInfo);
87
94
  });
88
95
  return;
89
96
  }
@@ -47,7 +47,14 @@ export default {
47
47
  data() {
48
48
  return {
49
49
  search: "",
50
- filteredItems: [...this.items],
50
+ filteredItems: [...this.items].map((item, index) => {
51
+ // Add the order property to the items if it doesn't exist
52
+ if (item.order === undefined) {
53
+ // eslint-disable-next-line no-param-reassign
54
+ this.$set(item, "order", index + 1);
55
+ }
56
+ return item;
57
+ })
51
58
  };
52
59
  },
53
60
  watch: {
@@ -64,6 +64,7 @@ export default {
64
64
  },
65
65
  data() {
66
66
  return {
67
+ refreshSort: 1,
67
68
  newName: '',
68
69
  draggedItem: 0,
69
70
  draggedOverItem: 0,
@@ -72,9 +73,9 @@ export default {
72
73
  },
73
74
  computed: {
74
75
  sortedItems() {
75
- const sortedItems = [...this.filteredItems].sort(
76
- (a, b) => a.order - b.order
77
- );
76
+ const sortedItems =
77
+ this.refreshSort &&
78
+ [...this.filteredItems].sort((a, b) => a.order - b.order);
78
79
  return sortedItems;
79
80
  }
80
81
  },
@@ -178,7 +179,7 @@ export default {
178
179
  item.order = index + 1;
179
180
  });
180
181
  }
181
-
182
+ this.refreshSort++;
182
183
  this.$emit('ordered', itemsSortedClone);
183
184
  },
184
185
  dragOver(event) {
@@ -115,7 +115,7 @@ export default {
115
115
  hasErrors: false,
116
116
  refreshScreen: 0,
117
117
  redirecting: null,
118
- loadingButton: false
118
+ loadingButton: false,
119
119
  };
120
120
  },
121
121
  watch: {
@@ -223,7 +223,7 @@ export default {
223
223
  }
224
224
  this.renderComponent = component;
225
225
  }
226
- },
226
+ }
227
227
  },
228
228
  },
229
229
  computed: {
@@ -289,7 +289,7 @@ export default {
289
289
  }
290
290
  },
291
291
  loadTask() {
292
- const url = `/${this.taskId}?include=data,user,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission`;
292
+ const url = `/${this.taskId}?include=data,user,draft,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission`;
293
293
  // For Vocabularies
294
294
  if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
295
295
  window.ProcessMaker.VocabulariesSchemaUrl = `vocabularies/task_schema/${this.taskId}`;
@@ -324,6 +324,15 @@ export default {
324
324
  this.resetScreenState();
325
325
  this.requestData = _.get(this.task, 'request_data', {});
326
326
  this.loopContext = _.get(this.task, "loop_context", "");
327
+
328
+ if (this.task.draft) {
329
+ this.requestData = _.merge(
330
+ {},
331
+ this.requestData,
332
+ this.task.draft.data
333
+ );
334
+ }
335
+
327
336
  this.refreshScreen++;
328
337
  }
329
338
 
@@ -433,7 +442,7 @@ export default {
433
442
  }
434
443
  return 'card-header text-capitalize text-white ' + header;
435
444
  },
436
- submit(formData = null, loading = false) {
445
+ submit(formData = null, loading = false, buttonInfo = null) {
437
446
  //single click
438
447
  if (this.disabled) {
439
448
  return;
@@ -449,7 +458,7 @@ export default {
449
458
  } else {
450
459
  this.loadingButton = false;
451
460
  }
452
- this.$emit('submit', this.task, loading);
461
+ this.$emit('submit', this.task, loading, buttonInfo);
453
462
 
454
463
  if (this.task && this.task.allow_interstitial && !this.loadingButton) {
455
464
  this.task.interstitial_screen['_interstitial'] = true;
@@ -246,8 +246,8 @@ export default {
246
246
  node.$children.forEach((child) => this.registerCustomFunctions(child));
247
247
  }
248
248
  },
249
- submit(eventData, loading = false) {
250
- this.$emit("submit", this.data, loading);
249
+ submit(eventData, loading = false, buttonInfo = null) {
250
+ this.$emit("submit", this.data, loading, buttonInfo);
251
251
  },
252
252
  parseCss() {
253
253
  const containerSelector = `.${this.containerClass}`;
@@ -53,8 +53,8 @@ export default {
53
53
  dot2bracket(str) {
54
54
  return str.replace(/\.\d/g, match => `[${match.substr(1)}]`);
55
55
  },
56
- submit(eventData, loading = false) {
57
- this.$emit('submit', this.value, loading);
56
+ submit(eventData, loading = false, buttonInfo = null) {
57
+ this.$emit('submit', this.value, loading, buttonInfo);
58
58
  },
59
59
  buildComponent(definition) {
60
60
  if (window.ProcessMaker && window.ProcessMaker.EventBus) {
@@ -145,7 +145,7 @@ export default {
145
145
  return 'MUSTACHE: ' + e.message;
146
146
  }
147
147
  },
148
- async submitForm(eventData, loading = false) {
148
+ async submitForm(eventData, loading = false, buttonInfo = null) {
149
149
  await this.validateNow(findRootScreen(this));
150
150
  this.hasSubmitted(true);
151
151
  if (!this.valid__ || this.disableSubmit__) {
@@ -155,7 +155,7 @@ export default {
155
155
  // if the form is not valid the data is not emitted
156
156
  return;
157
157
  }
158
- this.$emit('submit', this.vdata, loading);
158
+ this.$emit('submit', this.vdata, loading, buttonInfo);
159
159
  },
160
160
  resetValue(safeDotName, variableName) {
161
161
  this.setValue(safeDotName, null);
@@ -234,3 +234,52 @@ export const UserCanSortWithFilterByText = {
234
234
  expect(itemsOrder[4]).toHaveAttribute("data-order", "5");
235
235
  }
236
236
  };
237
+
238
+ // User can reorder items that does not have an order
239
+ export const UserCanReorderItemsThatDoesNotHaveAnOrder = {
240
+ args: {
241
+ filterKey: "name",
242
+ items: [
243
+ { name: "Page 1" },
244
+ { name: "Page 2" },
245
+ { name: "Page 3" },
246
+ { name: "Page 4" },
247
+ { name: "Page 5" }
248
+ ]
249
+ },
250
+ play: async ({ canvasElement }) => {
251
+ const canvas = within(canvasElement);
252
+
253
+ // Drag item-1 item-5 position
254
+ await dragAndDrop(
255
+ canvas.getByTestId("item-1"),
256
+ canvas.getByTestId("item-5")
257
+ );
258
+
259
+ // Drag item-1 item-4 position
260
+ await dragAndDrop(
261
+ canvas.getByTestId("item-1"),
262
+ canvas.getByTestId("item-4")
263
+ );
264
+
265
+ // Drag item-1 item-3 position
266
+ await dragAndDrop(
267
+ canvas.getByTestId("item-1"),
268
+ canvas.getByTestId("item-3")
269
+ );
270
+
271
+ // Drag item-1 item-2 position
272
+ await dragAndDrop(
273
+ canvas.getByTestId("item-1"),
274
+ canvas.getByTestId("item-2")
275
+ );
276
+
277
+ // Check the new order
278
+ const items = canvas.getAllByTestId(/item-\d+/);
279
+ expect(items[0]).toHaveTextContent("Page 5");
280
+ expect(items[1]).toHaveTextContent("Page 4");
281
+ expect(items[2]).toHaveTextContent("Page 3");
282
+ expect(items[3]).toHaveTextContent("Page 2");
283
+ expect(items[4]).toHaveTextContent("Page 1");
284
+ }
285
+ };