2015-11-20 08:14:50 -05:00
|
|
|
import FlaggedPost from 'admin/models/flagged-post';
|
|
|
|
|
2014-07-22 23:20:45 -04:00
|
|
|
export default Ember.ArrayController.extend({
|
2014-11-11 15:48:13 -05:00
|
|
|
query: null,
|
2013-03-14 18:03:13 -04:00
|
|
|
|
2014-08-04 16:48:04 -04:00
|
|
|
adminOldFlagsView: Em.computed.equal("query", "old"),
|
|
|
|
adminActiveFlagsView: Em.computed.equal("query", "active"),
|
2014-07-28 13:17:37 -04:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
actions: {
|
2015-02-18 14:21:36 -05:00
|
|
|
disagreeFlags(flaggedPost) {
|
2014-07-28 13:17:37 -04:00
|
|
|
var self = this;
|
|
|
|
flaggedPost.disagreeFlags().then(function () {
|
|
|
|
self.removeObject(flaggedPost);
|
|
|
|
}, function () {
|
2013-09-16 14:08:55 -04:00
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
2013-06-20 03:42:15 -04:00
|
|
|
|
2015-02-18 14:21:36 -05:00
|
|
|
deferFlags(flaggedPost) {
|
2014-07-28 13:17:37 -04:00
|
|
|
var self = this;
|
|
|
|
flaggedPost.deferFlags().then(function () {
|
|
|
|
self.removeObject(flaggedPost);
|
|
|
|
}, function () {
|
2013-09-16 14:08:55 -04:00
|
|
|
bootbox.alert(I18n.t("admin.flags.error"));
|
|
|
|
});
|
|
|
|
},
|
2013-06-20 17:20:08 -04:00
|
|
|
|
2015-02-18 14:21:36 -05:00
|
|
|
doneTopicFlags(item) {
|
2014-08-04 16:48:04 -04:00
|
|
|
this.send("disagreeFlags", item);
|
2014-02-05 17:54:16 -05:00
|
|
|
},
|
2013-07-26 15:40:08 -04:00
|
|
|
},
|
|
|
|
|
2015-02-18 14:21:36 -05:00
|
|
|
loadMore(){
|
2014-08-04 16:48:04 -04:00
|
|
|
var flags = this.get("model");
|
2015-11-20 08:14:50 -05:00
|
|
|
return FlaggedPost.findAll(this.get("query"),flags.length+1).then(function(data){
|
2013-08-19 07:14:26 -04:00
|
|
|
if(data.length===0){
|
2014-08-04 16:48:04 -04:00
|
|
|
flags.set("allLoaded",true);
|
2013-08-19 07:14:26 -04:00
|
|
|
}
|
|
|
|
flags.addObjects(data);
|
|
|
|
});
|
|
|
|
}
|
2013-03-14 18:03:13 -04:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|