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), var $this = $(this),
value = $this.attr('rel'), value = $this.attr('rel'),
form = $this.closest('form'); form = $this.closest('form');
$(".form2 .collist", form).hide(); $(".collist", form).hide();
$(".form2 .collist-" + value, form).show(); $(".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);
}
});
}); });
$('.form2 .collist').each(function() { $('.collist').each(function() {
var $this = $(this), var $this = $(this),
form = $this.closest('form'), form = $this.closest('form'),
i = $this.closest('form').find('.sbas_select').val() i = $this.closest('form').find('.sbas_select').val()
; ;
$this.hide(); $this.hide();
$(".collist-" + i, form).show(); $(".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() { $('.form2').each(function() {
@@ -109,15 +92,56 @@ function bindEvents() {
* "Download" buttons * "Download" buttons
**/ **/
$('.formsubmiter').bind('click', function () { $('.formsubmiter').bind('click', function () {
var form = $($(this).attr('data-form_selector')); var collectionsArr = [],
var action = form.find("select.sbas_select"); fieldsArr = [],
form = $($(this).attr('data-form_selector')),
action = form.find("select.sbas_select")
;
if(action.length != 1) { // should never happen with select ! if(action.length != 1) { // should never happen with select !
return false; // prevent button to submit form 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'); action = action.find(':selected').data('action');
form.attr("action", action); form.attr("action", action);
form.submit(); 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 return false; // prevent button to submit form
}); });

View File

@@ -33,7 +33,7 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="form2 form_content"> <div class="form2 form_content form_content_checkboxes">
{% if displayCollections == true %} {% if displayCollections == true %}
<div class="form_titre"> <div class="form_titre">
{{ "report:: 3 - Collections" | trans }} {{ "report:: 3 - Collections" | trans }}

View File

@@ -58,7 +58,7 @@
{% include "report/form_date_and_base.html.twig" with {'tab': "records", 'route': "report2_records", 'displayCollections': true } %} {% include "report/form_date_and_base.html.twig" with {'tab': "records", 'route': "report2_records", 'displayCollections': true } %}
{% block form_records %} {% block form_records %}
<div class="form3 form_content"> <div class="form3 form_content form_content_checkboxes">
<div class="form_titre">{{ "report:: 4 - Fields" | trans }}</div> <div class="form_titre">{{ "report:: 4 - Fields" | trans }}</div>
{% for sbas_id,databox in granted_bases %} {% for sbas_id,databox in granted_bases %}