2017-09-08 16:27:07 -04:00
|
|
|
import showModal from 'discourse/lib/show-modal';
|
2017-09-14 14:10:39 -04:00
|
|
|
import computed from 'ember-addons/ember-computed-decorators';
|
2017-09-08 16:27:07 -04:00
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
2017-09-14 14:10:39 -04:00
|
|
|
adminTools: Ember.inject.service(),
|
2017-09-14 12:44:49 -04:00
|
|
|
expanded: false,
|
2017-09-14 14:10:39 -04:00
|
|
|
suspended: false,
|
2017-09-14 12:44:49 -04:00
|
|
|
|
2017-09-11 14:01:59 -04:00
|
|
|
tagName: 'div',
|
|
|
|
classNameBindings: [
|
|
|
|
':flagged-post',
|
|
|
|
'flaggedPost.hidden:hidden-post',
|
|
|
|
'flaggedPost.deleted'
|
|
|
|
],
|
2017-09-08 16:27:07 -04:00
|
|
|
|
2017-09-14 14:10:39 -04:00
|
|
|
@computed('filter')
|
|
|
|
canAct(filter) {
|
|
|
|
return filter === 'active';
|
|
|
|
},
|
|
|
|
|
2017-09-08 16:27:07 -04:00
|
|
|
removeAfter(promise) {
|
|
|
|
return promise.then(() => {
|
|
|
|
this.attrs.removePost();
|
|
|
|
}).catch(() => {
|
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_spawnModal(name, model, modalClass) {
|
|
|
|
let controller = showModal(name, { model, admin: true, modalClass });
|
|
|
|
controller.removeAfter = (p) => this.removeAfter(p);
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
showAgreeFlagModal() {
|
|
|
|
this._spawnModal('admin-agree-flag', this.get('flaggedPost'), 'agree-flag-modal');
|
|
|
|
},
|
|
|
|
|
|
|
|
showDeleteFlagModal() {
|
|
|
|
this._spawnModal('admin-delete-flag', this.get('flaggedPost'), 'delete-flag-modal');
|
|
|
|
},
|
|
|
|
|
|
|
|
disagree() {
|
|
|
|
this.removeAfter(this.get('flaggedPost').disagreeFlags());
|
|
|
|
},
|
|
|
|
|
|
|
|
defer() {
|
|
|
|
this.removeAfter(this.get('flaggedPost').deferFlags());
|
2017-09-14 12:44:49 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
expand() {
|
|
|
|
this.get('flaggedPost').expandHidden().then(() => {
|
|
|
|
this.set('expanded', true);
|
|
|
|
});
|
2017-09-14 14:10:39 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
showSuspendModal() {
|
|
|
|
let post = this.get('flaggedPost');
|
|
|
|
let user = post.get('user');
|
|
|
|
this.get('adminTools').showSuspendModal(
|
|
|
|
user,
|
|
|
|
{
|
|
|
|
post,
|
|
|
|
successCallback: result => this.set('suspended', result.suspended)
|
|
|
|
}
|
|
|
|
);
|
2017-09-08 16:27:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|