mirror of
https://github.com/discourse/discourse.git
synced 2025-01-20 03:52:48 +08:00
FEATURE: agree all the flags
This commit is contained in:
parent
17debbdcda
commit
ec30086dea
|
@ -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
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminDeleteFlagController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||||
|
|
||||||
needs: ["adminFlags"],
|
needs: ["adminFlags"],
|
||||||
|
|
||||||
|
@ -31,22 +31,14 @@ Discourse.AdminDeleteFlagController = Discourse.ObjectController.extend(Discours
|
||||||
var post = this.get("content");
|
var post = this.get("content");
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
return post.agreeFlags(true).then(function () {
|
return post.agreeFlags("delete").then(function () {
|
||||||
adminFlagController.removeObject(post);
|
adminFlagController.removeObject(post);
|
||||||
self.send("closeModal");
|
self.send("closeModal");
|
||||||
}, function () {
|
}, function () {
|
||||||
bootbox.alert(I18n.t("admin.flags.error"));
|
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({
|
export default Ember.ArrayController.extend({
|
||||||
|
|
||||||
adminOldFlagsView: Em.computed.equal('query', 'old'),
|
adminOldFlagsView: Em.computed.equal("query", "old"),
|
||||||
adminActiveFlagsView: Em.computed.equal('query', 'active'),
|
adminActiveFlagsView: Em.computed.equal("query", "active"),
|
||||||
|
|
||||||
actions: {
|
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) {
|
disagreeFlags: function (flaggedPost) {
|
||||||
var self = this;
|
var self = this;
|
||||||
flaggedPost.disagreeFlags().then(function () {
|
flaggedPost.disagreeFlags().then(function () {
|
||||||
|
@ -41,15 +32,15 @@ export default Ember.ArrayController.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
doneTopicFlags: function(item) {
|
doneTopicFlags: function(item) {
|
||||||
this.send('disagreeFlags', item);
|
this.send("disagreeFlags", item);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
loadMore: function(){
|
loadMore: function(){
|
||||||
var flags = this.get('model');
|
var flags = this.get("model");
|
||||||
return Discourse.FlaggedPost.findAll(this.get('query'),flags.length+1).then(function(data){
|
return Discourse.FlaggedPost.findAll(this.get("query"),flags.length+1).then(function(data){
|
||||||
if(data.length===0){
|
if(data.length===0){
|
||||||
flags.set('allLoaded',true);
|
flags.set("allLoaded",true);
|
||||||
}
|
}
|
||||||
flags.addObjects(data);
|
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 } });
|
return Discourse.ajax('/admin/flags/defer/' + this.id, { type: 'POST', cache: false, data: { delete_post: deletePost } });
|
||||||
},
|
},
|
||||||
|
|
||||||
agreeFlags: function (deletePost) {
|
agreeFlags: function (actionOnPost) {
|
||||||
return Discourse.ajax('/admin/flags/agree/' + this.id, { type: 'POST', cache: false, data: { delete_post: deletePost } });
|
return Discourse.ajax('/admin/flags/agree/' + this.id, { type: 'POST', cache: false, data: { action_on_post: actionOnPost } });
|
||||||
},
|
},
|
||||||
|
|
||||||
postHidden: Em.computed.alias('hidden'),
|
postHidden: Em.computed.alias('hidden'),
|
||||||
|
|
|
@ -13,6 +13,17 @@ Discourse.AdminFlagsRouteType = Discourse.Route.extend({
|
||||||
var adminFlagsController = this.controllerFor('adminFlags');
|
var adminFlagsController = this.controllerFor('adminFlags');
|
||||||
adminFlagsController.set('content', model);
|
adminFlagsController.set('content', model);
|
||||||
adminFlagsController.set('query', this.get('filter'));
|
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: {
|
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);
|
Discourse.Route.showModal(this, 'admin_delete_flag', flaggedPost);
|
||||||
this.controllerFor('modal').set('modalClass', 'delete-flag-modal');
|
this.controllerFor('modal').set('modalClass', 'delete-flag-modal');
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,14 +135,14 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" class="action">
|
<td colspan="4" class="action">
|
||||||
{{#if adminActiveFlagsView}}
|
{{#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}}
|
{{#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}}
|
{{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}}
|
{{/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.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.delete_title}}' class='btn btn-danger' {{action showDeleteFlagModal flaggedPost}}><i class="fa fa-trash-o"></i>{{i18n admin.flags.delete}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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_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>
|
<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}}
|
{{#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}}
|
{{/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;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.delete-flag-modal {
|
.delete-flag-modal, .agree-flag-modal {
|
||||||
.modal-inner-container {
|
.modal-inner-container {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,32 +19,45 @@ class Admin::FlagsController < Admin::AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def agree
|
def agree
|
||||||
params.permit(:id, :delete_post)
|
params.permit(:id, :action_on_post)
|
||||||
|
|
||||||
post = Post.find(params[:id])
|
post = Post.find(params[:id])
|
||||||
post_action_type = PostAction.post_action_type_for_post(post.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
|
PostDestroyer.new(current_user, post).destroy
|
||||||
else
|
elsif !keep_post
|
||||||
PostAction.hide_post!(post, post_action_type)
|
PostAction.hide_post!(post, post_action_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
def disagree
|
def disagree
|
||||||
params.permit(:id)
|
params.permit(:id)
|
||||||
post = Post.find(params[:id])
|
post = Post.find(params[:id])
|
||||||
|
|
||||||
PostAction.clear_flags!(post, current_user)
|
PostAction.clear_flags!(post, current_user)
|
||||||
|
|
||||||
post.reload
|
post.reload
|
||||||
post.unhide!
|
post.unhide!
|
||||||
|
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
def defer
|
def defer
|
||||||
params.permit(:id, :delete_post)
|
params.permit(:id, :delete_post)
|
||||||
post = Post.find(params[:id])
|
post = Post.find(params[:id])
|
||||||
|
|
||||||
PostAction.defer_flags!(post, current_user, params[:delete_post])
|
PostAction.defer_flags!(post, current_user, params[:delete_post])
|
||||||
|
|
||||||
PostDestroyer.new(current_user, post).destroy if params[:delete_post]
|
PostDestroyer.new(current_user, post).destroy if params[:delete_post]
|
||||||
|
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1415,15 +1415,20 @@ en:
|
||||||
old: "Old"
|
old: "Old"
|
||||||
active: "Active"
|
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: "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_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: "Defer"
|
||||||
defer_flag_title: "No action is necessary at this time, defer any action on this flag until a later date, or never"
|
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: "Delete"
|
||||||
delete_title: "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_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_post_agree_flag_title: "Delete post; if the first post, delete the topic"
|
||||||
delete_flag_modal_title: "Delete and..."
|
delete_flag_modal_title: "Delete and..."
|
||||||
delete_spammer: "Delete Spammer"
|
delete_spammer: "Delete Spammer"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user