From 2d85baf67d343ad4e84a093e1c1f72aea1f15410 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Oct 2012 18:29:01 +0530 Subject: [PATCH] added last comment in form --- public/js/legacy/widgets/form/form_header.js | 5 ++--- public/js/legacy/wn/widgets/form/comments.js | 21 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/public/js/legacy/widgets/form/form_header.js b/public/js/legacy/widgets/form/form_header.js index dd619dbced..ea66cfdf1e 100644 --- a/public/js/legacy/widgets/form/form_header.js +++ b/public/js/legacy/widgets/form/form_header.js @@ -40,7 +40,7 @@ _f.FrmHeader = Class.extend({ if(!frm.meta.issingle) { this.appframe.add_tab(frm.doctype, 0.3, function() { wn.set_route("List", frm.doctype); - }); + }); } }, refresh: function() { @@ -52,10 +52,9 @@ _f.FrmHeader = Class.extend({ wn.views.breadcrumbs(this.appframe, cur_frm.meta.module, cur_frm.meta.name, cur_frm.docname); } - + this.refresh_labels(); this.refresh_toolbar(); - }, refresh_labels: function() { cur_frm.doc = get_local(cur_frm.doc.doctype, cur_frm.doc.name); diff --git a/public/js/legacy/wn/widgets/form/comments.js b/public/js/legacy/wn/widgets/form/comments.js index e4f6d06b08..f499d4ae1e 100644 --- a/public/js/legacy/wn/widgets/form/comments.js +++ b/public/js/legacy/wn/widgets/form/comments.js @@ -29,9 +29,30 @@ wn.widgets.form.sidebar.Comments = function(parent, sidebar, doctype, docname) { $c('webnotes.widgets.form.comments.get_comments', {dt: me.doctype, dn: me.docname, limit: 5}, function(r, rt) { wn.widgets.form.comments.sync(me.doctype, me.docname, r); me.make_body(); + me.refresh_latest_comment(); }); } + this.refresh_latest_comment = function() { + var wrapper = cur_frm.page_layout.body; + if(!$(wrapper).find(".latest-comment").length) { + $('
').prependTo(wrapper); + } + var comment_list = wn.widgets.form.comments.comment_list[me.docname]; + if(comment_list) { + $(wrapper).find(".latest-comment") + .html(repl('
\ + Last Comment: %(comment)s
\ +
\ + by %(comment_by_fullname)s
\ +
', comment_list[0])) + .toggle(true); + } else { + $(wrapper).find(".latest-comment").toggle(false); + } + } + + this.make_body = function() { if(this.wrapper) this.wrapper.innerHTML = ''; else this.wrapper = $a(parent, 'div', 'sidebar-comment-wrapper');