PHRAS-2342_report_collections_fix

This commit is contained in:
Filip Vilic
2018-12-14 12:18:24 +01:00
parent 2b0edafc49
commit 91aaf2c6d7
3 changed files with 48 additions and 24 deletions

View File

@@ -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
});