From e1f1a411c89cfbb5d3063e1571394258d83a22c6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 19 Jan 2017 15:05:51 +0530 Subject: [PATCH] [fix] email dialog --- frappe/boot.py | 2 + .../public/js/frappe/form/footer/timeline.js | 4 +- .../js/frappe/form/footer/timeline_item.html | 3 +- .../public/js/frappe/views/communication.js | 37 +++++-------------- 4 files changed, 13 insertions(+), 33 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index cc894bddb3..9686e4f3c0 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -65,6 +65,8 @@ def get_bootinfo(): bootinfo.error_report_email = frappe.get_hooks("error_report_email") bootinfo.calendars = sorted(frappe.get_hooks("calendars")) bootinfo.treeviews = frappe.get_hooks("treeviews") or [] + bootinfo.email_accounts = frappe.get_doc('User Email', fields=['email_account', 'email_id'], + filters=dict(parent=frappe.session.user)) bootinfo.lang_dict = get_lang_dict() return bootinfo diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js index 2f5b858a22..c065886dbb 100644 --- a/frappe/public/js/frappe/form/footer/timeline.js +++ b/frappe/public/js/frappe/form/footer/timeline.js @@ -37,10 +37,9 @@ frappe.ui.form.Timeline = Class.extend({ this.list.on("click",".comment-header",function(e) { if (!inList(["A","BUTTON"],e.target.tagName)) { $(this).parent().find(".timeline-content-show").toggleClass("hide"); - $(this).find(".expand-icon").toggleClass("octicon-chevron-down octicon-chevron-up") } }) - + this.email_button = this.wrapper.find(".btn-new-email") .on("click", function() { new frappe.views.CommunicationComposer({ @@ -137,7 +136,6 @@ frappe.ui.form.Timeline = Class.extend({ this.frm.trigger('timeline_refresh'); $(this.list.find(".comment-header")[0]).parent().find(".timeline-content-show").toggleClass("hide") - $(this.list.find(".comment-header")[0]).find(".expand-icon").toggleClass("octicon-chevron-down octicon-chevron-up") }, render_timeline_item: function(c) { diff --git a/frappe/public/js/frappe/form/footer/timeline_item.html b/frappe/public/js/frappe/form/footer/timeline_item.html index f15cf0aed8..f9ee179300 100755 --- a/frappe/public/js/frappe/form/footer/timeline_item.html +++ b/frappe/public/js/frappe/form/footer/timeline_item.html @@ -27,7 +27,6 @@ && data.comment_type==="Comment")) { %}
- {%= data.fullname %} {% if (data.timeline_doctype===data.frm.doc.doctype @@ -81,7 +80,7 @@ {% if (frappe.model.can_read(\'Communication\')) { %} {% } %} - + {% if (data.communication_medium === "Email") { %} – {%= __("Relink") %} diff --git a/frappe/public/js/frappe/views/communication.js b/frappe/public/js/frappe/views/communication.js index db4283b8ac..40a204bde1 100755 --- a/frappe/public/js/frappe/views/communication.js +++ b/frappe/public/js/frappe/views/communication.js @@ -47,10 +47,7 @@ frappe.views.CommunicationComposer = Class.extend({ }, get_fields: function() { - this.from = {}; - this.get_from(); var fields= [ - this.from , {label:__("To"), fieldtype:"Data", reqd: 0, fieldname:"recipients",length:524288}, {fieldtype: "Section Break", collapsible: 1, label: "CC & Standard Reply"}, {label:__("CC"), fieldtype:"Data", fieldname:"cc",length:524288}, @@ -86,32 +83,16 @@ frappe.views.CommunicationComposer = Class.extend({ {label:__("Select Attachments"), fieldtype:"HTML", fieldname:"select_attachments"} ]; - if(!fields[1]){//removes from if doesnt have assigned email - fields.splice(1,1) + + // add from if user has access to multiple email accounts + if(frappe.boot.email_accounts && frappe.boot.email_accounts.length > 1) { + fields = [ + {label: __("From"), fieldtype: "Select", reqd: 1, fieldname: "sender", + options: frappe.boot.email_accounts.map(function(d) { return e.email_id; }) } + ].concat(fields); } - return fields - }, - get_from:function(){ - var me = this; - frappe.call({ - method: 'frappe.email.page.email_inbox.get_accounts', - args: {user: frappe.user["name"]}, - async: false, - callback: function (list) { - if (list["message"]) { - var accounts = []; - - for (var i =0;i