Skip to content

Commit

Permalink
adds select all/none to bulk moderation
Browse files Browse the repository at this point in the history
  • Loading branch information
kikito committed Sep 8, 2015
1 parent b9ebe8c commit 48ba9a4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -32,6 +32,7 @@ var initialize_modules = function() {
App.Stats.initialize();
App.Dropdown.initialize();
App.LocationChanger.initialize();
App.CheckAllNone.initialize();
};

$(function(){
Expand Down
13 changes: 13 additions & 0 deletions app/assets/javascripts/check_all_none.js.coffee
@@ -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)



7 changes: 7 additions & 0 deletions app/views/moderation/bulk/index.html.erb
Expand Up @@ -3,6 +3,13 @@
<h3><%= page_entries_info @debates %></h3>

<%= 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>
<tr>
<th>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/moderation.en.yml
Expand Up @@ -52,6 +52,9 @@ en:
hide_debates: Hide debates
block_authors: Block authors
confirm: Are you sure?
check: Select
check_all: All
check_none: None
users:
notice_hide: User banned.
index:
Expand Down
3 changes: 3 additions & 0 deletions config/locales/moderation.es.yml
Expand Up @@ -52,6 +52,9 @@ es:
hide_debates: Ocultar debates
block_authors: Bloquear usuarios
confirm: ¿Estás seguro?
check: Seleccionar
check_all: Todos
check_none: Ninguno
users:
notice_hide: Usuario bloqueado. Se han ocultado todos sus debates y comentarios.
index:
Expand Down
23 changes: 20 additions & 3 deletions spec/features/moderation/bulk_spec.rb
@@ -1,13 +1,14 @@
require 'rails_helper'

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
background do
moderator = create(:moderator)
@debate = create(:debate)

login_as(moderator.user)
visit moderation_bulk_path

within("#debate_#{@debate.id}") do
Expand All @@ -32,4 +33,20 @@
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

0 comments on commit 48ba9a4

Please sign in to comment.