[fix] email dialog

This commit is contained in:
Rushabh Mehta 2017-01-19 15:05:51 +05:30
parent 4777650474
commit e1f1a411c8
4 changed files with 13 additions and 33 deletions

View file

@ -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

View file

@ -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) {

View file

@ -27,7 +27,6 @@
&& data.comment_type==="Comment")) { %}
<div class="comment-header small" style="cursor: pointer;">
<i class="{%= data.icon %} fa-fw"></i>
<i class="expand-icon octicon octicon-chevron-down"></i>
<span title="{%= data.comment_by %}">{%= data.fullname %}</span>
<span>
{% if (data.timeline_doctype===data.frm.doc.doctype
@ -81,7 +80,7 @@
{% if (frappe.model.can_read(\'Communication\')) { %}
</a>
{% } %}
{% if (data.communication_medium === "Email") { %}
<a class="text-muted relink-link timeline-content-show hide"
data-name="{%= data.name %}"> &ndash; {%= __("Relink") %}</a>

View file

@ -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<list["message"].length;i++){
accounts.push(list["message"][i]["email_id"])
}
me.from = {label: __("From"), fieldtype: "Select", reqd: 1, fieldname: "sender", options: accounts}
} else {
me.from = false
}
}
})
return fields;
},
prepare: function() {
this.setup_subject_and_recipients();
@ -248,7 +229,7 @@ frappe.views.CommunicationComposer = Class.extend({
me.dialog.set_value("content", last_edited_communication.content || "");
}
}
}
},