From 9e040cabc9fd2ff8416603e977dbbe03be077629 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 11 Mar 2016 13:48:06 -0500 Subject: [PATCH] Can use admin menu item to attach a note, too --- .../initializers/enable-staff-notes.js.es6 | 28 +++++++++++++------ config/locales/client.en.yml | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6 b/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6 index 4811a42..b7a7c7c 100644 --- a/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6 +++ b/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6 @@ -8,6 +8,15 @@ export default { if (!siteSettings.staff_notes_enabled) { return; } withPluginApi('0.2', api => { + function showStaffNotes() { + const userId = this.attrs.user_id; + return this.store.find('staff-note', { user_id: userId }).then(model => { + const controller = showModal('staff-notes', { model, title: 'staff_notes.title' }); + controller.reset(); + controller.set('userId', userId); + }); + } + api.decorateWidget('poster-name:after', dec => { const cfs = dec.attrs.userCustomFields || {}; if (cfs.has_staff_notes) { @@ -15,19 +24,22 @@ export default { } }); + api.decorateWidget('post-admin-menu:after', dec => { + return dec.attach('post-admin-menu-button', { + icon: 'pencil', + label: 'staff_notes.attach', + action: 'showStaffNotes' + }); + }); + + api.attachWidgetAction('post-admin-menu', 'showStaffNotes', showStaffNotes); + api.createWidget('staff-notes-icon', { tagName: 'span.staff-notes-icon', + click: showStaffNotes, html() { return this.attach('emoji', { name: 'pencil' }); - }, - - click() { - return this.store.find('staff-note', { user_id: this.attrs.user_id }).then(model => { - const controller = showModal('staff-notes', { model, title: 'staff_notes.title' }); - controller.reset(); - controller.set('userId', this.attrs.user_id); - }); } }); }); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 75323e8..4b82b04 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2,5 +2,5 @@ en: js: staff_notes: title: "Staff Notes" - attach: "Attach Note" + attach: "Attach Staff Note" remove: "Remove Note"