discourse/app/assets/javascripts/admin/controllers/admin-flags-list.js.es6
2015-02-18 14:23:14 -05:00

42 lines
1016 B
JavaScript

export default Ember.ArrayController.extend({
query: null,
adminOldFlagsView: Em.computed.equal("query", "old"),
adminActiveFlagsView: Em.computed.equal("query", "active"),
actions: {
disagreeFlags(flaggedPost) {
var self = this;
flaggedPost.disagreeFlags().then(function () {
self.removeObject(flaggedPost);
}, function () {
bootbox.alert(I18n.t("admin.flags.error"));
});
},
deferFlags(flaggedPost) {
var self = this;
flaggedPost.deferFlags().then(function () {
self.removeObject(flaggedPost);
}, function () {
bootbox.alert(I18n.t("admin.flags.error"));
});
},
doneTopicFlags(item) {
this.send("disagreeFlags", item);
},
},
loadMore(){
var flags = this.get("model");
return Discourse.FlaggedPost.findAll(this.get("query"),flags.length+1).then(function(data){
if(data.length===0){
flags.set("allLoaded",true);
}
flags.addObjects(data);
});
}
});