From 01a955eb450d9e671324c8ca2058719df3797cc4 Mon Sep 17 00:00:00 2001 From: ci2014 Date: Wed, 6 Dec 2017 15:32:13 +0100 Subject: [PATCH] Allow developers to choose attachments (#4477) * Allow developers to choose attachments This change allows developers to choose attachments, even if there is a cur_frm object. * Update communication.js * Merge this.attachments and form attachments * fix codacy --- frappe/public/js/frappe/views/communication.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index ea02974f28..19fd967897 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -354,11 +354,14 @@ frappe.views.CommunicationComposer = Class.extend({ var fields = this.dialog.fields_dict; var attach = $(fields.select_attachments.wrapper).find(".attach-list").empty(); - if (cur_frm){ - var files = cur_frm.get_files(); - }else { - var files = this.attachments + var files = []; + if (this.attachments && this.attachments.length) { + files = files.concat(this.attachments); } + if (cur_frm) { + files = files.concat(cur_frm.get_files()); + } + if(files.length) { $.each(files, function(i, f) { if (!f.file_name) return;