@decaf-ts/for-angular 0.1.15 → 0.1.16
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.
|
@@ -13640,37 +13640,52 @@ let FileUploadComponent = class FileUploadComponent extends NgxFormFieldDirectiv
|
|
|
13640
13640
|
async parseValue(revert = false) {
|
|
13641
13641
|
if (!revert) {
|
|
13642
13642
|
const files = this.files;
|
|
13643
|
-
if (
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
const
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13643
|
+
if (files?.length) {
|
|
13644
|
+
if (this.valueType === 'base64') {
|
|
13645
|
+
return JSON.stringify(await this.getDataURLs(files));
|
|
13646
|
+
}
|
|
13647
|
+
else {
|
|
13648
|
+
const data = [];
|
|
13649
|
+
for (const file of files) {
|
|
13650
|
+
const source = await this.getDataURLs(file);
|
|
13651
|
+
data.push({
|
|
13652
|
+
name: file.name,
|
|
13653
|
+
size: file.size,
|
|
13654
|
+
type: file.type,
|
|
13655
|
+
source,
|
|
13656
|
+
});
|
|
13657
|
+
}
|
|
13658
|
+
return JSON.stringify(data);
|
|
13656
13659
|
}
|
|
13657
|
-
return JSON.stringify(data);
|
|
13658
13660
|
}
|
|
13659
13661
|
}
|
|
13660
|
-
if (this.value
|
|
13662
|
+
if (this.value) {
|
|
13661
13663
|
try {
|
|
13662
|
-
|
|
13664
|
+
let value;
|
|
13665
|
+
try {
|
|
13666
|
+
value = JSON.parse(this.value);
|
|
13667
|
+
}
|
|
13668
|
+
catch (error) {
|
|
13669
|
+
value = this.value;
|
|
13670
|
+
}
|
|
13663
13671
|
const files = Array.isArray(value) ? value : [value];
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13672
|
+
if (files?.length) {
|
|
13673
|
+
this.files = files
|
|
13674
|
+
.map((file) => {
|
|
13675
|
+
if (this.isBase64String(file)) {
|
|
13676
|
+
const mime = this.getFileMime(file)?.split('/') || [];
|
|
13677
|
+
const type = mime?.[0] === 'text' ? mime?.[1] : `${mime?.[0]}/${mime?.[1]}`;
|
|
13678
|
+
return {
|
|
13679
|
+
name: mime?.[0] || 'file',
|
|
13680
|
+
type: `${type}` || 'image/*',
|
|
13681
|
+
source: file,
|
|
13682
|
+
};
|
|
13683
|
+
}
|
|
13684
|
+
return false;
|
|
13685
|
+
})
|
|
13686
|
+
.filter(Boolean);
|
|
13687
|
+
this.getPreview();
|
|
13688
|
+
}
|
|
13674
13689
|
}
|
|
13675
13690
|
catch (error) {
|
|
13676
13691
|
this.log.for(this.initialize).error(`Error parsing file list: ${error.message || error}`);
|