@processmaker/screen-builder 2.24.1 → 2.25.0

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-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "2.24.1",
3
+ "version": "2.25.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -1738,9 +1738,9 @@
1738
1738
  }
1739
1739
  },
1740
1740
  "@processmaker/vue-form-elements": {
1741
- "version": "0.28.6",
1742
- "resolved": "https://registry.npmjs.org/@processmaker/vue-form-elements/-/vue-form-elements-0.28.6.tgz",
1743
- "integrity": "sha512-uxHsOkCNLJEF4mJu7dK4+qn2SL/mWDswdoV1kQjNjQkwBk10uGXDdAbtliHRbld3HDMAPUQAu69c+1fS8pDqjA==",
1741
+ "version": "0.28.7",
1742
+ "resolved": "https://registry.npmjs.org/@processmaker/vue-form-elements/-/vue-form-elements-0.28.7.tgz",
1743
+ "integrity": "sha512-CVtaOlyrrcWLoY8bqUyb0KOi9e7kKf0oDdACyrvTpy7UzsaYP05lf6KOqMKyKUXAvpHg8UVJKjxJTbJfflNDKA==",
1744
1744
  "dev": true,
1745
1745
  "requires": {
1746
1746
  "@tinymce/tinymce-vue": "2.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "2.24.1",
3
+ "version": "2.25.0",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -44,7 +44,7 @@
44
44
  "@cypress/code-coverage": "^3.8.1",
45
45
  "@fortawesome/fontawesome-free": "^5.6.1",
46
46
  "@panter/vue-i18next": "^0.15.2",
47
- "@processmaker/vue-form-elements": "0.28.6",
47
+ "@processmaker/vue-form-elements": "0.28.7",
48
48
  "@processmaker/vue-multiselect": "^2.2.0",
49
49
  "@vue/cli-plugin-babel": "^3.6.0",
50
50
  "@vue/cli-plugin-e2e-cypress": "^4.0.3",
@@ -16,7 +16,7 @@
16
16
  >
17
17
  <i class="fas fa-file-download"/> {{ $t('Download') }}
18
18
  </b-btn>
19
- {{ file.name }}
19
+ {{ file.file_name }}
20
20
  </div>
21
21
  </template>
22
22
  <div v-else>
@@ -39,18 +39,12 @@ export default {
39
39
  rowId: null,
40
40
  };
41
41
  },
42
- props: ['name', 'value', 'endpoint', 'requestFiles', 'label'],
42
+ props: ['name', 'value', 'endpoint', 'requestFiles', 'label', 'transient-data'],
43
43
  mounted() {
44
- this.$root.$on('set-upload-data-name',
45
- (recordList, index, id) => this.listenRecordList(recordList, index, id));
46
-
47
44
  if (this.donwloadingNotAvailable) {
48
45
  // Not somewhere we can download anything (like web entry start event)
49
46
  return;
50
47
  }
51
-
52
- this.checkIfInRecordList();
53
- this.setPrefix();
54
48
  this.setFilesInfo();
55
49
  },
56
50
  watch: {
@@ -103,24 +97,11 @@ export default {
103
97
  }
104
98
  return false;
105
99
  },
100
+ requestData() {
101
+ return {_parent: {...this.$parent._parent}, ...this.transientData};
102
+ },
106
103
  },
