diff --git a/assets/javascripts/discourse-staff-notes/connectors/admin-user-controls-after/add-staff-notes-button.js.es6 b/assets/javascripts/discourse-staff-notes/connectors/admin-user-controls-after/add-staff-notes-button.js.es6 index 46cfb93..7f0674b 100644 --- a/assets/javascripts/discourse-staff-notes/connectors/admin-user-controls-after/add-staff-notes-button.js.es6 +++ b/assets/javascripts/discourse-staff-notes/connectors/admin-user-controls-after/add-staff-notes-button.js.es6 @@ -1,4 +1,4 @@ -import connector from 'discourse/plugins/discourse-staff-notes/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile'; +import connector from "discourse/plugins/discourse-staff-notes/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile"; // Same as other connector export default connector; diff --git a/assets/javascripts/discourse-staff-notes/connectors/flagged-post-controls/show-staff-notes-on-flags.js.es6 b/assets/javascripts/discourse-staff-notes/connectors/flagged-post-controls/show-staff-notes-on-flags.js.es6 index 5b58d2b..ba31ea6 100644 --- a/assets/javascripts/discourse-staff-notes/connectors/flagged-post-controls/show-staff-notes-on-flags.js.es6 +++ b/assets/javascripts/discourse-staff-notes/connectors/flagged-post-controls/show-staff-notes-on-flags.js.es6 @@ -1,5 +1,5 @@ -import { showStaffNotes } from 'discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes'; -import { getOwner } from 'discourse-common/lib/get-owner'; +import { showStaffNotes } from "discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes"; +import { getOwner } from "discourse-common/lib/get-owner"; export default { shouldRender(args, component) { @@ -7,18 +7,20 @@ export default { }, setupComponent(args, component) { - let model = args.flaggedPost.get('user'); + let model = args.flaggedPost.get("user"); component.set( - 'staffNotesCount', - model.get('custom_fields.staff_notes_count') || 0 + "staffNotesCount", + model.get("custom_fields.staff_notes_count") || 0 ); }, actions: { showStaffNotes() { - const store = getOwner(this).lookup('store:main'); - const user = this.get('args.flaggedPost.user'); - showStaffNotes(store, user.get('id'), count => this.set('staffNotesCount', count)); + const store = getOwner(this).lookup("store:main"); + const user = this.get("args.flaggedPost.user"); + showStaffNotes(store, user.get("id"), count => + this.set("staffNotesCount", count) + ); } } }; diff --git a/assets/javascripts/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile.js.es6 b/assets/javascripts/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile.js.es6 index 7b4e637..bac44fc 100644 --- a/assets/javascripts/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile.js.es6 +++ b/assets/javascripts/discourse-staff-notes/connectors/user-profile-controls/show-notes-on-profile.js.es6 @@ -1,5 +1,5 @@ -import { showStaffNotes } from 'discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes'; -import { getOwner } from 'discourse-common/lib/get-owner'; +import { showStaffNotes } from "discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes"; +import { getOwner } from "discourse-common/lib/get-owner"; export default { shouldRender(args, component) { @@ -10,16 +10,20 @@ export default { setupComponent(args, component) { const { model } = args; component.set( - 'staffNotesCount', - model.get('staff_notes_count') || model.get('custom_fields.staff_notes_count') || 0 + "staffNotesCount", + model.get("staff_notes_count") || + 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)); + const store = getOwner(this).lookup("store:main"); + const user = this.get("args.model"); + showStaffNotes(store, user.get("id"), count => + this.set("staffNotesCount", count) + ); } } }; diff --git a/assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6 b/assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6 index 1413ac6..59d75c5 100644 --- a/assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6 +++ b/assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6 @@ -1,20 +1,20 @@ -import showModal from 'discourse/lib/show-modal'; -import loadScript from 'discourse/lib/load-script'; +import showModal from "discourse/lib/show-modal"; +import loadScript from "discourse/lib/load-script"; export function showStaffNotes(store, userId, callback, opts) { opts = opts || {}; - return loadScript('defer/html-sanitizer-bundle').then(() => { - return store.find('staff-note', { user_id: userId }).then(model => { - const controller = showModal('staff-notes', { + 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', + title: "staff_notes.title", addModalBodyView: true }); controller.reset(); - controller.set('userId', userId); - controller.set('callback', callback); - controller.set('postId', opts.postId); + controller.set("userId", userId); + controller.set("callback", callback); + controller.set("postId", opts.postId); return controller; }); }); diff --git a/assets/javascripts/discourse/adapters/staff-note.js.es6 b/assets/javascripts/discourse/adapters/staff-note.js.es6 index 991ad04..db214cb 100644 --- a/assets/javascripts/discourse/adapters/staff-note.js.es6 +++ b/assets/javascripts/discourse/adapters/staff-note.js.es6 @@ -1,10 +1,10 @@ -import RestAdapter from 'discourse/adapters/rest'; -import { ajax } from 'discourse/lib/ajax'; +import RestAdapter from "discourse/adapters/rest"; +import { ajax } from "discourse/lib/ajax"; export default RestAdapter.extend({ destroyRecord(store, type, record) { - const path = this.pathFor(store, type, record.get('id')); - const userId = record.get('user_id'); - return ajax(`${path}?user_id=${userId}`, { method: 'DELETE' }); + const path = this.pathFor(store, type, record.get("id")); + const userId = record.get("user_id"); + return ajax(`${path}?user_id=${userId}`, { method: "DELETE" }); } }); diff --git a/assets/javascripts/discourse/components/show-staff-notes.js.es6 b/assets/javascripts/discourse/components/show-staff-notes.js.es6 index fdbc665..0dea6a1 100644 --- a/assets/javascripts/discourse/components/show-staff-notes.js.es6 +++ b/assets/javascripts/discourse/components/show-staff-notes.js.es6 @@ -1,14 +1,14 @@ -import computed from 'ember-addons/ember-computed-decorators'; +import computed from "ember-addons/ember-computed-decorators"; export default Ember.Component.extend({ - tagName: '', + tagName: "", - @computed('count') + @computed("count") showCount: count => count && count > 0, actions: { show() { - this.sendAction('show'); + this.sendAction("show"); } } }); diff --git a/assets/javascripts/discourse/controllers/staff-notes.js.es6 b/assets/javascripts/discourse/controllers/staff-notes.js.es6 index 4f25376..db1bc55 100644 --- a/assets/javascripts/discourse/controllers/staff-notes.js.es6 +++ b/assets/javascripts/discourse/controllers/staff-notes.js.es6 @@ -1,59 +1,74 @@ -import { default as computed, on } from 'ember-addons/ember-computed-decorators'; -import { popupAjaxError } from 'discourse/lib/ajax-error'; +import { + default as computed, + on +} from "ember-addons/ember-computed-decorators"; +import { popupAjaxError } from "discourse/lib/ajax-error"; export default Ember.Controller.extend({ newNote: null, saving: false, user: null, - @on('init') + @on("init") reset() { this.setProperties({ newNote: null, saving: false, callback: null }); }, - @computed('newNote', 'saving') + @computed("newNote", "saving") attachDisabled(newNote, saving) { - return saving || !newNote || (newNote.length === 0); + return saving || !newNote || newNote.length === 0; }, _refreshCount() { - const callback = this.get('callback'); + const callback = this.get("callback"); if (callback) { - callback(this.get('model.length')); + callback(this.get("model.length")); } }, actions: { attachNote() { - const note = this.store.createRecord('staff-note'); - const userId = parseInt(this.get('userId')); + const note = this.store.createRecord("staff-note"); + const userId = parseInt(this.get("userId")); - this.set('saving', true); + this.set("saving", true); let args = { - raw: this.get('newNote'), + raw: this.get("newNote"), user_id: userId }; - let postId = this.get('postId'); + let postId = this.get("postId"); if (postId) { args.post_id = parseInt(postId); } - note.save(args).then(() => { - this.set('newNote', ''); - this.get('model').pushObject(note); - this._refreshCount(); - }).catch(popupAjaxError).finally(() => this.set('saving', false)); + note + .save(args) + .then(() => { + this.set("newNote", ""); + this.get("model").pushObject(note); + this._refreshCount(); + }) + .catch(popupAjaxError) + .finally(() => this.set("saving", false)); }, removeNote(note) { - bootbox.confirm(I18n.t("staff_notes.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), result => { - if (result) { - note.destroyRecord().then(() => { - const notes = this.get('model'); - notes.removeObject(note); - this._refreshCount(); - }).catch(popupAjaxError); + bootbox.confirm( + I18n.t("staff_notes.delete_confirm"), + I18n.t("no_value"), + I18n.t("yes_value"), + result => { + if (result) { + note + .destroyRecord() + .then(() => { + const notes = this.get("model"); + notes.removeObject(note); + this._refreshCount(); + }) + .catch(popupAjaxError); + } } - }); + ); } } });