adds select all/none to bulk moderation
This commit is contained in:
@@ -32,6 +32,7 @@ var initialize_modules = function() {
|
|||||||
App.Stats.initialize();
|
App.Stats.initialize();
|
||||||
App.Dropdown.initialize();
|
App.Dropdown.initialize();
|
||||||
App.LocationChanger.initialize();
|
App.LocationChanger.initialize();
|
||||||
|
App.CheckAllNone.initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
|
|||||||
13
app/assets/javascripts/check_all_none.js.coffee
Normal file
13
app/assets/javascripts/check_all_none.js.coffee
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
App.CheckAllNone =
|
||||||
|
|
||||||
|
initialize: ->
|
||||||
|
$('[data-check-all]').on 'click', ->
|
||||||
|
target_name = $(this).data('check-all')
|
||||||
|
$("[name='" + target_name + "']").prop('checked', true)
|
||||||
|
|
||||||
|
$('[data-check-none]').on 'click', ->
|
||||||
|
target_name = $(this).data('check-none')
|
||||||
|
$("[name='" + target_name + "']").prop('checked', false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -3,6 +3,13 @@
|
|||||||
<h3><%= page_entries_info @debates %></h3>
|
<h3><%= page_entries_info @debates %></h3>
|
||||||
|
|
||||||
<%= form_tag moderation_bulk_hide_path, method: :put do %>
|
<%= form_tag moderation_bulk_hide_path, method: :put do %>
|
||||||
|
<p class="right">
|
||||||
|
<%= t('moderation.bulk.index.check') %>:
|
||||||
|
<%= link_to t('moderation.bulk.index.check_all'), '#', data: {check_all: "debate_ids[]"} %>
|
||||||
|
|
|
||||||
|
<%= link_to t('moderation.bulk.index.check_none'), '#', data: {check_none: "debate_ids[]"} %>
|
||||||
|
</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ en:
|
|||||||
hide_debates: Hide debates
|
hide_debates: Hide debates
|
||||||
block_authors: Block authors
|
block_authors: Block authors
|
||||||
confirm: Are you sure?
|
confirm: Are you sure?
|
||||||
|
check: Select
|
||||||
|
check_all: All
|
||||||
|
check_none: None
|
||||||
users:
|
users:
|
||||||
notice_hide: User banned.
|
notice_hide: User banned.
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ es:
|
|||||||
hide_debates: Ocultar debates
|
hide_debates: Ocultar debates
|
||||||
block_authors: Bloquear usuarios
|
block_authors: Bloquear usuarios
|
||||||
confirm: ¿Estás seguro?
|
confirm: ¿Estás seguro?
|
||||||
|
check: Seleccionar
|
||||||
|
check_all: Todos
|
||||||
|
check_none: Ninguno
|
||||||
users:
|
users:
|
||||||
notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios.
|
notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios.
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Moderate in bulk' do
|
feature 'Moderate in bulk' do
|
||||||
|
background do
|
||||||
|
moderator = create(:moderator)
|
||||||
|
login_as(moderator.user)
|
||||||
|
end
|
||||||
|
|
||||||
feature "When a debate has been selected for moderation" do
|
feature "When a debate has been selected for moderation" do
|
||||||
background do
|
background do
|
||||||
moderator = create(:moderator)
|
|
||||||
@debate = create(:debate)
|
@debate = create(:debate)
|
||||||
|
|
||||||
login_as(moderator.user)
|
|
||||||
visit moderation_bulk_path
|
visit moderation_bulk_path
|
||||||
|
|
||||||
within("#debate_#{@debate.id}") do
|
within("#debate_#{@debate.id}") do
|
||||||
@@ -32,4 +33,20 @@ feature 'Moderate in bulk' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "select all/none", :js do
|
||||||
|
create_list(:debate, 20)
|
||||||
|
|
||||||
|
visit moderation_bulk_path
|
||||||
|
|
||||||
|
click_on 'All'
|
||||||
|
all('input[type=checkbox]').each do |checkbox|
|
||||||
|
expect(checkbox).to be_checked
|
||||||
|
end
|
||||||
|
|
||||||
|
click_on 'None'
|
||||||
|
all('input[type=checkbox]').each do |checkbox|
|
||||||
|
expect(checkbox).to_not be_checked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user