107
104
  methods: {
108
- parentRecordList(node) {
109
- if (node.$parent && node.$parent.$options) {
110
- if (node.$parent.$options._componentTag === 'form-record-list') {
111
- return node.$parent;
112
- }
113
- return this.parentRecordList(node.$parent);
114
- }
115
- return null;
116
- },
117
- listenRecordList(recordList, index, id) {
118
- const parent = this.parentRecordList(this);
119
- if (parent !== recordList) {
120
- return;
121
- }
122
- this.rowId = (parent !== null) ? id : null;
123
- },
124
105
  downloadFile(file) {
125
106
  if (this.collection) {
126
107
  this.downloadCollectionFile(file);
@@ -133,15 +114,16 @@ export default {
133
114
 
134
115
  if (_.has(window, 'PM4ConfigOverrides.getFileEndpoint')) {
135
116
  endpoint = window.PM4ConfigOverrides.getFileEndpoint;
136
- }
137
-
138
- if (endpoint && file.token) {
139
- return `${endpoint}/${file.id}?&token=${file.token}`;
117
+ return `${endpoint}/${file.id}`;
140
118
  }
141
119
 
142
120
  return `/files/${file.id}/contents`;
143
121
  },
144
122
  setPrefix() {
123
+ if (this.name.startsWith('_parent.')) {
124
+ // do not set the loop prefix
125
+ return;
126
+ }
145
127
  let parent = this.$parent;
146
128
  let i = 0;
147
129
  while (!parent.loopContext) {
@@ -177,93 +159,53 @@ export default {
177
159
  const url = window.URL.createObjectURL(new Blob([response.data]));
178
160
  const link = document.createElement('a');
179
161
  link.href = url;
180
- link.setAttribute('download', file.name);
162
+ link.setAttribute('download', file.file_name);
181
163
  document.body.appendChild(link);
182
164
  link.click();
183
165
  },
184
166
  setFilesInfo() {
185
167
  if (this.collection) {
168
+ this.setPrefix();
186
169
  this.setFilesInfoFromCollectionValue();
187
170
  } else {
188
171
  this.setFilesInfoFromRequest();
189
172
  }
190
173
  },
191
- setFilesInfoFromRequest() {
192
- if (!this.value) {
174
+ setFilesInfoFromRequest() {
175
+ const fileId = this.value ? this.value : _.get(this.requestData, this.fileDataName, null);
176
+ let endpoint = this.endpoint;
177
+
178
+ if (!this.requestId || !fileId) {
193
179
  return;
194
180
  }
195
-
196
- let requestFiles = _.get(
197
- window,
198
- `PM4ConfigOverrides.requestFiles["${this.fileDataName}"]`,
199
- []
200
- );
201
-
202
- requestFiles = requestFiles.filter(file => {
203
- // Filter any requestFiles that don't exist in this component's value. This can happen if
204
- // a file is uploaded but the task is not saved.
205
- if (Array.isArray(this.value)) {
206
- return this.value.some(valueFile => valueFile.file === file.id);
207
- } else {
208
- return file.id === this.value;
181
+
182
+ if (!endpoint) {
183
+ endpoint = 'requests/' + this.requestId + '/files?id=' + fileId;
184
+ if (_.has(window, 'PM4ConfigOverrides.getFileEndpoint')) {
185
+ endpoint = window.PM4ConfigOverrides.getFileEndpoint;
186
+ endpoint += '/' + fileId;
209
187
  }
210
- });
211
-
212
- // Might be accessing individual files from inside a loop
213
- if (requestFiles.length === 0 && this.fileDataName.endsWith('.file')) {
214
- requestFiles = this.requestFileInsideALoop();
215
188
  }
216
189
 
217
- this.filesInfo = requestFiles.map(file => {
218
- const info = { id: file.id, name: file.file_name };
219
- if (file.token) {
220
- // web entry
221
- info.token = file.token;
190
+ this.$dataProvider.get(endpoint).then(response => {
191
+ const fileInfo = response.data.data ? _.get(response, 'data.data.0', null) : _.get(response, 'data', null);
192
+ if (fileInfo) {
193
+ this.filesInfo.push(fileInfo);
194
+ } else {
195
+ window.ProcessMaker.alert(
196
+ this.$t('File Download Missing File'),
197
+ 'danger'
198
+ );
222
199
  }
223
- return info;
224
200
  });
225
201
  },
226
- requestFileInsideALoop() {
227
- const path = this.fileDataName.slice(0, -5);
228
- const loopFile = _.get(
229
- window,
230
- `PM4ConfigOverrides.requestFiles.${path}`,
231
- null
232
- );
233
- if (loopFile) {
234
- return [loopFile]; // Treat as single file download
235
- }
236
- return [];
237
- },
238
202
  setFilesInfoFromCollectionValue() {
239
- if (!this.value) {
203
+ const files = this.value ? this.value : _.get(this.requestData, this.fileDataName);
204
+ if (!this.value && !files) {
240
205
  this.filesInfo = [];
241
206
  return;
242
207
  }
243
- if (Array.isArray(this.value)) {
244
- // multi file upload
245
- this.filesInfo = this.value.map(value => value.file);
246
- } else {
247
- this.filesInfo = [this.value];
248
- }
249
-
250
- },
251
- checkIfInRecordList() {
252
- const parent = this.parentRecordList(this);
253
- if (parent !== null) {
254
- const recordList = parent;
255
- const prefix = recordList.name + '.';
256
- this.setFileUploadNameForChildren(recordList.$children, prefix);
257
- }
258
- },
259
- setFileUploadNameForChildren(children, prefix) {
260
- children.forEach(child => {
261
- if (_.get(child, '$options.name') === 'FileDownload') {
262
- child.prefix = prefix;
263
- } else if (_.get(child, '$children', []).length > 0) {
264
- this.setFileUploadNameForChildren(child.$children, prefix);
265
- }
266
- });
208
+ this.filesInfo = [this.value ? this.value : files];
267
209
  },
268
210
  },
269
211
  };
@@ -103,8 +103,6 @@ export default {
103
103
 
104
104
  this.removeDefaultClasses();
105
105
 
106
- this.checkIfInRecordList();
107
-
108
106
  this.setPrefix();
109
107
  if (this.$refs['uploader']) {
110
108
  this.$refs['uploader'].$forceUpdate();
@@ -438,15 +436,6 @@ export default {
438
436
  this.prefix = parent.loopContext + '.';
439
437
  }
440
438
  },
441
- setFileUploadNameForChildren(children, prefix) {
442
- children.forEach(child => {
443
- if (_.get(child, '$options.name') === 'FileUpload') {
444
- child.prefix = prefix;
445
- } else if (_.get(child, '$children', []).length > 0) {
446
- this.setFileUploadNameForChildren(child.$children, prefix);
447
- }
448
- });
449
- },
450
439
  addFile(file) {
451
440
  if (this.disabled) {
452
441
  file.ignored = true;
@@ -556,14 +545,6 @@ export default {
556
545
  : null;
557
546
  }
558
547
  },
559
- checkIfInRecordList() {
560
- const parent = this.parentRecordList(this);
561
- if (parent !== null) {
562
- const recordList = parent;
563
- const prefix = recordList.name + '.';
564
- this.setFileUploadNameForChildren(recordList.$children, prefix);
565
- }
566
- },
567
548
  },
568
549
  };
569
550
  </script>
@@ -90,6 +90,7 @@
90
90
  debug-context="Record List Add"
91
91
  :key="Array.isArray(value) ? value.length : 0"
92
92
  :_parent="validationData"
93
+ @update="updateRowDataNamePrefix"
93
94
  />
94
95
  </b-modal>
95
96
  <b-modal
@@ -116,6 +117,7 @@
116
117
  debug-context="Record List Edit"
117
118
  :_parent="validationData"
118
119
  :key="editFormVersion"
120
+ @update="updateRowDataNamePrefix"
119
121
  />
120
122
  </b-modal>
121
123
  <b-modal
@@ -195,12 +197,14 @@ export default {
195
197
  },
196
198
  },
197
199
  initFormValues: {},
200
+ currentRowIndex: null,
198
201
  };
199
202
  },
200
203
  mounted() {
201
204
  if (this._perPage) {
202
205
  this.perPage = this._perPage;
203
206
  }
207
+ this.updateRowDataNamePrefix = _.debounce(this.updateRowDataNamePrefix, 100);
204
208
  },
205
209
  computed: {
206
210
  popupConfig() {
@@ -280,6 +284,9 @@ export default {
280
284
  },
281
285
  },
282
286
  methods: {
287
+ updateRowDataNamePrefix() {
288
+ this.setUploadDataNamePrefix(this.currentRowIndex);
289
+ },
283
290
  sortChanged(payload) {
284
291
  this.lastSortConfig = payload;
285
292
  this.tableData.data = this.sort(this.tableData.data, payload);
@@ -309,6 +316,7 @@ export default {
309
316
  return field.key === '__filedownload';
310
317
  },
311
318
  setUploadDataNamePrefix(index = null) {
319
+ this.currentRowIndex = index;
312
320
  let rowId = null;
313
321
  if (index !== null && this.editItem) {
314
322
  rowId = this.editItem.row_id;
@@ -428,8 +436,7 @@ export default {
428
436
  // Add the item to our model and emit change
429
437
  // @todo Also check that value is an array type, if not, reset it to an array
430
438
  let data = this.value ? JSON.parse(JSON.stringify(this.value)) : [];
431
-
432
- const item = JSON.parse(JSON.stringify(this.addItem));
439
+ const item = JSON.parse(JSON.stringify({...this.addItem, _parent: undefined }));
433
440
  delete item._parent;
434
441
  data[data.length] = item;
435
442
 
@@ -26,7 +26,7 @@ import Json2Vue from '../mixins/Json2Vue';
26
26
  import CurrentPageProperty from '../mixins/CurrentPageProperty';
27
27
  import WatchersSynchronous from '@/components/watchers-synchronous';
28
28
  import ScreenRendererError from '../components/renderer/screen-renderer-error';
29
- import { cloneDeep, isEqual, debounce } from 'lodash';
29
+ import { cloneDeep, isEqual } from 'lodash';
30
30
 
31
31
  export default {
32
32
  name: 'screen-renderer',
@@ -43,7 +43,6 @@ export default {
43
43
  mounted() {
44
44
  this.currentDefinition = cloneDeep(this.definition);
45
45
  this.component = this.buildComponent(this.currentDefinition);
46
- this.rebuildScreen = debounce(this.rebuildScreen, 25);
47
46
  },
48
47
  watch: {
49
48
  definition: {
@@ -326,8 +326,8 @@ export default {
326
326
  }
327
327
  this.taskId = task.id;
328
328
  this.nodeId = task.element_id;
329
- } else {
330
- this.$emit('completed', (this.parentRequest ? this.parentRequest : requestId));
329
+ } else if (this.parentRequest) {
330
+ this.$emit('completed', this.parentRequest);
331
331
  }
332
332
  });
333
333
  },
@@ -283,6 +283,7 @@ export default [
283
283
  type: 'FormInput',
284
284
  field: 'minDate',
285
285
  config: {
286
+ name: 'Minimum Date',
286
287
  label: 'Minimum Date',
287
288
  validation: 'date_or_mustache',
288
289
  },
@@ -291,8 +292,9 @@ export default [
291
292
  type: 'FormInput',
292
293
  field: 'maxDate',
293
294
  config: {
295
+ name: 'Maximum Date',
294
296
  label: 'Maximum Date',
295
- validation: 'date_or_mustache',
297
+ validation: 'after_min_date|date_or_mustache',
296
298
  },
297
299
  },
298
300
  keyNameProperty,
@@ -222,6 +222,9 @@ export default {
222
222
  });
223
223
  },
224
224
  registerVariable(name, element = {}) {
225
+ if (name && name.startsWith('_parent.') || name && name.includes('._parent.')) {
226
+ return;
227
+ }
225
228
  if (!this.validVariableName(name)) {
226
229
  return;
227
230
  }
@@ -3,7 +3,7 @@ import _ from 'lodash';
3
3
  export default {
4
4
  methods: {
5
5
  dataFields(screen, definition) {
6
- this.variables.filter(v => !this.isComputedVariable(v.name, definition))
6
+ this.variables.filter(v => (!v.name.startsWith('_parent') && !v.name.includes('._parent.') && !this.isComputedVariable(v.name, definition)))
7
7
  .forEach(v => {
8
8
  let component = _.get(v, 'element.component');
9
9
  let dataFormat = _.get(v, 'config.dataFormat', null);