@processmaker/screen-builder 2.78.3 → 2.78.4

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.78.3",
3
+ "version": "2.78.4",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -9,75 +9,64 @@
9
9
  </b-card>
10
10
  <div v-else>
11
11
  <template v-if="filesInfo.length > 0">
12
- <div v-for="(file, idx) in filesInfo" :key="idx" :data-cy="file.id + '-' + file.name.replace(/[^0-9a-zA-Z\-]/g, '-')">
13
- <b-btn v-show="!isReadOnly"
14
- class="mb-2 d-print-none" variant="primary" :aria-label="$attrs['aria-label']"
12
+ <div
13
+ v-for="(file, idx) in filesInfo"
14
+ :key="idx"
15
+ :data-cy="file.id + '-' + file.name.replace(/[^0-9a-zA-Z\-]/g, '-')"
16
+ >
17
+ <b-btn
18
+ v-show="!isReadOnly"
19
+ class="mb-2 d-print-none"
20
+ variant="primary"
21
+ :aria-label="$attrs['aria-label']"
15
22
  @click="downloadFile(file)"
16
23
  >
17
- <i class="fas fa-file-download"/> {{ $t('Download') }}
24
+ <i class="fas fa-file-download" /> {{ $t("Download") }}
18
25
  </b-btn>
19
26
  {{ file.file_name }}
20
27
  </div>
21
28
  </template>
22
29
  <div v-else>
23
- {{ $t('No files available for download') }}
30
+ {{ $t("No files available for download") }}
24
31
  </div>
25
32
  </div>
26
33
  </div>
27
34
  </template>
28
35
 
29
-
30
36
  <script>
31
- import _ from 'lodash';
37
+ import _ from "lodash";
32
38
 
