Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
25 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ripts/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { showStaffNotes } from 'discourse/plugins/staff-notes/discourse-staff-notes/lib/staff-notes'; | ||
import { getOwner } from 'discourse-common/lib/get-owner'; | ||
|
||
export default { | ||
shouldRender(args, component) { | ||
const { siteSettings, currentUser } = component; | ||
return siteSettings.staff_notes_enabled && currentUser && currentUser.staff; | ||
}, | ||
|
||
setupComponent(args, component) { | ||
const { model } = args; | ||
component.set('staffNotesCount', model.get('custom_fields.staff_notes_count') || 0); | ||
}, | ||
|
||
actions: { | ||
showStaffNotes() { | ||
const store = getOwner(this).lookup('store:main'); | ||
const user = this.get('args.model'); | ||
showStaffNotes(store, user.get('id'), count => this.set('staffNotesCount', count)); | ||
} | ||
} | ||
}; |
18 changes: 18 additions & 0 deletions
18
assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import showModal from 'discourse/lib/show-modal'; | ||
import loadScript from 'discourse/lib/load-script'; | ||
|
||
export function showStaffNotes(store, userId, callback) { | ||
return loadScript('defer/html-sanitizer-bundle').then(() => { | ||
return store.find('staff-note', { user_id: userId }).then(model => { | ||
const controller = showModal('staff-notes', { | ||
model, | ||
title: 'staff_notes.title', | ||
addModalBodyView: true | ||
}); | ||
controller.reset(); | ||
controller.set('userId', userId); | ||
controller.set('callback', callback); | ||
return controller; | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters