[minor] reply mail button in timeline if doctype is communication

This commit is contained in:
mbauskar 2017-03-10 11:17:47 +05:30
parent cbe260c41e
commit aa6c26bd7f
2 changed files with 36 additions and 11 deletions

View file

@ -13,9 +13,15 @@
</div>
</div>
<div class="timeline-new-email">
<button class="btn btn-default btn-new-email btn-xs">
{% if(doctype === "Communication") { %}
<button class="btn btn-default btn-reply-email btn-xs">
{%= __("Reply") %}
</button>
{% } else { %}
<button class="btn btn-default btn-new-email btn-xs">
{%= __("New Email") %}
</button>
{% } %}
</div>
<div class="timeline-items">

View file

@ -11,7 +11,7 @@ frappe.ui.form.Timeline = Class.extend({
make: function() {
var me = this;
this.wrapper = $(frappe.render_template("timeline",
{})).appendTo(this.parent);
{doctype: this.frm.doctype})).appendTo(this.parent);
this.list = this.wrapper.find(".timeline-items");
this.input = this.wrapper.find(".form-control");
@ -35,15 +35,7 @@ frappe.ui.form.Timeline = Class.extend({
}
});
this.email_button = this.wrapper.find(".btn-new-email")
.on("click", function() {
new frappe.views.CommunicationComposer({
doc: me.frm.doc,
txt: frappe.markdown(me.input.val()),
frm: me.frm,
recipients: me.get_recipient()
})
});
this.setup_email_button();
this.list.on("click", ".toggle-blockquote", function() {
$(this).parent().siblings("blockquote").toggleClass("hidden");
@ -82,6 +74,33 @@ frappe.ui.form.Timeline = Class.extend({
},
setup_email_button: function() {
var me = this;
selector = this.frm.doctype === "Communication"? ".btn-reply-email": ".btn-new-email"
this.email_button = this.wrapper.find(selector)
.on("click", function() {
args = {
doc: me.frm.doc,
frm: me.frm,
recipients: me.get_recipient()
}
if(me.frm.doctype === "Communication") {
$.extend(args, {
txt: "",
last_email: me.frm.doc,
recipients: me.frm.doc.sender,
subject: __("Re: {0}", [me.frm.doc.subject]),
});
} else {
$.extend(args, {
txt: frappe.markdown(me.input.val())
});
}
new frappe.views.CommunicationComposer(args)
});
},
refresh: function(scroll_to_end) {
var me = this;