From 4841e0902249966f62f63989c5b0e4678ecb0fa0 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 23 Apr 2019 15:41:23 +0530 Subject: [PATCH] fix: Attach get_value Return file_url in get_value --- .../js/frappe/file_uploader/FileUploader.vue | 6 ++++-- .../public/js/frappe/form/controls/attach.js | 19 +++---------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/frappe/public/js/frappe/file_uploader/FileUploader.vue b/frappe/public/js/frappe/file_uploader/FileUploader.vue index 295af49290..ae7f428327 100644 --- a/frappe/public/js/frappe/file_uploader/FileUploader.vue +++ b/frappe/public/js/frappe/file_uploader/FileUploader.vue @@ -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); } } } diff --git a/frappe/public/js/frappe/form/controls/attach.js b/frappe/public/js/frappe/form/controls/attach.js index 694bfb6fb3..00e9af4323 100644 --- a/frappe/public/js/frappe/form/controls/attach.js +++ b/frappe/public/js/frappe/form/controls/attach.js @@ -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(); }, });