Skip to content
Snippets Groups Projects
Commit 1664b369 authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[REF]: Imporove support for fake upload progress. Also improved ExtFileObject...

[REF]: Imporove support for fake upload progress. Also improved ExtFileObject response to avoid copying undefined attributes from ExtFileInstance
parent 9e97e5a2
No related branches found
No related tags found
No related merge requests found
...@@ -200,85 +200,33 @@ export class ExtFileInstance { ...@@ -200,85 +200,33 @@ export class ExtFileInstance {
} }
/**
* Copies all non undefined attributes from ExtFileInstance to a new ExtFile object
* @param extFileInstance the instance of ExtFile
* @returns an ExtFile object
*/
static toExtFile(extFileInstance: ExtFileInstance): ExtFile { static toExtFile(extFileInstance: ExtFileInstance): ExtFile {
const console.log("before toExtFile()", extFileInstance);
{
id, let extFileClone: ExtFile = {}; // the new empty object
file, const extFileInstanceKeys = Object.keys(extFileInstance) as [keyof ExtFile];
name, const extFileInstanceValues = Object.values(extFileInstance);
size, // let's copy all user properties into it
type, for (let i = 0; i < extFileInstanceKeys.length; i++) {
imageUrl, if (extFileInstanceValues[i] !== undefined) {
valid, extFileClone[extFileInstanceKeys[i]] = extFileInstanceValues[i];
errors, }
uploadMessage, }
uploadStatus, console.log("after toExtFile()", extFileClone);
progress,
xhr, return extFileClone;
extraData,
extraUploadData,
serverResponse,
downloadUrl
} = extFileInstance;
return {
id,
file,
name,
size,
type,
imageUrl,
valid,
errors,
uploadMessage,
uploadStatus,
progress,
xhr,
extraData,
extraUploadData,
serverResponse,
downloadUrl
};
} }
/**
* Copies all non undefined attributes from ExtFileInstance to a new ExtFile object.
* @returns an ExtFile object
*/
toExtFile(): ExtFile { toExtFile(): ExtFile {
const { return ExtFileInstance.toExtFile(this);
id,
file,
name,
size,
type,
imageUrl,
valid,
errors,
uploadMessage,
uploadStatus,
progress,
xhr,
extraData,
extraUploadData,
serverResponse,
downloadUrl
} = this;
const result: ExtFile = {
id,
file,
name,
size,
type,
imageUrl,
valid,
errors,
uploadMessage,
uploadStatus,
progress,
xhr,
extraData,
extraUploadData,
serverResponse,
downloadUrl
} as ExtFile;
console.log("incomming result", { ...result });
return { ...result };
} }
static mock = (): ExtFileInstance => { static mock = (): ExtFileInstance => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment