adds select all/none to bulk moderation

This commit is contained in:
kikito
2015-09-08 20:46:18 +02:00
parent b9ebe8c2c4
commit 48ba9a436d
6 changed files with 47 additions and 3 deletions

View File

@@ -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(){

View 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)

View File

@@ -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>

View File

@@ -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:

View File

@@ -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:

View File

@@ -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