diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..a529980
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,112 @@
+AllCops:
+ TargetRubyVersion: 2.4
+ DisabledByDefault: true
+ Exclude:
+ - 'db/schema.rb'
+ - 'bundle/**/*'
+ - 'vendor/**/*'
+ - 'node_modules/**/*'
+
+# Prefer &&/|| over and/or.
+Style/AndOr:
+ Enabled: true
+
+# Do not use braces for hash literals when they are the last argument of a
+# method call.
+Style/BracesAroundHashParameters:
+ Enabled: true
+
+# Align `when` with `case`.
+Layout/CaseIndentation:
+ Enabled: true
+
+# Align comments with method definitions.
+Layout/CommentIndentation:
+ Enabled: true
+
+# No extra empty lines.
+Layout/EmptyLines:
+ Enabled: true
+
+# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
+Style/HashSyntax:
+ Enabled: true
+
+# Two spaces, no tabs (for indentation).
+Layout/IndentationWidth:
+ Enabled: true
+
+Layout/SpaceAfterColon:
+ Enabled: true
+
+Layout/SpaceAfterComma:
+ Enabled: true
+
+Layout/SpaceAroundEqualsInParameterDefault:
+ Enabled: true
+
+Layout/SpaceAroundKeyword:
+ Enabled: true
+
+Layout/SpaceAroundOperators:
+ Enabled: true
+
+Layout/SpaceBeforeFirstArg:
+ Enabled: true
+
+# Defining a method with parameters needs parentheses.
+Style/MethodDefParentheses:
+ Enabled: true
+
+# Use `foo {}` not `foo{}`.
+Layout/SpaceBeforeBlockBraces:
+ Enabled: true
+
+# Use `foo { bar }` not `foo {bar}`.
+Layout/SpaceInsideBlockBraces:
+ Enabled: true
+
+# Use `{ a: 1 }` not `{a:1}`.
+Layout/SpaceInsideHashLiteralBraces:
+ Enabled: true
+
+Layout/SpaceInsideParens:
+ Enabled: true
+
+# Detect hard tabs, no hard tabs.
+Layout/Tab:
+ Enabled: true
+
+# Blank lines should not have any spaces.
+Layout/TrailingBlankLines:
+ Enabled: true
+
+# No trailing whitespace.
+Layout/TrailingWhitespace:
+ Enabled: true
+
+Lint/Debugger:
+ Enabled: true
+
+Lint/BlockAlignment:
+ Enabled: true
+
+# Align `end` with the matching keyword or starting expression except for
+# assignments, where it should be aligned with the LHS.
+Lint/EndAlignment:
+ Enabled: true
+ EnforcedStyleAlignWith: variable
+
+# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
+Lint/RequireParentheses:
+ Enabled: true
+
+Layout/MultilineMethodCallIndentation:
+ Enabled: true
+ EnforcedStyle: indented
+
+Layout/AlignHash:
+ Enabled: true
+
+Bundler/OrderedGems:
+ Enabled: false
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 5b684ac..1413ac6 100644
--- a/assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6
+++ b/assets/javascripts/discourse-staff-notes/lib/staff-notes.js.es6
@@ -1,7 +1,9 @@
import showModal from 'discourse/lib/show-modal';
import loadScript from 'discourse/lib/load-script';
-export function showStaffNotes(store, userId, callback) {
+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', {
@@ -12,6 +14,7 @@ export function showStaffNotes(store, userId, callback) {
controller.reset();
controller.set('userId', userId);
controller.set('callback', callback);
+ controller.set('postId', opts.postId);
return controller;
});
});
diff --git a/assets/javascripts/discourse/controllers/staff-notes.js.es6 b/assets/javascripts/discourse/controllers/staff-notes.js.es6
index 2736d71..4f25376 100644
--- a/assets/javascripts/discourse/controllers/staff-notes.js.es6
+++ b/assets/javascripts/discourse/controllers/staff-notes.js.es6
@@ -29,7 +29,15 @@ export default Ember.Controller.extend({
const userId = parseInt(this.get('userId'));
this.set('saving', true);
- note.save({ raw: this.get('newNote'), user_id: userId }).then(() => {
+ let args = {
+ raw: this.get('newNote'),
+ user_id: userId
+ };
+ 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();
@@ -37,7 +45,6 @@ export default Ember.Controller.extend({
},
removeNote(note) {
-
bootbox.confirm(I18n.t("staff_notes.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), result => {
if (result) {
note.destroyRecord().then(() => {
diff --git a/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6 b/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6
index e6fe494..036883d 100644
--- a/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6
+++ b/assets/javascripts/discourse/initializers/enable-staff-notes.js.es6
@@ -1,5 +1,5 @@
import { withPluginApi } from 'discourse/lib/plugin-api';
-import { iconNode } from 'discourse/helpers/fa-icon-node';
+import { iconNode } from 'discourse-common/lib/icon-library';
import { showStaffNotes } from 'discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes';
export default {
@@ -10,10 +10,12 @@ export default {
if (!siteSettings.staff_notes_enabled || !currentUser || !currentUser.staff) { return; }
const store = container.lookup('store:main');
- withPluginApi('0.2', api => {
+ withPluginApi('0.8.15', api => {
function widgetShowStaffNotes() {
showStaffNotes(store, this.attrs.user_id, count => {
this.sendWidgetAction('refreshStaffNotes', count);
+ }, {
+ postId: this.attrs.id
});
}
@@ -23,8 +25,7 @@ export default {
this.model.set('user_custom_fields', cfs);
});
- const UserController = container.lookupFactory('controller:user');
- UserController.reopen({
+ api.modifyClass('controller:user', {
staffNotesCount: null,
_modelChanged: function() {
diff --git a/assets/javascripts/discourse/templates/components/show-staff-notes.hbs b/assets/javascripts/discourse/templates/components/show-staff-notes.hbs
index 11b7d71..d5bde2b 100644
--- a/assets/javascripts/discourse/templates/components/show-staff-notes.hbs
+++ b/assets/javascripts/discourse/templates/components/show-staff-notes.hbs
@@ -1,5 +1,5 @@
- {{fa-icon "pencil"}}
+ {{d-icon "pencil"}}
{{#if showCount}}
{{i18n 'staff_notes.show' count=count}}
{{else}}
diff --git a/assets/javascripts/discourse/templates/modal/staff-notes.hbs b/assets/javascripts/discourse/templates/modal/staff-notes.hbs
index 369a780..6f3eafc 100644
--- a/assets/javascripts/discourse/templates/modal/staff-notes.hbs
+++ b/assets/javascripts/discourse/templates/modal/staff-notes.hbs
@@ -13,11 +13,10 @@
{{#if n.can_delete}}
- {{d-button action="removeNote"
- actionParam=n
- icon="times"
- class="btn-small btn-danger"
- title="staff_notes.remove"}}
+ {{d-button action=(action "removeNote" n)
+ icon="times"
+ class="btn-small btn-danger"
+ title="staff_notes.remove"}}
{{/if}}
@@ -25,6 +24,12 @@