@@ -94,6 +94,7 @@ def get_docinfo(doc=None, doctype=None, name=None): | |||||
frappe.response["docinfo"] = { | frappe.response["docinfo"] = { | ||||
"attachments": get_attachments(doc.doctype, doc.name), | "attachments": get_attachments(doc.doctype, doc.name), | ||||
"communications": _get_communications(doc.doctype, doc.name), | "communications": _get_communications(doc.doctype, doc.name), | ||||
'total_comments': len(json.loads(doc.get('_comments') or '[]')), | |||||
'versions': get_versions(doc), | 'versions': get_versions(doc), | ||||
"assignments": get_assignments(doc.doctype, doc.name), | "assignments": get_assignments(doc.doctype, doc.name), | ||||
"permissions": get_doc_permissions(doc), | "permissions": get_doc_permissions(doc), | ||||
@@ -51,6 +51,10 @@ frappe.ui.form.Timeline = Class.extend({ | |||||
var communications = me.get_communications().concat(new_communications); | var communications = me.get_communications().concat(new_communications); | ||||
frappe.model.set_docinfo(me.frm.doc.doctype, me.frm.doc.name, "communications", communications); | frappe.model.set_docinfo(me.frm.doc.doctype, me.frm.doc.name, "communications", communications); | ||||
if (new_communications.length < 20) { | |||||
me.more = false; | |||||
} | |||||
} else { | } else { | ||||
me.more = false; | me.more = false; | ||||
} | } | ||||
@@ -70,10 +70,10 @@ frappe.ui.form.Sidebar = Class.extend({ | |||||
}, | }, | ||||
refresh_comments: function() { | 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; | 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() { | make_tags: function() { | ||||