DEV: Apply prettier
This commit is contained in:
parent
f7fbdadf31
commit
89706d80e1
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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" });
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
note
|
||||
.save(args)
|
||||
.then(() => {
|
||||
this.set("newNote", "");
|
||||
this.get("model").pushObject(note);
|
||||
this._refreshCount();
|
||||
}).catch(popupAjaxError).finally(() => this.set('saving', false));
|
||||
})
|
||||
.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 => {
|
||||
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');
|
||||
note
|
||||
.destroyRecord()
|
||||
.then(() => {
|
||||
const notes = this.get("model");
|
||||
notes.removeObject(note);
|
||||
this._refreshCount();
|
||||
}).catch(popupAjaxError);
|
||||
})
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue