UX: Show staff notes icon in user card

If staff notes available then an icon will be displayed in user card by linking to user profile page
This commit is contained in:
Vinoth Kannan 2019-03-14 21:04:16 +05:30
parent 5cf3df533e
commit 52338dd6eb
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import { emojiUrlFor } from "discourse/lib/text";
export default {
shouldRender(args, component) {
const { siteSettings, currentUser } = component;
return siteSettings.staff_notes_enabled && currentUser && currentUser.staff;
},
setupComponent(args, component) {
const { user } = args;
const count =
user.get("staff_notes_count") ||
user.get("custom_fields.staff_notes_count") ||
0;
component.set("staffNotesCount", count);
component.set("emojiEnabled", component.siteSettings.enable_emoji);
component.set("emojiUrl", emojiUrlFor("pencil"));
component.set("user", user);
component.set("staffNotesTitle", I18n.t("staff_notes.show", { count }));
}
};

View File

@ -0,0 +1,9 @@
{{#if staffNotesCount}}
{{#link-to "user" user title=staffNotesTitle}}
{{#if emojiEnabled}}
<img src={{emojiUrl}} title={{staffNotesTitle}} alt="pencil" class="emoji">
{{else}}
{{d-icon "sticky-note"}}
{{/if}}
{{/link-to}}
{{/if}}