@processmaker/screen-builder 2.62.1 → 2.64.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.62.1",
3
+ "version": "2.64.1",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -39,7 +39,7 @@
39
39
  "@cypress/code-coverage": "^3.8.1",
40
40
  "@fortawesome/fontawesome-free": "^5.6.1",
41
41
  "@panter/vue-i18next": "^0.15.2",
42
- "@processmaker/vue-form-elements": "0.42.0",
42
+ "@processmaker/vue-form-elements": "0.43.2",
43
43
  "@processmaker/vue-multiselect": "^2.2.0",
44
44
  "@vue/cli-plugin-babel": "^3.6.0",
45
45
  "@vue/cli-plugin-e2e-cypress": "^4.0.3",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@panter/vue-i18next": "^0.15.0",
91
- "@processmaker/vue-form-elements": "0.42.0",
91
+ "@processmaker/vue-form-elements": "0.43.2",
92
92
  "i18next": "^15.0.8",
93
93
  "vue": "^2.6.12",
94
94
  "vuex": "^3.1.1"
package/src/.DS_Store CHANGED
Binary file
package/src/App.vue CHANGED
@@ -400,6 +400,10 @@ export default {
400
400
  return warnings;
401
401
  },
402
402
  },
403
+ created() {
404
+ this.updateDataInput = debounce(this.updateDataInput, 1000);
405
+ this.updateDataPreview = debounce(this.updateDataPreview, 1000);
406
+ },
403
407
  mounted() {
404
408
  this.countElements = debounce(this.countElements, 2000);
405
409
  if (globalObject.ProcessMaker && globalObject.ProcessMaker.user && globalObject.ProcessMaker.user.lang) {
@@ -422,10 +426,9 @@ export default {
422
426
  },
423
427
  methods: {
424
428
  ...mapMutations("globalErrorsModule", { setStoreMode: "setMode" }),
425
- // eslint-disable-next-line func-names
426
- updateDataInput: debounce(function () {
429
+ updateDataInput() {
427
430
  this.updateDataInputNow();
428
- }, 1000),
431
+ },
429
432
  updateDataInputNow() {
430
433
  if (this.previewInputValid) {
431
434
  // Copy data over
@@ -433,10 +436,9 @@ export default {
433
436
  this.updateDataPreview();
434
437
  }
435
438
  },
436
- // eslint-disable-next-line func-names
437
- updateDataPreview: debounce(function () {
439
+ updateDataPreview() {
438
440
  this.previewDataStringify = JSON.stringify(this.previewData, null, 2);
439
- }, 1000),
441
+ },
440
442
  monacoMounted(editor) {
441
443
  this.editor = editor;
442
444
  this.editor.updateOptions({ readOnly: true });
@@ -45,6 +45,11 @@ export default {
45
45
  // Not somewhere we can download anything (like web entry start event)
46
46
  return;
47
47
  }
48
+
49
+ if (this.collection && this.value) {
50
+ // eslint-disable-next-line vue/no-mutating-props
51
+ this.value.file_name = this.value.name;
52
+ }
48
53
  this.setFilesInfo();
49
54
  },
50
55
  watch: {
@@ -114,6 +119,9 @@ export default {
114
119
 
115
120
  if (_.has(window, 'PM4ConfigOverrides.useDefaultUrlDownload') && window.PM4ConfigOverrides.useDefaultUrlDownload) {
116
121
  // Use default endpoint when coming from a package.
122
+ if (this.requestId) {
123
+ return `requests/${this.requestId}/files/${file.id}/contents`;
124
+ }
117
125
  return `../files/${file.id}/contents`;
118
126
  }
119
127
 
@@ -202,10 +210,7 @@ export default {
202
210
  if (fileInfo) {
203
211
  this.filesInfo.push(fileInfo);
204
212
  } else {
205
- window.ProcessMaker.alert(
206
- this.$t('File ID does not exist'),
207
- 'danger'
208
- );
213
+ console.log(this.$t('File ID does not exist'));
209
214
  }
210
215
  });
211
216
  },
@@ -111,6 +111,12 @@ export default {
111
111
  this.setPrefix();
112
112
  if (this.$refs['uploader']) {
113
113
  this.$refs['uploader'].$forceUpdate();
114
+ // Re-upload stored files;
115
+ // Files disappear when navigating between pages with the Page Navigation component
116
+ if (this.files.length > 0) {
117
+ this.$refs.uploader.uploader.addFiles(this.files);
118
+ this.uploading = false;
119
+ }
114
120
  }
115
121
 
116
122
  this.disabled = _.get(window, 'ProcessMaker.isSelfService', false);
@@ -288,6 +294,7 @@ export default {
288
294
  files: [],
289
295
  nativeFiles: {},
290
296
  uploading: false,
297
+ invalidFile: false,
291
298
  };
292
299
  },
293
300
  methods: {
@@ -450,6 +457,14 @@ export default {
450
457
  file.ignored = true;
451
458
  return false;
452
459
  }
460
+ if (file.fileType === undefined) {
461
+ const existingFile = this.files.find(el => {
462
+ if (el.name === file.name) {
463
+ return el.fileType;
464
+ }
465
+ });
466
+ file.fileType = existingFile.fileType;
467
+ }
453
468
 
454
469
  if (this.filesAccept) {
455
470
  file.ignored = true;
@@ -457,6 +472,8 @@ export default {
457
472
  file.ignored = false;
458
473
  }
459
474
  if (file.ignored) {
475
+ this.invalidFile = true;
476
+ this.uploading = false;
460
477
  window.ProcessMaker.alert(this.$t('File not allowed.'), 'danger');
461
478
  return false;
462
479
  }
@@ -493,6 +510,9 @@ export default {
493
510
  id,
494
511
  file_name: name,
495
512
  mime_type: rootFile.fileType,
513
+ // additional properties needed when re-uploading files to the uploader component
514
+ name: name,
515
+ fileType: rootFile.fileType,
496
516
  };
497
517
 
498
518
  this.$set(this.nativeFiles, id, rootFile);
@@ -521,6 +541,11 @@ export default {
521
541
  return null;
522
542
  },
523
543
  start() {
544
+ // Prevent the upload from being started when the file is invalid.
545
+ if (this.invalidFile) {
546
+ return;
547
+ }
548
+
524
549
  this.uploading = true;
525
550
  if (this.parentRecordList(this) === null) {
526
551
  this.row_id = null;
@@ -62,6 +62,14 @@ export default {
62
62
  name: "ScreenRenderer",
63
63
  components: { WatchersSynchronous, ScreenRendererError },
64
64
  mixins: [Json2Vue, CurrentPageProperty],
65
+ props: {
66
+ // property used to pass the context of the screen used as prefix for the file upload component
67
+ // e.g. `multi_instance_var.1` or `loop_var.1`
68
+ loopContext: {
69
+ type: String,
70
+ default: ""
71
+ }
72
+ },
65
73
  data() {
66
74
  return {
67
75
  currentDefinition: null,
@@ -16,6 +16,7 @@
16
16
  :custom-css="screen.custom_css"
17
17
  :watchers="screen.watchers"
18
18
  :key="refreshScreen"
19
+ :loop-context="loopContext"
19
20
  @update="onUpdate"
20
21
  @submit="submit"
21
22
  />
@@ -74,6 +75,7 @@ export default {
74
75
  csrfToken: { type: String, default: null },
75
76
  value: { type: Object, default: () => {} },
76
77
  beforeLoadTask: { type: Function, default: defaultBeforeLoadTask },
78
+ initialLoopContext: { type: String, default: "" }
77
79
  },
78
80
  data() {
79
81
  return {
@@ -230,7 +232,7 @@ export default {
230
232
  }
231
233
  },
232
234
  loadTask() {
233
- const url = `/${this.taskId}?include=data,user,requestor,processRequest,component,screen,requestData,bpmnTagName,interstitial,definition,nested`;
235
+ const url = `/${this.taskId}?include=data,user,requestor,processRequest,component,screen,requestData,loopContext,bpmnTagName,interstitial,definition,nested,userRequestPermission`;
234
236
  // For Vocabularies
235
237
  if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
236
238
  window.ProcessMaker.VocabulariesSchemaUrl = `vocabularies/task_schema/${this.taskId}`;
@@ -256,6 +258,7 @@ export default {
256
258
  prepareTask() {
257
259
  this.resetScreenState();
258
260
  this.requestData = _.get(this.task, 'request_data', {});
261
+ this.loopContext = _.get(this.task, "loop_context", "");
259
262
  this.refreshScreen++;
260
263
 
261
264
  this.$emit('task-updated', this.task);
@@ -326,7 +329,7 @@ export default {
326
329
  this.taskId = task.id;
327
330
  this.nodeId = task.element_id;
328
331
  } else if (this.parentRequest && ['COMPLETED', 'CLOSED'].includes(this.task.process_request.status)) {
329
- this.$emit('completed', this.parentRequest);
332
+ this.$emit('completed', this.getAllowedRequestId());
330
333
  }
331
334
  });
332
335
  },
@@ -379,10 +382,20 @@ export default {
379
382
  // This may no longer be needed
380
383
  },
381
384
  processCompleted() {
385
+ let requestId;
382
386
  if (this.parentRequest) {
383
- this.$emit('completed', this.parentRequest);
387
+ requestId = this.getAllowedRequestId();
388
+ this.$emit('completed', requestId);
384
389
  }
385
- this.$emit('completed', this.requestId);
390
+ if (requestId !== this.requestId) {
391
+ this.$emit('completed', this.requestId);
392
+ }
393
+ },
394
+ getAllowedRequestId() {
395
+ const permissions = this.task.user_request_permission || [];
396
+ const permission = permissions.find(item => item.process_request_id === this.parentRequest)
397
+ const allowed = permission && permission.allowed;
398
+ return allowed ? this.parentRequest : this.requestId
386
399
  },
387
400
  processUpdated: _.debounce(function(data) {
388
401
  if (
@@ -487,6 +500,7 @@ export default {
487
500
  this.processId = this.initialProcessId;
488
501
  this.nodeId = this.initialNodeId;
489
502
  this.requestData = this.value;
503
+ this.loopContext = this.initialLoopContext;
490
504
  },
491
505
  destroyed() {
492
506
  this.unsubscribeSocketListeners();
@@ -1,7 +1,19 @@
1
1
  <template>
2
2
  <div :class="containerClass">
3
3
  <custom-css-output>{{ customCssWrapped }}</custom-css-output>
4
- <screen-renderer ref="renderer" :value="data" :_parent="_parent" :definition="definition" :current-page="currentPage" @submit="submit" data-cy="screen-renderer" :show-errors="showErrors" :test-screen-definition="testScreenDefinition || false" class="p-0"/>
4
+ <screen-renderer
5
+ ref="renderer"
6
+ :value="data"
7
+ :_parent="_parent"
8
+ :definition="definition"
9
+ :current-page="currentPage"
10
+ data-cy="screen-renderer"
11
+ :show-errors="showErrors"
12
+ :test-screen-definition="testScreenDefinition || false"
13
+ class="p-0"
14
+ :loop-context="loopContext"
15
+ @submit="submit"
16
+ />
5
17
  </div>
6
18
  </template>
7
19
 
@@ -145,7 +145,6 @@ export default {
145
145
  },
146
146
  async submitForm() {
147
147
  await this.validateNow(findRootScreen(this));
148
- console.log(this.valid__, this.message__);
149
148
  if (!this.valid__) {
150
149
  window.ProcessMaker.alert(this.message__, "danger");
151
150
  // if the form is not valid the data is not emitted
@@ -28,9 +28,14 @@ export default {
28
28
  const safeDotName = this.safeDotName(name);
29
29
  const defaultComputedName = `default_${safeDotName}__`;
30
30
  this.addData(screen, `${name}_was_filled__`, `!!this.getValue(${JSON.stringify(name)}, this.vdata) || !!this.getValue(${JSON.stringify(name)}, data)`);
31
- this.addMounted(screen, `if (!this.${name}) {
32
- this.tryFormField(${JSON.stringify(name)}, () => {this.${this.dot2bracket(name)} = ${value};});
33
- }`);
31
+ this.addMounted(
32
+ screen,
33
+ `if (!this.${safeDotName}) {
34
+ this.tryFormField(${JSON.stringify(name)}, () => {
35
+ this.${safeDotName} = ${value};
36
+ this.setValue(${JSON.stringify(name)}, ${value}, this.vdata, this);});
37
+ }`
38
+ );
34
39
  screen.computed[defaultComputedName] = {
35
40
  get: new Function(`return this.tryFormField(${JSON.stringify(name)}, () => ${value});`),
36
41
  set() {},
@@ -1,51 +1,60 @@
1
1
  export default {
2
2
  props: {
3
3
  configRef: null,
4
- loopContext: null,
4
+ loopContext: null
5
5
  },
6
6
  data() {
7
7
  return {
8
- loops: [],
8
+ loops: []
9
9
  };
10
10
  },
11
11
  methods: {
12
12
  loadFormLoopProperties({ properties, element }) {
13
13
  this.registerVariable(element.config.settings.varname, element);
14
- this.loops.push({ variable: element.config.settings.varname, element, properties });
14
+ this.loops.push({
15
+ variable: element.config.settings.varname,
16
+ element,
17
+ properties
18
+ });
15
19
  },
16
20
  loadFormLoopItems({ element, node, definition }) {
17
- const loop = this.createComponent('div', {
18
- 'v-for': `(loopRow, index) in ${element.config.settings.varname}`,
21
+ const safeDotName = this.safeDotName(element.config.settings.varname);
22
+ const loop = this.createComponent("div", {
23
+ "v-for": `(loopRow, index) in ${safeDotName}`
19
24
  });
20
25
  const nested = {
21
26
  config: [
22
27
  {
23
- items: element.items,
24
- },
28
+ items: element.items
29
+ }
25
30
  ],
26
- watchers: definition.watchers,
31
+ watchers: definition.watchers
27
32
  };
28
33
 
29
- let loopContext = '';
34
+ let loopContext = "";
30
35
  if (this.loopContext) {
31
- loopContext = this.loopContext + '.';
36
+ loopContext = `${this.loopContext}.`;
32
37
  }
33
38
  loopContext += element.config.settings.varname;
34
39
 
35
40
  // Add nested component inside loop
36
- const child = this.createComponent('ScreenRenderer', {
37
- ':definition': this.byRef(nested),
38
- ':value': 'loopRow',
39
- ':loop-context': `'${loopContext}.' + index`,
40
- ':_parent': 'getValidationData()',
41
- ':components': this.byRef(this.components),
42
- ':config-ref': this.byRef(this.configRef || definition.config),
43
- '@submit': 'submitForm',
41
+ const child = this.createComponent("ScreenRenderer", {
42
+ ":definition": this.byRef(nested),
43
+ ":value": "loopRow",
44
+ ":loop-context": `'${loopContext}.' + index`,
45
+ ":_parent": "getValidationData()",
46
+ ":components": this.byRef(this.components),
47
+ ":config-ref": this.byRef(this.configRef || definition.config),
48
+ "@submit": "submitForm"
44
49
  });
45
- const addLoopRow = this.createComponent('AddLoopRow', {
46
- ':value': element.config.settings.varname,
47
- ':config': this.byRef(element.config),
48
- ':error': `${this.checkVariableExists('$v.vdata.' + element.config.name)} && validationMessage($v.vdata.${element.config.name}) || ${this.checkVariableExists('$v.schema.' + element.config.name)} && validationMessage($v.schema.${element.config.name})`,
50
+ const addLoopRow = this.createComponent("AddLoopRow", {
51
+ ":value": safeDotName,
52
+ ":config": this.byRef(element.config),
53
+ ":error": `${this.checkVariableExists(
54
+ `$v.vdata.${element.config.name}`
55
+ )} && validationMessage($v.vdata.${element.config.name})
56
+ || ${this.checkVariableExists(`$v.schema.${element.config.name}`)}
57
+ && validationMessage($v.schema.${element.config.name})`
49
58
  });
50
59
  loop.appendChild(child);
51
60
  node.appendChild(loop);
@@ -53,24 +62,24 @@ export default {
53
62
  // Register nested component as Array
54
63
  this.registerNestedVariable(
55
64
  element.config.settings.varname,
56
- element.config.settings.varname + '.index.',
65
+ `${element.config.settings.varname}.index.`,
57
66
  nested
58
67
  );
59
- },
68
+ }
60
69
  },
61
70
  mounted() {
62
- this.alias['FormLoop'] = 'div';
71
+ this.alias.FormLoop = "div";
63
72
  this.extensions.push({
64
73
  beforeload() {
65
74
  this.loops.splice(0);
66
75
  },
67
76
  onloadproperties(params) {
68
- if (params.element.container && params.componentName === 'FormLoop') {
77
+ if (params.element.container && params.componentName === "FormLoop") {
69
78
  this.loadFormLoopProperties(params);
70
79
  }
71
80
  },
72
81
  onloaditems(params) {
73
- if (params.element.container && params.componentName === 'FormLoop') {
82
+ if (params.element.container && params.componentName === "FormLoop") {
74
83
  this.loadFormLoopItems(params);
75
84
  }
76
85
  }