diff --git a/frappe/desk/form/load.py b/frappe/desk/form/load.py index ee7fffa242..b09a23cbb4 100644 --- a/frappe/desk/form/load.py +++ b/frappe/desk/form/load.py @@ -94,6 +94,7 @@ def get_docinfo(doc=None, doctype=None, name=None): frappe.response["docinfo"] = { "attachments": get_attachments(doc.doctype, doc.name), "communications": _get_communications(doc.doctype, doc.name), + 'total_comments': len(json.loads(doc.get('_comments') or '[]')), 'versions': get_versions(doc), "assignments": get_assignments(doc.doctype, doc.name), "permissions": get_doc_permissions(doc), diff --git a/frappe/public/js/frappe/form/footer/timeline.js b/frappe/public/js/frappe/form/footer/timeline.js index 418b8f277e..02b540a8c8 100644 --- a/frappe/public/js/frappe/form/footer/timeline.js +++ b/frappe/public/js/frappe/form/footer/timeline.js @@ -51,6 +51,10 @@ frappe.ui.form.Timeline = Class.extend({ var communications = me.get_communications().concat(new_communications); frappe.model.set_docinfo(me.frm.doc.doctype, me.frm.doc.name, "communications", communications); + if (new_communications.length < 20) { + me.more = false; + } + } else { me.more = false; } diff --git a/frappe/public/js/frappe/form/form_sidebar.js b/frappe/public/js/frappe/form/form_sidebar.js index 989bdfbca4..dfe8abb6b5 100644 --- a/frappe/public/js/frappe/form/form_sidebar.js +++ b/frappe/public/js/frappe/form/form_sidebar.js @@ -70,10 +70,10 @@ frappe.ui.form.Sidebar = Class.extend({ }, refresh_comments: function() { - var comments = $.map(this.frm.timeline.get_communications(), function(c) { + $.map(this.frm.timeline.get_communications(), function(c) { return (c.communication_type==="Communication" || (c.communication_type=="Comment" && c.comment_type==="Comment")) ? c : null; }); - this.comments.find(".n-comments").html(comments.length); + this.comments.find(".n-comments").html(this.frm.get_docinfo().total_comments); }, make_tags: function() {