UX: Add staff notes to admin user profile

This commit is contained in:
Robin Ward 2017-11-09 14:19:08 -05:00
parent 8d1cd35a52
commit 99ab454c74
7 changed files with 36 additions and 10 deletions

View File

@ -0,0 +1,4 @@
import connector from 'discourse/plugins/staff-notes/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile';
// Same as other connector
export default connector;

View File

@ -9,7 +9,10 @@ export default {
setupComponent(args, component) {
const { model } = args;
component.set('staffNotesCount', model.get('custom_fields.staff_notes_count') || 0);
component.set(
'staffNotesCount',
model.get('staff_notes_count') || model.get('custom_fields.staff_notes_count') || 0
);
},
actions: {

View File

@ -0,0 +1 @@
{{show-staff-notes show="showStaffNotes" count=staffNotesCount}}

View File

@ -1,9 +1 @@
{{#if siteSettings.staff_notes_enabled}}
{{#if currentUser.staff}}
{{#if staffNotesCount}}
<li><a {{action "showStaffNotes"}} href class="btn">{{fa-icon "pencil"}}{{i18n 'staff_notes.show' count=staffNotesCount}}</a></li>
{{else}}
<li><a {{action "showStaffNotes"}} href class="btn">{{fa-icon "pencil"}}{{i18n 'staff_notes.title'}}</a></li>
{{/if}}
{{/if}}
{{/if}}
<li>{{show-staff-notes show="showStaffNotes" count=staffNotesCount}}</li>

View File

@ -0,0 +1,14 @@
import computed from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
tagName: '',
@computed('count')
showCount: count => count && count > 0,
actions: {
show() {
this.sendAction('show');
}
}
});

View File

@ -0,0 +1,8 @@
<a {{action "show"}} href class="btn">
{{fa-icon "pencil"}}
{{#if showCount}}
{{i18n 'staff_notes.show' count=count}}
{{else}}
{{i18n 'staff_notes.title'}}
{{/if}}
</a>

View File

@ -142,6 +142,10 @@ after_initialize do
(SiteSetting.staff_notes_moderators_delete? && user.staff?) || user.admin?
end
add_to_serializer(:admin_detailed_user, :staff_notes_count, false) do
object.custom_fields && object.custom_fields['staff_notes_count'].to_i
end
DiscourseStaffNotes::Engine.routes.draw do
get '/' => 'staff_notes#index'
post '/' => 'staff_notes#create'