diff --git a/frappe/core/doctype/comment/comment.py b/frappe/core/doctype/comment/comment.py index 4a7532e57c..2ad9f83b6c 100644 --- a/frappe/core/doctype/comment/comment.py +++ b/frappe/core/doctype/comment/comment.py @@ -34,11 +34,17 @@ class Comment(Document): def notify_change(self, action): key_map = { - 'Like': 'like_logs' + 'Like': 'like_logs', + 'Assigned': 'assignment_logs', + 'Assignment Completed': 'assignment_logs', + 'Comment': 'comments' } + key = key_map.get(self.comment_type) + if not key: return + frappe.publish_realtime('update_docinfo_for_{}_{}'.format(self.reference_doctype, self.reference_name), { 'doc': self.as_dict(), - 'key': key_map.get(self.comment_type, 'comments'), + 'key': key, 'action': action }, after_commit=True) diff --git a/frappe/desk/form/load.py b/frappe/desk/form/load.py index 270a06d4e2..b89bf47aa6 100644 --- a/frappe/desk/form/load.py +++ b/frappe/desk/form/load.py @@ -96,6 +96,7 @@ def get_docinfo(doc=None, doctype=None, name=None): 'total_comments': len(json.loads(doc.get('_comments') or '[]')), 'versions': get_versions(doc), "assignments": get_assignments(doc.doctype, doc.name), + "assignment_logs": get_comments(doc.doctype, doc.name, 'assignment'), "permissions": get_doc_permissions(doc), "shared": frappe.share.get_users(doc.doctype, doc.name), "share_logs": get_comments(doc.doctype, doc.name, 'share'), @@ -136,6 +137,9 @@ def get_comments(doctype, name, comment_type='Comment'): if comment_type == 'share': comment_types = ['Shared', 'Unshared'] + if comment_type == 'assignment': + comment_types = ['Assignment Completed', 'Assigned'] + comments = frappe.get_all('Comment', fields = ['name', 'creation', 'content', 'owner'], filters=dict( reference_doctype = doctype, reference_name = name, diff --git a/frappe/public/js/frappe/form/footer/new_timeline.js b/frappe/public/js/frappe/form/footer/new_timeline.js index 32d6627cc9..541be15f66 100644 --- a/frappe/public/js/frappe/form/footer/new_timeline.js +++ b/frappe/public/js/frappe/form/footer/new_timeline.js @@ -129,6 +129,7 @@ frappe.ui.form.NewTimeline = class { this.timeline_items.push(...this.get_share_timeline_contents()); this.timeline_items.push(...this.get_like_timeline_contents()); this.timeline_items.push(...this.get_custom_timeline_contents()); + this.timeline_items.push(...this.get_assignment_timeline_contents()); } // attachments // milestones @@ -253,6 +254,17 @@ frappe.ui.form.NewTimeline = class { return share_timeline_contents; } + get_assignment_timeline_contents() { + let assignment_timeline_contents = []; + (this.doc_info.assignment_logs || []).forEach(assignment => { + assignment_timeline_contents.push({ + creation: assignment.creation, + content: assignment.content, + }); + }); + return assignment_timeline_contents; + } + get_like_timeline_contents() { let like_timeline_contents = []; (this.doc_info.like_logs || []).forEach(like => {