Browse Source

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

version-14
mbauskar 8 years ago
parent
commit
aa6c26bd7f
2 changed files with 36 additions and 11 deletions
  1. +7
    -1
      frappe/public/js/frappe/form/footer/timeline.html
  2. +29
    -10
      frappe/public/js/frappe/form/footer/timeline.js

+ 7
- 1
frappe/public/js/frappe/form/footer/timeline.html View File

@@ -13,9 +13,15 @@
</div> </div>
</div> </div>
<div class="timeline-new-email"> <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") %} {%= __("New Email") %}
</button> </button>
{% } %}
</div> </div>
<div class="timeline-items"> <div class="timeline-items">




+ 29
- 10
frappe/public/js/frappe/form/footer/timeline.js View File

@@ -11,7 +11,7 @@ frappe.ui.form.Timeline = Class.extend({
make: function() { make: function() {
var me = this; var me = this;
this.wrapper = $(frappe.render_template("timeline", this.wrapper = $(frappe.render_template("timeline",
{})).appendTo(this.parent);
{doctype: this.frm.doctype})).appendTo(this.parent);


this.list = this.wrapper.find(".timeline-items"); this.list = this.wrapper.find(".timeline-items");
this.input = this.wrapper.find(".form-control"); 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.list.on("click", ".toggle-blockquote", function() {
$(this).parent().siblings("blockquote").toggleClass("hidden"); $(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) { refresh: function(scroll_to_end) {
var me = this; var me = this;




Loading…
Cancel
Save