33
39
  export default {
34
40
  inheritAttrs: false,
41
+ props: [
42
+ "name",
43
+ "value",
44
+ "endpoint",
45
+ "requestFiles",
46
+ "label",
47
+ "transient-data"
48
+ ],
35
49
  data() {
36
50
  return {
37
51
  filesInfo: [],
38
- prefix: '',
39
- rowId: null,
52
+ prefix: "",
53
+ rowId: null
40
54
  };
41
55
  },
42
- props: ['name', 'value', 'endpoint', 'requestFiles', 'label', 'transient-data'],
43
- mounted() {
44
- if (this.donwloadingNotAvailable) {
45
- // Not somewhere we can download anything (like web entry start event)
46
- return;
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
- }
53
- this.setFilesInfo();
54
- },
55
- watch: {
56
- value: {
57
- handler() {
58
- this.setFilesInfo();
59
- },
60
- deep: true,
61
- },
62
- fileDataName() {
63
- this.setFilesInfo();
64
- },
65
- },
66
56
  computed: {
67
57
  donwloadingNotAvailable() {
68
58
  return !this.collection && !this.requestId;
69
59
  },
70
60
  inPreviewMode() {
71
- return this.mode === 'preview' && !window.exampleScreens;
61
+ return this.mode === "preview" && !window.exampleScreens;
72
62
  },
73
63
  messageForPreview() {
74
- return this.$t(
75
- 'Download button for {{fileName}} will appear here.',
76
- { fileName: this.name }
77
- );
64
+ return this.$t("Download button for {{fileName}} will appear here.", {
65
+ fileName: this.name
66
+ });
78
67
  },
79
68
  messageForNotAvailable() {
80
- return this.$t('Downloading files is not available.');
69
+ return this.$t("Downloading files is not available.");
81
70
  },
82
71
  mode() {
83
72
  return this.$root.$children[0].mode;
@@ -86,25 +75,50 @@ export default {
86
75
  return this.$attrs.readonly ? this.$attrs.readonly : false;
87
76
  },
88
77
  fileDataName() {
89
- return this.prefix + this.name + (this.rowId ? '.' + this.rowId : '');
78
+ return this.prefix + this.name + (this.rowId ? `.${this.rowId}` : "");
90
79
  },
91
80
  requestId() {
92
- let node = document.head.querySelector('meta[name="request-id"]');
81
+ const node = document.head.querySelector(`meta[name="request-id"]`);
93
82
  if (node === null) {
94
83
  return null;
95
84
  }
96
85
  return node.content;
97
86
  },
98
87
  collection() {
99
- const collectionIdNode = document.head.querySelector('meta[name="collection-id"]');
88
+ const collectionIdNode = document.head.querySelector(
89
+ `meta[name="collection-id"]`
90
+ );
100
91
  if (collectionIdNode) {
101
92
  return collectionIdNode.content;
102
93
  }
103
94
  return false;
104
95
  },
105
96
  requestData() {
106
- return {_parent: {...this.$parent._parent}, ...this.transientData};
97
+ return { _parent: { ...this.$parent._parent }, ...this.transientData };
98
+ }
99
+ },
100
+ watch: {
101
+ value: {
102
+ handler() {
103
+ this.setFilesInfo();
104
+ },
105
+ deep: true
107
106
  },
107
+ fileDataName() {
108
+ this.setFilesInfo();
109
+ }
110
+ },
111
+ mounted() {
112
+ if (this.donwloadingNotAvailable) {
113
+ // Not somewhere we can download anything (like web entry start event)
114
+ return;
115
+ }
116
+
117
+ if (this.collection && this.value) {
118
+ // eslint-disable-next-line vue/no-mutating-props
119
+ this.value.file_name = this.value.name;
120
+ }
121
+ this.setFilesInfo();
108
122
  },
109
123
  methods: {
110
124
  downloadFile(file) {
@@ -115,9 +129,12 @@ export default {
115
129
  }
116
130
  },
117
131
  requestEndpoint(file) {
118
- let endpoint = this.endpoint;
132
+ let { endpoint } = this;
119
133
 
120
- if (_.has(window, 'PM4ConfigOverrides.useDefaultUrlDownload') && window.PM4ConfigOverrides.useDefaultUrlDownload) {
134
+ if (
135
+ _.has(window, "PM4ConfigOverrides.useDefaultUrlDownload") &&
136
+ window.PM4ConfigOverrides.useDefaultUrlDownload
137
+ ) {
121
138
  // Use default endpoint when coming from a package.
122
139
  if (this.requestId) {
123
140
  return `requests/${this.requestId}/files/${file.id}/contents`;
@@ -125,7 +142,7 @@ export default {
125
142
  return `../files/${file.id}/contents`;
126
143
  }
127
144
 
128
- if (_.has(window, 'PM4ConfigOverrides.getFileEndpoint')) {
145
+ if (_.has(window, "PM4ConfigOverrides.getFileEndpoint")) {
129
146
  endpoint = window.PM4ConfigOverrides.getFileEndpoint;
130
147
  return `${endpoint}/${file.id}/contents`;
131
148
  }
@@ -133,7 +150,7 @@ export default {
133
150
  return `/files/${file.id}/contents`;
134
151
  },
135
152
  setPrefix() {
136
- if (this.name.startsWith('_parent.')) {
153
+ if (this.name.startsWith("_parent.")) {
137
154
  // do not set the loop prefix
138
155
  return;
139
156
  }
@@ -149,30 +166,34 @@ export default {
149
166
 
150
167
  i++;
151
168
  if (i > 100) {
152
- throw 'Loop Error';
169
+ throw new Error("Loop Error");
153
170
  }
154
171
  }
155
172
 
156
173
  if (parent && parent.loopContext) {
157
- this.prefix = parent.loopContext + '.';
174
+ this.prefix = `${parent.loopContext}.`;
158
175
  }
159
176
  },
160
177
  downloadRequestFile(file) {
161
- this.$dataProvider.download(this.requestEndpoint(file)).then(response => {
162
- this.sendToBrowser(response, file);
163
- });
178
+ this.$dataProvider
179
+ .download(this.requestEndpoint(file))
180
+ .then((response) => {
181
+ this.sendToBrowser(response, file);
182
+ });
164
183
  },
165
184
  downloadCollectionFile(file) {
166
- this.$dataProvider.download('/files/' + file.id + '/contents').then(response => {
167
- this.sendToBrowser(response, file);
168
- });
185
+ this.$dataProvider
186
+ .download(`/files/${file.id}/contents`)
187
+ .then((response) => {
188
+ this.sendToBrowser(response, file);
189
+ });
169
190
  },
170
191
  sendToBrowser(response, file) {
171
- //axios needs to be told to open the file
192
+ // axios needs to be told to open the file
172
193
  const url = window.URL.createObjectURL(new Blob([response.data]));
173
- const link = document.createElement('a');
194
+ const link = document.createElement("a");
174
195
  link.href = url;
175
- link.setAttribute('download', file.file_name);
196
+ link.setAttribute("download", file.file_name);
176
197
  document.body.appendChild(link);
177
198
  link.click();
178
199
  },
@@ -184,51 +205,55 @@ export default {
184
205
  this.setFilesInfoFromRequest();
185
206
  }
186
207
  },
187
- setFilesInfoFromRequest() {
188
- const fileId = this.value ? this.value : _.get(this.requestData, this.fileDataName, null);
189
- let endpoint = this.endpoint;
190
-
208
+ setFilesInfoFromRequest() {
209
+ const fileId = this.value
210
+ ? this.value
211
+ : _.get(this.requestData, this.fileDataName, null);
212
+ let { endpoint } = this;
213
+
191
214
  if (this.requestFiles) {
192
215
  this.filesInfo.push(_.get(this.requestFiles, this.fileDataName, null));
193
216
  return;
194
217
  }
195
-
218
+
196
219
  if (!this.requestId || !fileId) {
220
+ this.filesInfo = [];
197
221
  return;
198
222
  }
199
-
223
+
200
224
  if (!endpoint) {
201
- endpoint = 'requests/' + this.requestId + '/files?id=' + fileId;
202
- if (_.has(window, 'PM4ConfigOverrides.getFileEndpoint')) {
225
+ endpoint = `requests/${this.requestId}/files?id=${fileId}`;
226
+ if (_.has(window, "PM4ConfigOverrides.getFileEndpoint")) {
203
227
  endpoint = window.PM4ConfigOverrides.getFileEndpoint;
204
- endpoint += '/' + fileId;
228
+ endpoint += `/${fileId}`;
205
229
  }
206
230
  }
207
231
 
208
- this.$dataProvider.get(endpoint).then(response => {
209
- const fileInfo = response.data.data ? _.get(response, 'data.data.0', null) : _.get(response, 'data', null);
232
+ this.$dataProvider.get(endpoint).then((response) => {
233
+ const fileInfo = response.data.data
234
+ ? _.get(response, "data.data.0", null)
235
+ : _.get(response, "data", null);
210
236
  if (fileInfo) {
211
- if (typeof this.value === 'number' && this.filesInfo.length > 0) {
237
+ if (typeof this.value === "number" && this.filesInfo.length > 0) {
212
238
  this.filesInfo[0] = fileInfo;
213
239
  } else {
214
240
  this.filesInfo.push(fileInfo);
215
241
  }
216
242
  } else {
217
- console.log(this.$t('File ID does not exist'));
243
+ console.log(this.$t("File ID does not exist"));
218
244
  }
219
245
  });
220
246
  },
221
247
  setFilesInfoFromCollectionValue() {
222
- const files = this.value ? this.value : _.get(this.requestData, this.fileDataName);
248
+ const files = this.value
249
+ ? this.value
250
+ : _.get(this.requestData, this.fileDataName);
223
251
  if (!this.value && !files) {
224
252
  this.filesInfo = [];
225
253
  return;
226
254
  }
227
255
  this.filesInfo = [this.value ? this.value : files];
228
- },
229
- },
256
+ }
257
+ }
230
258
  };
231
259
  </script>
232
-
233
- <style lang="scss" scoped>
234
- </style>