diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index cf70af993..2a7676be9 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -32,6 +32,7 @@ var initialize_modules = function() { App.Stats.initialize(); App.Dropdown.initialize(); App.LocationChanger.initialize(); + App.CheckAllNone.initialize(); }; $(function(){ diff --git a/app/assets/javascripts/check_all_none.js.coffee b/app/assets/javascripts/check_all_none.js.coffee new file mode 100644 index 000000000..f49801a73 --- /dev/null +++ b/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) + + + diff --git a/app/views/moderation/bulk/index.html.erb b/app/views/moderation/bulk/index.html.erb index 77d283b80..c3bb68777 100644 --- a/app/views/moderation/bulk/index.html.erb +++ b/app/views/moderation/bulk/index.html.erb @@ -3,6 +3,13 @@
+ <%= 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[]"} %> +
+| diff --git a/config/locales/moderation.en.yml b/config/locales/moderation.en.yml index 0503a9981..30e35ed88 100644 --- a/config/locales/moderation.en.yml +++ b/config/locales/moderation.en.yml @@ -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: diff --git a/config/locales/moderation.es.yml b/config/locales/moderation.es.yml index 549a724b1..4fb81845a 100644 --- a/config/locales/moderation.es.yml +++ b/config/locales/moderation.es.yml @@ -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: diff --git a/spec/features/moderation/bulk_spec.rb b/spec/features/moderation/bulk_spec.rb index e1869da90..5d6163f7b 100644 --- a/spec/features/moderation/bulk_spec.rb +++ b/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 @@ -32,4 +33,20 @@ feature 'Moderate in bulk' do 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 |
|---|