Can use admin menu item to attach a note, too

This commit is contained in:
Robin Ward 2016-03-11 13:48:06 -05:00
parent bc9057073b
commit 9e040cabc9
2 changed files with 21 additions and 9 deletions

View File

@ -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);
});
}
});
});

View File

@ -2,5 +2,5 @@ en:
js:
staff_notes:
title: "Staff Notes"
attach: "Attach Note"
attach: "Attach Staff Note"
remove: "Remove Note"