discourse/app/assets/javascripts/admin/components/flagged-post.js.es6

59 lines
1.3 KiB
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import showModal from "discourse/lib/show-modal";
import computed from "ember-addons/ember-computed-decorators";
2017-09-09 04:27:07 +08:00
export default Ember.Component.extend({
2017-09-15 02:10:39 +08:00
adminTools: Ember.inject.service(),
expanded: false,
2018-06-15 23:03:24 +08:00
tagName: "div",
2017-09-12 02:01:59 +08:00
classNameBindings: [
2018-06-15 23:03:24 +08:00
":flagged-post",
"flaggedPost.hidden:hidden-post",
"flaggedPost.deleted"
2017-09-12 02:01:59 +08:00
],
2017-09-09 04:27:07 +08:00
2018-06-15 23:03:24 +08:00
canAct: Ember.computed.alias("actableFilter"),
2018-01-13 05:08:40 +08:00
2018-06-15 23:03:24 +08:00
@computed("filter")
2018-01-13 05:08:40 +08:00
actableFilter(filter) {
2018-06-15 23:03:24 +08:00
return filter === "active";
2017-09-15 02:10:39 +08:00
},
2017-09-09 04:27:07 +08:00
removeAfter(promise) {
return promise.then(() => this.attrs.removePost());
2017-09-09 04:27:07 +08:00
},
_spawnModal(name, model, modalClass) {
let controller = showModal(name, { model, admin: true, modalClass });
2018-06-15 23:03:24 +08:00
controller.removeAfter = p => this.removeAfter(p);
2017-09-09 04:27:07 +08:00
},
actions: {
2017-11-11 04:55:48 +08:00
removeAfter(promise) {
return this.removeAfter(promise);
},
2017-09-09 04:27:07 +08:00
disagree() {
2018-06-15 23:03:24 +08:00
this.removeAfter(this.get("flaggedPost").disagreeFlags());
2017-09-09 04:27:07 +08:00
},
defer() {
2018-06-15 23:03:24 +08:00
this.removeAfter(this.get("flaggedPost").deferFlags());
},
expand() {
2018-06-15 23:03:24 +08:00
this.get("flaggedPost")
.expandHidden()
.then(() => {
this.set("expanded", true);
});
2017-09-15 02:10:39 +08:00
},
showModerationHistory() {
2018-06-15 23:03:24 +08:00
this.get("adminTools").showModerationHistory({
filter: "post",
post_id: this.get("flaggedPost.id")
});
2017-09-09 04:27:07 +08:00
}
}
});