feat: Attach popover to review pills for more info
This commit is contained in:
parent
860473ab0a
commit
96ec88d4d9
3 changed files with 28 additions and 7 deletions
|
|
@ -61,7 +61,7 @@ frappe.ui.form.Review = class Review {
|
|||
options: this.get_involved_users(),
|
||||
default: this.frm.doc.owner
|
||||
}, {
|
||||
fieldname: 'action',
|
||||
fieldname: 'review_type',
|
||||
fieldtype: 'Select',
|
||||
label: __('Action'),
|
||||
options: [{
|
||||
|
|
@ -96,6 +96,7 @@ frappe.ui.form.Review = class Review {
|
|||
},
|
||||
to_user: values.to_user,
|
||||
points: values.points,
|
||||
review_type: values.review_type,
|
||||
reason: values.reason
|
||||
}).then(() => {
|
||||
review_dialog.hide();
|
||||
|
|
@ -114,15 +115,34 @@ frappe.ui.form.Review = class Review {
|
|||
'docname': this.frm.doc.name,
|
||||
}).then(review_logs => {
|
||||
review_logs.forEach(review_log => {
|
||||
this.review_list_wrapper.prepend(`
|
||||
let review_pill = $(`
|
||||
<span class="review-pill">
|
||||
${frappe.avatar(review_log.owner)}
|
||||
<span class="text-muted">
|
||||
${review_log.points}
|
||||
<span class="bold ${review_log.type === 'Appreciation' ? 'text-success': 'text-danger'}">
|
||||
${review_log.type === 'Appreciation' ? '+': ''}${review_log.points}
|
||||
</span>
|
||||
</span>
|
||||
`);
|
||||
this.review_list_wrapper.prepend(review_pill);
|
||||
this.setup_detail_popover(review_pill, review_log);
|
||||
});
|
||||
});
|
||||
}
|
||||
setup_detail_popover(el, data) {
|
||||
el.popover({
|
||||
animation: true,
|
||||
trigger: 'hover',
|
||||
delay: 500,
|
||||
placement: 'top',
|
||||
content: () => {
|
||||
return `<div class="text-small">
|
||||
<b>For</b> ${frappe.user_info(data.user).fullname}
|
||||
<p>${data.reason}</p>
|
||||
</div>`;
|
||||
},
|
||||
html: true,
|
||||
container: 'body'
|
||||
});
|
||||
return el;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -385,8 +385,7 @@ body[data-route^="Module"] .main-menu {
|
|||
border: 1px solid #d2d8dd;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
margin-right: 5px;
|
||||
margin-bottom: 10px;
|
||||
margin: 0 10px 10px 0;
|
||||
.avatar {
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
|
|
@ -400,5 +399,6 @@ body[data-route^="Module"] .main-menu {
|
|||
align-self: center;
|
||||
font-size: @text-small;
|
||||
}
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ from frappe.utils import cint
|
|||
|
||||
class EnergyPointLog(Document):
|
||||
def after_insert(self):
|
||||
message = ''
|
||||
if self.type == 'Auto':
|
||||
message=_('You gained <b>{}</b> points').format(self.points)
|
||||
elif self.type == 'Appreciation':
|
||||
|
|
@ -113,4 +114,4 @@ def get_reviews(doctype, docname):
|
|||
'reference_doctype': doctype,
|
||||
'reference_name': docname,
|
||||
'type': ['in', ('Appreciation', 'Criticism')],
|
||||
}, fields=['points', 'owner', 'type', 'user'])
|
||||
}, fields=['points', 'owner', 'type', 'user', 'reason'])
|
||||
Loading…
Add table
Reference in a new issue