From efccbc05974d9f2bddbf8edc3c58efd347c78759 Mon Sep 17 00:00:00 2001 From: snpd Date: Tue, 19 Mar 2019 02:43:04 +0530 Subject: [PATCH] Added select-all button in splashpage form While creating a splashpage,admin may want to select all the options by checking all the boxes at once, or clear all the checked boxes at once. Closes https://github.com/openSUSE/osem/issues/2022 --- app/views/admin/splashpages/_form.html.haml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/views/admin/splashpages/_form.html.haml b/app/views/admin/splashpages/_form.html.haml index 1d15b38c..874d9b37 100644 --- a/app/views/admin/splashpages/_form.html.haml +++ b/app/views/admin/splashpages/_form.html.haml @@ -8,6 +8,13 @@ .col-md-12 = f.inputs name: 'Components' do %ul.fa-ul + %li + %th + %button.btn.btn-default#select-all{ type: "button" } + Select All + %th + %button.btn.btn-default#unselect-all{ type: "button" } + Unselect All %li = f.input :include_cfp, label: 'Display call for papers and call for tracks, while open', input_html: { checked: params[:action] == 'new' || @splashpage.try(:include_cfp) } %li @@ -45,3 +52,15 @@ .col-md-12 %p.text-right = f.submit 'Save Changes', class: 'btn btn-primary' + +:javascript + $(document).ready(function(){ + $('#select-all').click(function(event) { + var parent = $(this).parents('.inputs:last'); + parent.find('.input.checkbox input[type=checkbox]').prop('checked',true); + }); + $('#unselect-all').click(function(event) { + var parent = $(this).parents('.inputs:last'); + parent.find('.input.checkbox input[type=checkbox]').prop('checked',false); + }); + });