diff --git a/frappe/public/js/frappe/form/footer/timeline.html b/frappe/public/js/frappe/form/footer/timeline.html
index 4b603dc1b8..381b540300 100644
--- a/frappe/public/js/frappe/form/footer/timeline.html
+++ b/frappe/public/js/frappe/form/footer/timeline.html
@@ -13,9 +13,15 @@
-
diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js
index 0150c16714..16c51819ba 100644
--- a/frappe/public/js/frappe/form/footer/timeline.js
+++ b/frappe/public/js/frappe/form/footer/timeline.js
@@ -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;