Merge pull request #7341 from netchampfaris/attach-get-value

fix: Attach get_value
This commit is contained in:
Shivam Mishra 2019-04-23 20:14:14 +05:30 committed by GitHub
commit 02fbf8de9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 18 deletions

View file

@ -364,11 +364,13 @@ export default {
}
} else {
file.failed = true;
let error = null;
try {
console.error(JSON.parse(xhr.responseText));
error = JSON.parse(xhr.responseText);
} catch(e) {
console.error(xhr.responseText);
// pass
}
frappe.request.cleanup({}, error);
}
}
}

View file

@ -83,29 +83,16 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlData.extend({
},
get_value: function() {
if ( this.fileobj ) {
if ( this.fileobj.file_url ) {
return this.fileobj.file_url;
} else if ( this.fileobj.filename ) {
var dataURI = this.fileobj.filename + ',' + this.dataurl;
return dataURI;
}
} else {
return this.value || null;
}
return this.value || null;
},
on_upload_complete: function(attachment) {
if(this.frm) {
this.parse_validate_and_set_in_model(attachment.file_url);
this.refresh();
this.frm.attachments.update_attachment(attachment);
this.frm.doc.docstatus == 1 ? this.frm.save('Update') : this.frm.save();
} else {
this.value = this.get_value();
this.refresh();
frappe.hide_progress();
}
this.value = attachment.file_url;
this.refresh();
},
});