fix(timeline): Add assignment logs

This commit is contained in:
Suraj Shetty 2020-09-03 13:27:50 +05:30
parent 01f3c640c9
commit 2a237e5aeb
3 changed files with 24 additions and 2 deletions

View file

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

View file

@ -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,

View file

@ -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 => {