@processmaker/screen-builder 2.98.4 → 2.99.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "2.98.4",
3
+ "version": "2.99.1",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -13,6 +13,7 @@
13
13
  @upload-start="start"
14
14
  @file-removed="removed"
15
15
  @file-success="fileUploaded"
16
+ @file-error="fileError"
16
17
  @file-added="addFile"
17
18
  :class="{'was-validated': required}"
18
19
  >
@@ -503,6 +504,24 @@ export default {
503
504
  e.target.click();
504
505
  }
505
506
  },
507
+ fileError(rootFile, file, messages, chunk)
508
+ {
509
+ let displayMessage = '';
510
+ try {
511
+ const messagesArray = JSON.parse(messages);
512
+ displayMessage = messagesArray.join(', ');
513
+ }
514
+ catch (e) {
515
+ displayMessage = messages;
516
+ }
517
+
518
+ if (displayMessage.length > 0) {
519
+ window.ProcessMaker.alert(`${this.$t('File Upload Error:')} ${displayMessage}`, 'danger');
520
+ }
521
+
522
+ window.onbeforeunload = function() {};
523
+ this.$emit('file-error', messages);
524
+ },
506
525
  fileUploaded(rootFile, file, message) {
507
526
  this.uploading = false;
508
527
  let name = file.name;
@@ -260,7 +260,7 @@ export default {
260
260
  this.loadNextAssignedTask();
261
261
  }
262
262
  },
263
- loadTask() {
263
+ loadTask(mounting = false) {
264
264
  if (!this.taskId) {
265
265
  return;
266
266
  }
@@ -276,7 +276,7 @@ export default {
276
276
  .getTasks(url)
277
277
  .then((response) => {
278
278
  this.task = response.data;
279
- this.linkTask();
279
+ this.linkTask(mounting);
280
280
  this.checkTaskStatus();
281
281
  if (
282
282
  window.PM4ConfigOverrides
@@ -296,12 +296,27 @@ export default {
296
296
  });
297
297
  });
298
298
  },
299
- linkTask() {
299
+ linkTask(mounting) {
300
300
  this.nodeId = this.task.element_id;
301
301
  this.listenForParentChanges();
302
302
  if (this.task.process_request.status === 'COMPLETED') {
303
303
  if (!this.taskPreview) {
304
304
  this.$emit('completed', this.task.process_request.id);
305
+ // When the process ends before the request is opened
306
+ if (mounting) {
307
+ // get end event element destination config
308
+ window.ProcessMaker.apiClient.get(`/requests/${this.requestId}/end-event-destination`)
309
+ .then((response) => {
310
+ if (!response.data?.data?.endEventDestination) {
311
+ // by default it goes to summary
312
+ window.location.href = `/requests/${this.requestId}`;
313
+ return;
314
+ }
315
+
316
+ // process the end event destination
317
+ this.processCompletedRedirect(response.data.data, this.userId, this.requestId);
318
+ });
319
+ }
305
320
  }
306
321
  }
307
322
  if (this.taskPreview && this.task.status === "CLOSED") {
@@ -826,9 +841,9 @@ export default {
826
841
  */
827
842
  isSameUser(currentTask, redirectData) {
828
843
  const userIdMatch = currentTask.user?.id === redirectData.params[0].userId;
829
- const typeMatch = currentTask.elementDestination?.type === null
844
+ const typeMatch = currentTask.elementDestination?.type === null
830
845
  || currentTask.elementDestination?.type === 'taskSource';
831
-
846
+
832
847
  return userIdMatch && typeMatch;
833
848
  },
834
849
 
@@ -839,6 +854,17 @@ export default {
839
854
  * @param {Object} data - The event data containing the process update information.
840
855
  */
841
856
  handleProcessUpdated(data) {
857
+ const elementDestinationValue = this.task.elementDestination?.value;
858
+
859
+ if (
860
+ elementDestinationValue &&
861
+ data?.params[0]?.tokenId === this.taskId &&
862
+ data?.params[0]?.requestStatus === 'ACTIVE'
863
+ ) {
864
+ window.location.href = elementDestinationValue;
865
+ return;
866
+ }
867
+
842
868
  if (
843
869
  ['ACTIVITY_ACTIVATED', 'ACTIVITY_COMPLETED'].includes(data.event)
844
870
  && data.elementType === 'task'
@@ -967,7 +993,7 @@ export default {
967
993
  this.nodeId = this.initialNodeId;
968
994
  this.requestData = this.value;
969
995
  this.loopContext = this.initialLoopContext;
970
- this.loadTask();
996
+ this.loadTask(true);
971
997
  },
972
998
  destroyed() {
973
999
  this.unsubscribeSocketListeners();