@processmaker/screen-builder 2.99.4 → 2.99.5-patch.tce

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.99.4",
3
+ "version": "2.99.5-patch.tce",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -99,6 +99,10 @@ export default {
99
99
  this.removeDefaultClasses();
100
100
  },
101
101
  mounted() {
102
+ if (this.value) {
103
+ this.fetchFiles();
104
+ }
105
+
102
106
  this.$root.$on('set-upload-data-name',
103
107
  (recordList, index, id) => this.listenRecordList(recordList, index, id));
104
108
 
@@ -529,6 +533,10 @@ export default {
529
533
  }
530
534
 
531
535
  if (displayMessage.length > 0) {
536
+ const data = JSON.parse(displayMessage);
537
+ if (data.message) {
538
+ displayMessage = data.message;
539
+ }
532
540
  window.ProcessMaker.alert(`${this.$t('File Upload Error:')} ${displayMessage}`, 'danger');
533
541
  }
534
542
 
@@ -621,6 +629,28 @@ export default {
621
629
  : null;
622
630
  }
623
631
  },
632
+ async fetchFiles() {
633
+ const fileIds = Array.isArray(this.value) ? this.value : [this.value];
634
+
635
+ const fetchPromises = fileIds.map(async (file) => {
636
+ const id = file?.file ?? file;
637
+ const endpoint = `files/${id}`;
638
+ try {
639
+ const response = await ProcessMaker.apiClient.get(endpoint);
640
+ if (response?.data) {
641
+ const fileExists = this.files.some(existingFile => existingFile.id === response.data.id);
642
+ // Check if the file already exists in the list before adding it.
643
+ if (!fileExists) {
644
+ this.files.push(response.data);
645
+ }
646
+ }
647
+ } catch (error) {
648
+ console.error(`Failed to fetch file ${id}`, error);
649
+ }
650
+ });
651
+
652
+ return await Promise.all(fetchPromises);
653
+ },
624
654
  },
625
655
  };
626
656
  </script>