diff --git a/resources/www/report/js/report.js b/resources/www/report/js/report.js index 015dfb1ece..64b7bc3ea6 100644 --- a/resources/www/report/js/report.js +++ b/resources/www/report/js/report.js @@ -63,34 +63,17 @@ $(document).ready(function () { var $this = $(this), value = $this.attr('rel'), form = $this.closest('form'); - $(".form2 .collist", form).hide(); - $(".form2 .collist-" + value, form).show(); - - $(".form2 .collist", form).each(function(i, list) { - if ($(list).is(':visible') === true) { - $(list).find('input').prop('checked', true); - } - else { - $(list).find('input').prop('checked', false); - } - - }); + $(".collist", form).hide(); + $(".collist-" + value, form).show(); }); - $('.form2 .collist').each(function() { + $('.collist').each(function() { var $this = $(this), form = $this.closest('form'), i = $this.closest('form').find('.sbas_select').val() ; $this.hide(); $(".collist-" + i, form).show(); - - if ($this.hasClass('collist-1')) { - $this.find('input').prop('checked', true); - } - else { - $this.find('input').prop('checked', false); - } }); $('.form2').each(function() { @@ -109,15 +92,56 @@ function bindEvents() { * "Download" buttons **/ $('.formsubmiter').bind('click', function () { - var form = $($(this).attr('data-form_selector')); - var action = form.find("select.sbas_select"); + var collectionsArr = [], + fieldsArr = [], + form = $($(this).attr('data-form_selector')), + action = form.find("select.sbas_select") + ; + if(action.length != 1) { // should never happen with select ! return false; // prevent button to submit form } + + $(".form2 .collist", form).each(function(i, el) { + if ($(el).is(':visible') === false) { + $.each($(el).find('input'), function(i, inputEl) { + collectionsArr.push($(inputEl).prop('checked')) + }); + $(el).find('input').prop('checked', false); + } + }); + $(".form3 .collist", form).each(function(i, el) { + if ($(el).is(':visible') === false) { + $.each($(el).find('input'), function(i, inputEl) { + fieldsArr.push($(inputEl).prop('checked')) + }); + $(el).find('input').prop('checked', false); + } + }); action = action.find(':selected').data('action'); form.attr("action", action); form.submit(); + + $(".form2 .collist", form).each(function(i, el) { + if ($(el).is(':visible') === false) { + + $.each($(el).find('input'), function(j, inputEl) { + $(inputEl).prop('checked', collectionsArr[j]); + }); + } + }); + $(".form3 .collist", form).each(function(i, el) { + if ($(el).is(':visible') === false) { + + $.each($(el).find('input'), function(j, inputEl) { + $(inputEl).prop('checked', fieldsArr[j]); + }); + } + }); + collectionsArr = []; + fieldsArr = []; + return false; // prevent button to submit form }); diff --git a/templates/web/report/form_date_and_base.html.twig b/templates/web/report/form_date_and_base.html.twig index dbf2573389..955749b250 100644 --- a/templates/web/report/form_date_and_base.html.twig +++ b/templates/web/report/form_date_and_base.html.twig @@ -33,7 +33,7 @@ {% endfor %} -