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
|
// Same as other connector
|
||||||
export default connector;
|
export default connector;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
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";
|
||||||
import { getOwner } from 'discourse-common/lib/get-owner';
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
shouldRender(args, component) {
|
shouldRender(args, component) {
|
||||||
|
@ -7,18 +7,20 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
setupComponent(args, component) {
|
setupComponent(args, component) {
|
||||||
let model = args.flaggedPost.get('user');
|
let model = args.flaggedPost.get("user");
|
||||||
component.set(
|
component.set(
|
||||||
'staffNotesCount',
|
"staffNotesCount",
|
||||||
model.get('custom_fields.staff_notes_count') || 0
|
model.get("custom_fields.staff_notes_count") || 0
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
showStaffNotes() {
|
showStaffNotes() {
|
||||||
const store = getOwner(this).lookup('store:main');
|
const store = getOwner(this).lookup("store:main");
|
||||||
const user = this.get('args.flaggedPost.user');
|
const user = this.get("args.flaggedPost.user");
|
||||||
showStaffNotes(store, user.get('id'), count => this.set('staffNotesCount', count));
|
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 { showStaffNotes } from "discourse/plugins/discourse-staff-notes/discourse-staff-notes/lib/staff-notes";
|
||||||
import { getOwner } from 'discourse-common/lib/get-owner';
|
import { getOwner } from "discourse-common/lib/get-owner";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
shouldRender(args, component) {
|
shouldRender(args, component) {
|
||||||
|
@ -10,16 +10,20 @@ export default {
|
||||||
setupComponent(args, component) {
|
setupComponent(args, component) {
|
||||||
const { model } = args;
|
const { model } = args;
|
||||||
component.set(
|
component.set(
|
||||||
'staffNotesCount',
|
"staffNotesCount",
|
||||||
model.get('staff_notes_count') || model.get('custom_fields.staff_notes_count') || 0
|
model.get("staff_notes_count") ||
|
||||||
|
model.get("custom_fields.staff_notes_count") ||
|
||||||
|
0
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
showStaffNotes() {
|
showStaffNotes() {
|
||||||
const store = getOwner(this).lookup('store:main');
|
const store = getOwner(this).lookup("store:main");
|
||||||
const user = this.get('args.model');
|
const user = this.get("args.model");
|
||||||
showStaffNotes(store, user.get('id'), count => this.set('staffNotesCount', count));
|
showStaffNotes(store, user.get("id"), count =>
|
||||||
|
this.set("staffNotesCount", count)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import showModal from 'discourse/lib/show-modal';
|
import showModal from "discourse/lib/show-modal";
|
||||||
import loadScript from 'discourse/lib/load-script';
|
import loadScript from "discourse/lib/load-script";
|
||||||
|
|
||||||
export function showStaffNotes(store, userId, callback, opts) {
|
export function showStaffNotes(store, userId, callback, opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
return loadScript('defer/html-sanitizer-bundle').then(() => {
|
return loadScript("defer/html-sanitizer-bundle").then(() => {
|
||||||
return store.find('staff-note', { user_id: userId }).then(model => {
|
return store.find("staff-note", { user_id: userId }).then(model => {
|
||||||
const controller = showModal('staff-notes', {
|
const controller = showModal("staff-notes", {
|
||||||
model,
|
model,
|
||||||
title: 'staff_notes.title',
|
title: "staff_notes.title",
|
||||||
addModalBodyView: true
|
addModalBodyView: true
|
||||||
});
|
});
|
||||||
controller.reset();
|
controller.reset();
|
||||||
controller.set('userId', userId);
|
controller.set("userId", userId);
|
||||||
controller.set('callback', callback);
|
controller.set("callback", callback);
|
||||||
controller.set('postId', opts.postId);
|
controller.set("postId", opts.postId);
|
||||||
return controller;
|
return controller;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import RestAdapter from 'discourse/adapters/rest';
|
import RestAdapter from "discourse/adapters/rest";
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
export default RestAdapter.extend({
|
export default RestAdapter.extend({
|
||||||
destroyRecord(store, type, record) {
|
destroyRecord(store, type, record) {
|
||||||
const path = this.pathFor(store, type, record.get('id'));
|
const path = this.pathFor(store, type, record.get("id"));
|
||||||
const userId = record.get('user_id');
|
const userId = record.get("user_id");
|
||||||
return ajax(`${path}?user_id=${userId}`, { method: 'DELETE' });
|
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({
|
export default Ember.Component.extend({
|
||||||
tagName: '',
|
tagName: "",
|
||||||
|
|
||||||
@computed('count')
|
@computed("count")
|
||||||
showCount: count => count && count > 0,
|
showCount: count => count && count > 0,
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
show() {
|
show() {
|
||||||
this.sendAction('show');
|
this.sendAction("show");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,59 +1,74 @@
|
||||||
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
|
import {
|
||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
default as computed,
|
||||||
|
on
|
||||||
|
} from "ember-addons/ember-computed-decorators";
|
||||||
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
newNote: null,
|
newNote: null,
|
||||||
saving: false,
|
saving: false,
|
||||||
user: null,
|
user: null,
|
||||||
|
|
||||||
@on('init')
|
@on("init")
|
||||||
reset() {
|
reset() {
|
||||||
this.setProperties({ newNote: null, saving: false, callback: null });
|
this.setProperties({ newNote: null, saving: false, callback: null });
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed('newNote', 'saving')
|
@computed("newNote", "saving")
|
||||||
attachDisabled(newNote, saving) {
|
attachDisabled(newNote, saving) {
|
||||||
return saving || !newNote || (newNote.length === 0);
|
return saving || !newNote || newNote.length === 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
_refreshCount() {
|
_refreshCount() {
|
||||||
const callback = this.get('callback');
|
const callback = this.get("callback");
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(this.get('model.length'));
|
callback(this.get("model.length"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
attachNote() {
|
attachNote() {
|
||||||
const note = this.store.createRecord('staff-note');
|
const note = this.store.createRecord("staff-note");
|
||||||
const userId = parseInt(this.get('userId'));
|
const userId = parseInt(this.get("userId"));
|
||||||
|
|
||||||
this.set('saving', true);
|
this.set("saving", true);
|
||||||
let args = {
|
let args = {
|
||||||
raw: this.get('newNote'),
|
raw: this.get("newNote"),
|
||||||
user_id: userId
|
user_id: userId
|
||||||
};
|
};
|
||||||
let postId = this.get('postId');
|
let postId = this.get("postId");
|
||||||
if (postId) {
|
if (postId) {
|
||||||
args.post_id = parseInt(postId);
|
args.post_id = parseInt(postId);
|
||||||
}
|
}
|
||||||
note.save(args).then(() => {
|
note
|
||||||
this.set('newNote', '');
|
.save(args)
|
||||||
this.get('model').pushObject(note);
|
.then(() => {
|
||||||
this._refreshCount();
|
this.set("newNote", "");
|
||||||
}).catch(popupAjaxError).finally(() => this.set('saving', false));
|
this.get("model").pushObject(note);
|
||||||
|
this._refreshCount();
|
||||||
|
})
|
||||||
|
.catch(popupAjaxError)
|
||||||
|
.finally(() => this.set("saving", false));
|
||||||
},
|
},
|
||||||
|
|
||||||
removeNote(note) {
|
removeNote(note) {
|
||||||
bootbox.confirm(I18n.t("staff_notes.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), result => {
|
bootbox.confirm(
|
||||||
if (result) {
|
I18n.t("staff_notes.delete_confirm"),
|
||||||
note.destroyRecord().then(() => {
|
I18n.t("no_value"),
|
||||||
const notes = this.get('model');
|
I18n.t("yes_value"),
|
||||||
notes.removeObject(note);
|
result => {
|
||||||
this._refreshCount();
|
if (result) {
|
||||||
}).catch(popupAjaxError);
|
note
|
||||||
|
.destroyRecord()
|
||||||
|
.then(() => {
|
||||||
|
const notes = this.get("model");
|
||||||
|
notes.removeObject(note);
|
||||||
|
this._refreshCount();
|
||||||
|
})
|
||||||
|
.catch(popupAjaxError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue