@processmaker/screen-builder 3.8.42 → 3.8.43-branch-5932fbd7

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": "3.8.42",
3
+ "version": "3.8.43-branch-5932fbd7",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -61,8 +61,8 @@
61
61
  "@fortawesome/fontawesome-free": "^5.6.1",
62
62
  "@originjs/vite-plugin-commonjs": "^1.0.3",
63
63
  "@panter/vue-i18next": "^0.15.2",
64
- "@processmaker/vue-form-elements": "0.65.11",
65
- "@processmaker/vue-multiselect": "2.3.2",
64
+ "@processmaker/vue-form-elements": "0.65.11-branch-2c6a640",
65
+ "@processmaker/vue-multiselect": "2.3.3",
66
66
  "@storybook/addon-essentials": "^7.6.13",
67
67
  "@storybook/addon-interactions": "^7.6.13",
68
68
  "@storybook/addon-links": "^7.6.13",
@@ -125,7 +125,7 @@
125
125
  },
126
126
  "peerDependencies": {
127
127
  "@panter/vue-i18next": "^0.15.0",
128
- "@processmaker/vue-form-elements": "0.65.11",
128
+ "@processmaker/vue-form-elements": "0.65.11-branch-2c6a640",
129
129
  "i18next": "^15.0.8",
130
130
  "vue": "^2.6.12",
131
131
  "vuex": "^3.1.1"
@@ -154,5 +154,10 @@
154
154
  ".js",
155
155
  ".vue"
156
156
  ]
157
+ },
158
+ "processmaker": {
159
+ "downstream": [
160
+ "modeler"
161
+ ]
157
162
  }
158
163
  }
@@ -228,6 +228,7 @@ export default {
228
228
  const normalizedDataSourceId = normalizeDataSourceId(dataSourceId);
229
229
  // keep backwards compatibility
230
230
  if (
231
+ !params.cache &&
231
232
  !window.ProcessMaker.screen.cacheEnabled &&
232
233
  !window.ProcessMaker.screen.cacheTimeout
233
234
  ) {
@@ -242,6 +243,7 @@ export default {
242
243
  url += this.authQueryString();
243
244
  return this.get(url, {
244
245
  useCache: window.ProcessMaker.screen.cacheEnabled,
246
+ cache: params.cache,
245
247
  params: {
246
248
  pmds_config: JSON.stringify(params.config),
247
249
  pmds_data: JSON.stringify(params.data)
@@ -283,10 +283,7 @@ export default {
283
283
  url += `&screen_version=${this.screenVersion}`;
284
284
  }
285
285
 
286
- // For Vocabularies
287
- if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
288
- window.ProcessMaker.VocabulariesSchemaUrl = `vocabularies/task_schema/${this.taskId}`;
289
- }
286
+ this.setVocabulariesSchemaUrl();
290
287
 
291
288
  return this.beforeLoadTask(this.taskId, this.nodeId).then(() => {
292
289
  this.$dataProvider
@@ -534,39 +531,47 @@ export default {
534
531
  // If the task has not an origin source it should re redirected top the tasks List as default.
535
532
  return document.referrer || '/tasks';
536
533
  },
537
- loadNextAssignedTask(requestId = null) {
534
+ loadNextAssignedTask(requestId = null, taskId = null) {
538
535
  if (!requestId) {
539
536
  requestId = this.requestId;
540
537
  }
541
538
  if (!this.userId) {
542
- return;
539
+ return false;
543
540
  }
544
541
  const timestamp = !window.Cypress ? `&t=${Date.now()}` : "";
545
- const url = `?user_id=${this.userId}&status=ACTIVE&process_request_id=${requestId}&include_sub_tasks=1${timestamp}`;
542
+ const taskIdFilter = taskId ? `&task_id=${encodeURIComponent(taskId)}` : "";
543
+ const url = `?user_id=${this.userId}&status=ACTIVE&process_request_id=${requestId}&include_sub_tasks=1${taskIdFilter}${timestamp}`;
546
544
  return this.$dataProvider
547
545
  .getTasks(url).then((response) => {
548
546
  this.$emit("load-data-task", response);
549
- if (response.data.data.length > 0) {
550
- let task = response.data.data[0];
551
- if (task.process_request_id !== this.requestId) {
552
- // Next task is in a subprocess, do a hard redirect
547
+ const tasks = response.data.data;
548
+ const task = taskId
549
+ ? tasks.find(({ id }) => String(id) === String(taskId))
550
+ : tasks[0];
551
+ if (task) {
552
+ const requiresWebEntryFallback = this.isWebEntry
553
+ && task.web_entry_available === false;
554
+ if (task.process_request_id !== this.requestId || requiresWebEntryFallback) {
555
+ // Cross-request transitions and non-Web Entry tasks require a hard redirect.
553
556
  if (this.redirecting === task.process_request_id) {
554
- return;
557
+ return true;
555
558
  }
556
559
  this.unsubscribeSocketListeners();
557
560
  this.redirecting = task.process_request_id;
558
- this.$emit('redirect', task.id, true);
559
- return;
561
+ // Screen Builder uses Vue 2, where emitted events have no runtime emits contract.
562
+ this.$emit('redirect', this.isWebEntry ? task : task.id, true); // NOSONAR
563
+ return true;
560
564
  } else {
561
565
  this.emitIfTaskCompleted(requestId);
562
566
  }
563
567
  this.taskId = task.id;
564
568
  this.nodeId = task.element_id;
565
569
  this.loadTask();
566
- } else if (this.parentRequest && ['COMPLETED', 'CLOSED'].includes(this.task.process_request.status)) {
570
+ } else if (!taskId && this.parentRequest && ['COMPLETED', 'CLOSED'].includes(this.task.process_request.status)) {
567
571
  this.$emit('completed', this.getAllowedRequestId());
568
572
  }
569
573
  this.disabled = false;
574
+ return Boolean(task);
570
575
  });
571
576
  },
572
577
  emitIfTaskCompleted(requestId) {
@@ -641,24 +646,27 @@ export default {
641
646
  * @param {Function} apiCall - The API call to be made.
642
647
  * @param {number} retries - The number of retry attempts.
643
648
  * @param {number} delay - The delay between retries in milliseconds.
649
+ * @param {Function} shouldRetry - Determines whether a successful response should be retried.
644
650
  * @returns {Promise} - The response from the API call.
645
651
  */
646
652
  // eslint-disable-next-line consistent-return
647
- async retryApiCall(apiCall, retries = 3, delay = 1000) {
653
+ async retryApiCall(apiCall, retries = 3, delay = 1000, shouldRetry = () => false) {
648
654
  for (let attempt = 0; attempt < retries; attempt++) {
649
655
  try {
650
656
  // eslint-disable-next-line no-await-in-loop
651
657
  const response = await apiCall();
652
- return response;
658
+ if (!shouldRetry(response) || attempt === retries - 1) {
659
+ return response;
660
+ }
653
661
  } catch (error) {
654
662
  if (attempt === retries - 1) {
655
663
  throw error;
656
664
  }
657
- // eslint-disable-next-line no-await-in-loop
658
- await new Promise((resolve) => {
659
- setTimeout(resolve, delay);
660
- });
661
665
  }
666
+ // eslint-disable-next-line no-await-in-loop
667
+ await new Promise((resolve) => {
668
+ setTimeout(resolve, delay);
669
+ });
662
670
  }
663
671
  },
664
672
  /**
@@ -693,6 +701,19 @@ export default {
693
701
 
694
702
  return this.$dataProvider.getTasks(`?${queryString}`);
695
703
  },
704
+ setVocabulariesSchemaUrl() {
705
+ if (
706
+ window.ProcessMaker
707
+ && window.ProcessMaker.packages
708
+ && window.ProcessMaker.packages.includes("package-vocabularies")
709
+ ) {
710
+ const schemaUrl = `vocabularies/task_schema/${this.taskId}`;
711
+ if (window.ProcessMaker.VocabulariesSchemaUrl !== schemaUrl) {
712
+ window.ProcessMaker.VocabulariesSchemaCache = null;
713
+ }
714
+ window.ProcessMaker.VocabulariesSchemaUrl = schemaUrl;
715
+ }
716
+ },
696
717
  /**
697
718
  * Parses a JSON string and returns the result.
698
719
  * @param {string} jsonString - The JSON string to parse.
@@ -919,6 +940,31 @@ export default {
919
940
  }
920
941
  },
921
942
 
943
+ async handleWebEntryTaskRedirect(data, tokenId) {
944
+ let taskHandled = false;
945
+ try {
946
+ taskHandled = await this.retryApiCall(
947
+ () => this.loadNextAssignedTask(this.requestId, tokenId),
948
+ 3,
949
+ 1000,
950
+ (handled) => handled !== true
951
+ );
952
+ } catch (error) {
953
+ taskHandled = false;
954
+ } finally {
955
+ if (!taskHandled) {
956
+ this.loadingTask = false;
957
+ this.disabled = false;
958
+ }
959
+ }
960
+
961
+ if (!taskHandled) {
962
+ const fallbackUrl = data?.params?.[0]?.payloadUrl
963
+ || (tokenId ? `/tasks/${tokenId}/edit` : `/requests/${this.requestId}`);
964
+ window.location.href = fallbackUrl;
965
+ }
966
+ },
967
+
922
968
  /**
923
969
  * Handles the 'redirectToTask' event by loading the specified task.
924
970
  * Updates the current task ID and reloads the task data.
@@ -947,6 +993,13 @@ export default {
947
993
  window.location.href = await this.getDestinationUrl();
948
994
  return;
949
995
  }
996
+
997
+ // Web Entry needs the complete task to preserve the target request context.
998
+ if (this.isWebEntry) {
999
+ await this.handleWebEntryTaskRedirect(data, tokenId);
1000
+ return;
1001
+ }
1002
+
950
1003
  this.nodeId = nodeId;
951
1004
  this.taskId = tokenId;
952
1005
 
package/src/main.js CHANGED
@@ -203,6 +203,17 @@ window.ProcessMaker = {
203
203
  }
204
204
  }
205
205
  });
206
+ } else if (url === "/requests/data_sources/1/resources/list/data") {
207
+ resolve({
208
+ data: {
209
+ response: [
210
+ { value: 1, content: "James" },
211
+ { value: 2, content: "John" },
212
+ { value: 3, content: "Mary" },
213
+ { value: 4, content: "Patricia" }
214
+ ]
215
+ }
216
+ });
206
217
  } else if (url === "/data_sources") {
207
218
  resolve({
208
219
  data: {
@@ -10,25 +10,52 @@ import { findRootScreen } from "./DataReference";
10
10
  const stringFormats = ['string', 'datetime', 'date', 'password'];
11
11
  const parentReference = [];
12
12
 
13
+ const getVocabulariesSchema = () => {
14
+ if (window.ProcessMaker?.packages?.includes("package-vocabularies")) {
15
+ if (window.ProcessMaker.VocabulariesSchemaUrl) {
16
+ const schemaUrl = window.ProcessMaker.VocabulariesSchemaUrl;
17
+ const cache = window.ProcessMaker.VocabulariesSchemaCache;
18
+
19
+ if (cache && cache.url === schemaUrl) {
20
+ return cache.promise || cache.data;
21
+ }
22
+
23
+ const promise = window.ProcessMaker.apiClient
24
+ .get(schemaUrl)
25
+ .then((response) => {
26
+ if (window.ProcessMaker.VocabulariesSchemaUrl === schemaUrl) {
27
+ window.ProcessMaker.VocabulariesSchemaCache = {
28
+ url: schemaUrl,
29
+ data: response.data
30
+ };
31
+ }
32
+ return response.data;
33
+ })
34
+ .catch((error) => {
35
+ if (window.ProcessMaker.VocabulariesSchemaCache?.url === schemaUrl) {
36
+ window.ProcessMaker.VocabulariesSchemaCache = null;
37
+ }
38
+ throw error;
39
+ });
40
+
41
+ window.ProcessMaker.VocabulariesSchemaCache = {
42
+ url: schemaUrl,
43
+ promise
44
+ };
45
+
46
+ return promise;
47
+ }
48
+ if (window.ProcessMaker.VocabulariesPreview) {
49
+ return window.ProcessMaker.VocabulariesPreview;
50
+ }
51
+ }
52
+ return {};
53
+ };
54
+
13
55
  export default {
14
56
  name: "ScreenContent",
15
57
  mixins: [DataReference, computedFields, VariablesToSubmitFilter],
16
- schema: [
17
- function() {
18
- if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
19
- if (window.ProcessMaker.VocabulariesSchemaUrl) {
20
- let response = window.ProcessMaker.apiClient.get(window.ProcessMaker.VocabulariesSchemaUrl);
21
- return response.then(response => {
22
- return response.data;
23
- });
24
- }
25
- if (window.ProcessMaker.VocabulariesPreview) {
26
- return window.ProcessMaker.VocabulariesPreview;
27
- }
28
- }
29
- return {};
30
- },
31
- ],
58
+ schema: [getVocabulariesSchema],
32
59
  data() {
33
60
  return {
34
61
  ValidationRules__: {},