mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FEATURE: agree all the flags
This commit is contained in:
parent
17debbdcda
commit
ec30086dea
12 changed files with 122 additions and 42 deletions
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
The modal for agreeing with a flag.
|
||||
|
||||
@class AdminAgreeFlagController
|
||||
@extends Discourse.Controller
|
||||
@namespace Discourse
|
||||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
|
||||
needs: ["adminFlags"],
|
||||
|
||||
actions: {
|
||||
|
||||
agreeFlagHidePost: function () {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
return post.agreeFlags("hide").then(function () {
|
||||
adminFlagController.removeObject(post);
|
||||
self.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
},
|
||||
|
||||
agreeFlagKeepPost: function () {
|
||||
var adminFlagController = this.get("controllers.adminFlags");
|
||||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
return post.agreeFlags("keep").then(function () {
|
||||
adminFlagController.removeObject(post);
|
||||
self.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
|
@ -7,7 +7,7 @@
|
|||
@uses Discourse.ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminDeleteFlagController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||
|
||||
needs: ["adminFlags"],
|
||||
|
||||
|
@ -31,22 +31,14 @@ Discourse.AdminDeleteFlagController = Discourse.ObjectController.extend(Discours
|
|||
var post = this.get("content");
|
||||
var self = this;
|
||||
|
||||
return post.agreeFlags(true).then(function () {
|
||||
return post.agreeFlags("delete").then(function () {
|
||||
adminFlagController.removeObject(post);
|
||||
self.send("closeModal");
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
Deletes a user and all posts and topics created by that user.
|
||||
|
||||
@method deleteSpammer
|
||||
**/
|
||||
deleteSpammer: function () {
|
||||
this.get("content.user").deleteAsSpammer(function() { window.location.reload(); });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
|
@ -8,20 +8,11 @@
|
|||
**/
|
||||
export default Ember.ArrayController.extend({
|
||||
|
||||
adminOldFlagsView: Em.computed.equal('query', 'old'),
|
||||
adminActiveFlagsView: Em.computed.equal('query', 'active'),
|
||||
adminOldFlagsView: Em.computed.equal("query", "old"),
|
||||
adminActiveFlagsView: Em.computed.equal("query", "active"),
|
||||
|
||||
actions: {
|
||||
|
||||
agreeFlags: function (flaggedPost) {
|
||||
var self = this;
|
||||
flaggedPost.agreeFlags().then(function () {
|
||||
self.removeObject(flaggedPost);
|
||||
}, function () {
|
||||
bootbox.alert(I18n.t("admin.flags.error"));
|
||||
});
|
||||
},
|
||||
|
||||
disagreeFlags: function (flaggedPost) {
|
||||
var self = this;
|
||||
flaggedPost.disagreeFlags().then(function () {
|
||||
|
@ -41,15 +32,15 @@ export default Ember.ArrayController.extend({
|
|||
},
|
||||
|
||||
doneTopicFlags: function(item) {
|
||||
this.send('disagreeFlags', item);
|
||||
this.send("disagreeFlags", item);
|
||||
},
|
||||
},
|
||||
|
||||
loadMore: function(){
|
||||
var flags = this.get('model');
|
||||
return Discourse.FlaggedPost.findAll(this.get('query'),flags.length+1).then(function(data){
|
||||
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.set("allLoaded",true);
|
||||
}
|
||||
flags.addObjects(data);
|
||||
});
|
||||
|
|
|
@ -104,8 +104,8 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
|||
return Discourse.ajax('/admin/flags/defer/' + this.id, { type: 'POST', cache: false, data: { delete_post: deletePost } });
|
||||
},
|
||||
|
||||
agreeFlags: function (deletePost) {
|
||||
return Discourse.ajax('/admin/flags/agree/' + this.id, { type: 'POST', cache: false, data: { delete_post: deletePost } });
|
||||
agreeFlags: function (actionOnPost) {
|
||||
return Discourse.ajax('/admin/flags/agree/' + this.id, { type: 'POST', cache: false, data: { action_on_post: actionOnPost } });
|
||||
},
|
||||
|
||||
postHidden: Em.computed.alias('hidden'),
|
||||
|
|
|
@ -13,6 +13,17 @@ Discourse.AdminFlagsRouteType = Discourse.Route.extend({
|
|||
var adminFlagsController = this.controllerFor('adminFlags');
|
||||
adminFlagsController.set('content', model);
|
||||
adminFlagsController.set('query', this.get('filter'));
|
||||
},
|
||||
|
||||
actions: {
|
||||
/**
|
||||
Deletes a user and all posts and topics created by that user.
|
||||
|
||||
@method deleteSpammer
|
||||
**/
|
||||
deleteSpammer: function (user) {
|
||||
user.deleteAsSpammer(function() { window.location.reload(); });
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -22,7 +33,12 @@ Discourse.AdminFlagsActiveRoute = Discourse.AdminFlagsRouteType.extend({
|
|||
|
||||
actions: {
|
||||
|
||||
showDeleteFlagModal: function(flaggedPost) {
|
||||
showAgreeFlagModal: function (flaggedPost) {
|
||||
Discourse.Route.showModal(this, 'admin_agree_flag', flaggedPost);
|
||||
this.controllerFor('modal').set('modalClass', 'agree-flag-modal');
|
||||
},
|
||||
|
||||
showDeleteFlagModal: function (flaggedPost) {
|
||||
Discourse.Route.showModal(this, 'admin_delete_flag', flaggedPost);
|
||||
this.controllerFor('modal').set('modalClass', 'delete-flag-modal');
|
||||
}
|
||||
|
|
|
@ -135,14 +135,14 @@
|
|||
<tr>
|
||||
<td colspan="4" class="action">
|
||||
{{#if adminActiveFlagsView}}
|
||||
<button title='{{i18n admin.flags.agree_title}}' class='btn' {{action showAgreeFlagModal flaggedPost}}><i class="fa fa-thumbs-o-up"></i>{{i18n admin.flags.agree}}</button>
|
||||
{{#if flaggedPost.postHidden}}
|
||||
<button title='{{i18n admin.flags.disagree_flag_unhide_post_title}}' class='btn' {{action disagreeFlags flaggedPost}}><i class="fa fa-thumbs-o-down"></i> {{i18n admin.flags.disagree_flag_unhide_post}}</button>
|
||||
<button title='{{i18n admin.flags.disagree_flag_unhide_post_title}}' class='btn' {{action disagreeFlags flaggedPost}}><i class="fa fa-thumbs-o-down"></i>{{i18n admin.flags.disagree_flag_unhide_post}}</button>
|
||||
{{else}}
|
||||
<button title='{{i18n admin.flags.agree_flag_hide_post_title}}' class='btn' {{action agreeFlags flaggedPost}}><i class="fa fa-thumbs-o-up"></i> {{i18n admin.flags.agree_flag_hide_post}}</button>
|
||||
<button title='{{i18n admin.flags.disagree_flag_title}}' class='btn' {{action disagreeFlags flaggedPost}}><i class="fa fa-thumbs-o-down"></i> {{i18n admin.flags.disagree_flag}}</button>
|
||||
<button title='{{i18n admin.flags.disagree_flag_title}}' class='btn' {{action disagreeFlags flaggedPost}}><i class="fa fa-thumbs-o-down"></i>{{i18n admin.flags.disagree_flag}}</button>
|
||||
{{/if}}
|
||||
<button title='{{i18n admin.flags.defer_flag_title}}' class='btn' {{action deferFlags flaggedPost}}><i class="fa fa-external-link"></i> {{i18n admin.flags.defer_flag}}</button>
|
||||
<button title='{{i18n admin.flags.delete_title}}' class='btn btn-danger' {{action showDeleteFlagModal flaggedPost}}><i class="fa fa-trash-o"></i> {{i18n admin.flags.delete}}</button>
|
||||
<button title='{{i18n admin.flags.defer_flag_title}}' class='btn' {{action deferFlags flaggedPost}}><i class="fa fa-external-link"></i>{{i18n admin.flags.defer_flag}}</button>
|
||||
<button title='{{i18n admin.flags.delete_title}}' class='btn btn-danger' {{action showDeleteFlagModal flaggedPost}}><i class="fa fa-trash-o"></i>{{i18n admin.flags.delete}}</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{{#unless postHidden}}
|
||||
<button title="{{i18n admin.flags.agree_flag_hide_post_title}}" {{action agreeFlagHidePost}} class="btn"><i class="fa fa-thumbs-o-up"></i><i class="fa fa-external-link"></i>{{i18n admin.flags.agree_flag_hide_post}}</button>
|
||||
{{/unless}}
|
||||
<button title="{{i18n admin.flags.agree_flag_title}}" {{action agreeFlagKeepPost}} class="btn"><i class="fa fa-thumbs-o-up"></i>{{i18n admin.flags.agree_flag}}</button>
|
||||
{{#if canDeleteAsSpammer}}
|
||||
<button title="{{i18n admin.flags.delete_spammer_title}}" {{action deleteSpammer user}} class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i>{{i18n admin.flags.delete_spammer}}</button>
|
||||
{{/if}}
|
|
@ -1,5 +1,5 @@
|
|||
<button title="{{i18n admin.flags.delete_post_defer_flag_title}}" {{action deletePostDeferFlag}} class="btn"><i class="fa fa-trash-o"></i><i class="fa fa-external-link"></i>{{i18n admin.flags.delete_post_defer_flag}}</button>
|
||||
<button title="{{i18n admin.flags.delete_post_agree_flag_title}}" {{action deletePostAgreeFlag}} class="btn"><i class="fa fa-trash-o"></i><i class="fa fa-thumbs-o-up"></i>{{i18n admin.flags.delete_post_agree_flag}}</button>
|
||||
{{#if canDeleteAsSpammer}}
|
||||
<button title="{{i18n admin.flags.delete_spammer_title}}" {{action deleteSpammer}} class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i> {{i18n admin.flags.delete_spammer}}</button>
|
||||
<button title="{{i18n admin.flags.delete_spammer_title}}" {{action deleteSpammer user}} class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i>{{i18n admin.flags.delete_spammer}}</button>
|
||||
{{/if}}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
A modal view for agreeing with a flag.
|
||||
|
||||
@class AdminAgreeFlagView
|
||||
@extends Discourse.ModalBodyView
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminAgreeFlagView = Discourse.ModalBodyView.extend({
|
||||
templateName: 'admin/templates/modal/admin_agree_flag',
|
||||
title: I18n.t('admin.flags.agree_flag_modal_title')
|
||||
});
|
|
@ -1144,7 +1144,7 @@ button.ru {
|
|||
visibility: hidden;
|
||||
}
|
||||
|
||||
.delete-flag-modal {
|
||||
.delete-flag-modal, .agree-flag-modal {
|
||||
.modal-inner-container {
|
||||
width: 400px;
|
||||
}
|
||||
|
|
|
@ -19,32 +19,45 @@ class Admin::FlagsController < Admin::AdminController
|
|||
end
|
||||
|
||||
def agree
|
||||
params.permit(:id, :delete_post)
|
||||
params.permit(:id, :action_on_post)
|
||||
|
||||
post = Post.find(params[:id])
|
||||
post_action_type = PostAction.post_action_type_for_post(post.id)
|
||||
PostAction.agree_flags!(post, current_user, params[:delete_post])
|
||||
if params[:delete_post]
|
||||
|
||||
keep_post = params[:action_on_post] == "keep"
|
||||
delete_post = params[:action_on_post] == "delete"
|
||||
|
||||
PostAction.agree_flags!(post, current_user, delete_post)
|
||||
|
||||
if delete_post
|
||||
PostDestroyer.new(current_user, post).destroy
|
||||
else
|
||||
elsif !keep_post
|
||||
PostAction.hide_post!(post, post_action_type)
|
||||
end
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def disagree
|
||||
params.permit(:id)
|
||||
post = Post.find(params[:id])
|
||||
|
||||
PostAction.clear_flags!(post, current_user)
|
||||
|
||||
post.reload
|
||||
post.unhide!
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def defer
|
||||
params.permit(:id, :delete_post)
|
||||
post = Post.find(params[:id])
|
||||
|
||||
PostAction.defer_flags!(post, current_user, params[:delete_post])
|
||||
|
||||
PostDestroyer.new(current_user, post).destroy if params[:delete_post]
|
||||
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
|
|
|
@ -1415,15 +1415,20 @@ en:
|
|||
old: "Old"
|
||||
active: "Active"
|
||||
|
||||
agree: "Agree"
|
||||
agree_title: "Agree"
|
||||
agree_flag_modal_title: "Agree and..."
|
||||
agree_flag_hide_post: "Agree (hide post + send PM)"
|
||||
agree_flag_hide_post_title: "Hide this post and automatically send the user a private message urging them to edit it"
|
||||
agree_flag: "Agree with flag"
|
||||
agree_flag_title: "Agree with flag and keep the post unchanged"
|
||||
defer_flag: "Defer"
|
||||
defer_flag_title: "No action is necessary at this time, defer any action on this flag until a later date, or never"
|
||||
delete: "Delete"
|
||||
delete_title: "Delete"
|
||||
delete_post_defer_flag: "Delete Post and Defer flag"
|
||||
delete_post_defer_flag: "Delete post and Defer flag"
|
||||
delete_post_defer_flag_title: "Delete post; if the first post, delete the topic"
|
||||
delete_post_agree_flag: "Delete Post and Agree with flag"
|
||||
delete_post_agree_flag: "Delete post and Agree with flag"
|
||||
delete_post_agree_flag_title: "Delete post; if the first post, delete the topic"
|
||||
delete_flag_modal_title: "Delete and..."
|
||||
delete_spammer: "Delete Spammer"
|
||||
|
|
Loading…
Reference in a new issue