added last comment in form

This commit is contained in:
Rushabh Mehta 2012-10-01 18:29:01 +05:30
parent bc11149738
commit 2d85baf67d
2 changed files with 23 additions and 3 deletions

View file

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

View file

@ -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) {
$('<div class="latest-comment help-box" style="margin-top:0px;">').prependTo(wrapper);
}
var comment_list = wn.widgets.form.comments.comment_list[me.docname];
if(comment_list) {
$(wrapper).find(".latest-comment")
.html(repl('<div style="width: 70%; float:left;">\
Last Comment: <b>%(comment)s</b></div>\
<div style="width: 25%; float:right; text-align: right; font-size: 90%">\
by %(comment_by_fullname)s</div>\
<div class="clear"></div>', 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');