Run prettier on the javascript
This commit is contained in:
parent
3f5816204e
commit
4724ae1223
|
@ -1,76 +1,94 @@
|
||||||
import { withPluginApi } from 'discourse/lib/plugin-api';
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { iconNode } from 'discourse-common/lib/icon-library';
|
import { iconNode } from "discourse-common/lib/icon-library";
|
||||||
import { showStaffNotes } from 'discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes';
|
import { showStaffNotes } from "discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'enable-staff-notes',
|
name: "enable-staff-notes",
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const siteSettings = container.lookup('site-settings:main');
|
const siteSettings = container.lookup("site-settings:main");
|
||||||
const currentUser = container.lookup('current-user:main');
|
const currentUser = container.lookup("current-user:main");
|
||||||
if (!siteSettings.staff_notes_enabled || !currentUser || !currentUser.staff) { return; }
|
if (
|
||||||
|
!siteSettings.staff_notes_enabled ||
|
||||||
|
!currentUser ||
|
||||||
|
!currentUser.staff
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const store = container.lookup('store:main');
|
const store = container.lookup("store:main");
|
||||||
withPluginApi('0.8.15', api => {
|
withPluginApi("0.8.15", api => {
|
||||||
function widgetShowStaffNotes() {
|
function widgetShowStaffNotes() {
|
||||||
showStaffNotes(store, this.attrs.user_id, count => {
|
showStaffNotes(
|
||||||
this.sendWidgetAction('refreshStaffNotes', count);
|
store,
|
||||||
}, {
|
this.attrs.user_id,
|
||||||
postId: this.attrs.id
|
count => {
|
||||||
});
|
this.sendWidgetAction("refreshStaffNotes", count);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
postId: this.attrs.id
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.attachWidgetAction('post', 'refreshStaffNotes', function(count) {
|
api.attachWidgetAction("post", "refreshStaffNotes", function(count) {
|
||||||
const cfs = this.model.get('user_custom_fields') || {};
|
const cfs = this.model.get("user_custom_fields") || {};
|
||||||
cfs.staff_notes_count = count;
|
cfs.staff_notes_count = count;
|
||||||
this.model.set('user_custom_fields', cfs);
|
this.model.set("user_custom_fields", cfs);
|
||||||
});
|
});
|
||||||
|
|
||||||
api.modifyClass('controller:user', {
|
api.modifyClass("controller:user", {
|
||||||
staffNotesCount: null,
|
staffNotesCount: null,
|
||||||
|
|
||||||
_modelChanged: function() {
|
_modelChanged: function() {
|
||||||
this.set('staffNotesCount', this.get('model.custom_fields.staff_notes_count') || 0);
|
this.set(
|
||||||
}.observes('model').on('init'),
|
"staffNotesCount",
|
||||||
|
this.get("model.custom_fields.staff_notes_count") || 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
.observes("model")
|
||||||
|
.on("init"),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
showStaffNotes() {
|
showStaffNotes() {
|
||||||
const user = this.get('model');
|
const user = this.get("model");
|
||||||
showStaffNotes(store, user.get('id'), count => this.set('staffNotesCount', count));
|
showStaffNotes(store, user.get("id"), count =>
|
||||||
|
this.set("staffNotesCount", count)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const mobileView = api.container.lookup('site:main').mobileView;
|
const mobileView = api.container.lookup("site:main").mobileView;
|
||||||
const loc = mobileView ? 'before' : 'after';
|
const loc = mobileView ? "before" : "after";
|
||||||
api.decorateWidget(`poster-name:${loc}`, dec => {
|
api.decorateWidget(`poster-name:${loc}`, dec => {
|
||||||
const cfs = dec.attrs.userCustomFields || {};
|
const cfs = dec.attrs.userCustomFields || {};
|
||||||
if (cfs.staff_notes_count > 0) {
|
if (cfs.staff_notes_count > 0) {
|
||||||
return dec.attach('staff-notes-icon');
|
return dec.attach("staff-notes-icon");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
api.decorateWidget('post-admin-menu:after', dec => {
|
api.decorateWidget("post-admin-menu:after", dec => {
|
||||||
return dec.attach('post-admin-menu-button', {
|
return dec.attach("post-admin-menu-button", {
|
||||||
icon: 'pencil',
|
icon: "pencil",
|
||||||
label: 'staff_notes.attach',
|
label: "staff_notes.attach",
|
||||||
action: 'showStaffNotes'
|
action: "showStaffNotes"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
api.attachWidgetAction('post', 'showStaffNotes', widgetShowStaffNotes);
|
api.attachWidgetAction("post", "showStaffNotes", widgetShowStaffNotes);
|
||||||
|
|
||||||
api.createWidget('staff-notes-icon', {
|
api.createWidget("staff-notes-icon", {
|
||||||
tagName: 'span.staff-notes-icon',
|
tagName: "span.staff-notes-icon",
|
||||||
click: widgetShowStaffNotes,
|
click: widgetShowStaffNotes,
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
if (siteSettings.enable_emoji) {
|
if (siteSettings.enable_emoji) {
|
||||||
return this.attach('emoji', { name: 'pencil' });
|
return this.attach("emoji", { name: "pencil" });
|
||||||
} else {
|
} else {
|
||||||
return iconNode('sticky-note');
|
return iconNode("sticky-note");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue