Skip to content

Commit

Permalink
Fixed issue #19282: Statistics of a survey - response filters disappe…
Browse files Browse the repository at this point in the history
…ar after first excel exported (#3647)

Co-authored-by: lapiudevgit <devgit@lapiu.biz>
  • Loading branch information
gabrieljenik and lapiudevgit committed Dec 11, 2023
1 parent b6e5859 commit 264e4cd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 38 deletions.
2 changes: 1 addition & 1 deletion application/extensions/AccordionWidget/AccordionWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function normaliseItems($items)
'id' => $item['id'] ?? $this->id . '_item_' . bin2hex(random_bytes(2)),
'title' => $item['title'] ?? null,
'content' => $item['content'] ?? null,
'open' => $item['open'] ?? false,
'open' => $item['open'] ?? true,
'style' => $item['style'] ?? ''
];
}, $items);
Expand Down
6 changes: 3 additions & 3 deletions application/extensions/AccordionWidget/views/accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<div class="accordion-item" style="<?=$item['style']?>">
<h2 class="accordion-header" id="<?=$item['id']?>">
<button
class="accordion-button"
class="accordion-button <?= $item['open'] ? '' : 'collapsed' ?>"
type="button"
data-bs-toggle="collapse"
data-bs-target="#<?=$item['id']?>-body"
aria-expanded="true"
aria-expanded="<?= $item['open'] ? 'true' : 'false' ?>"
aria-controls="<?=$item['id']?>">
<?=gT($item['title'])?>
</button>
</h2>
<div
id="<?=$item['id']?>-body"
class="accordion-collapse collapse show"
class="accordion-collapse collapse <?= $item['open'] ? 'show' : '' ?>"
aria-labelledby="<?=$item['id']?>"
>
<div class="accordion-body">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div id="filterchoices"
<?php if ($filterchoice_state != '' || !empty($summary)) {echo " style='display:none' ";}?>>
<div id="filterchoices">
<?php foreach ($aGroups as $groupKey => $aGroup) : ?>
<div class="accordion mb-3" id="accordion_<?php echo $aGroup['gid']; ?>">
<div class="accordion-item">
Expand Down
2 changes: 2 additions & 0 deletions application/views/admin/export/statistics_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
[
'id' => 'general-filters-item',
'title' => 'General filters',
'open' => $filterchoice_state == '' && empty($summary),
'content' => $this->renderPartial(
'/admin/export/statistics_subviews/_general_filters',
array(
Expand All @@ -56,6 +57,7 @@
[
'id' => 'response-filters-item',
'title' => 'Response filters',
'open' => $filterchoice_state == '' && empty($summary),
'content' => $this->renderPartial(
'/admin/export/statistics_subviews/_response_filters',
array(
Expand Down
43 changes: 11 additions & 32 deletions assets/scripts/admin/statistics.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

function toggleSection(chevron, section) {
section.toggle();
chevron.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down');
}

function hideSection(chevron, section) {
section.hide();
chevron.removeClass('fa-chevron-up');
chevron.addClass('fa-chevron-down');
function hideSection(section) {
var collapsible = document.getElementById(section);
// Try to get the bootstrap collapse instance
var bsCollapse = bootstrap.Collapse.getInstance(collapsible);
// If there is no previous instance, create a new one
if (!bsCollapse) {
bsCollapse = new bootstrap.Collapse(collapsible);
}
bsCollapse.hide();
}

/**
Expand Down Expand Up @@ -264,24 +264,10 @@ LS.Statistics2 = function () {
$('#statisticsoutput .row').first().find('.chartjs-container').loadGraph();
}

$('#generalfilters-chevron').click(function () {
toggleSection($('#generalfilters-chevron'), $('#statisticsgeneralfilters'));
});

$('#responsefilters-chevron').click(function () {
toggleSection($('#responsefilters-chevron'), $('#filterchoices'));
});

$('#statistics-render-chevron').click(function () {
toggleSection($('#statistics-render-chevron'), $('#statisticsoutput'));
});

$('#generate-statistics').submit(function () {
hideSection($('#generalfilters-chevron'), $('#statisticsgeneralfilters'));
hideSection($('#responsefilters-chevron'), $('#filterchoices'))
hideSection('general-filters-item-body');
hideSection('response-filters-item-body');
$('#statisticsoutput').show();
$('#statistics-render-chevron').removeClass('fa-chevron-up');
$('#statistics-render-chevron').addClass('fa-chevron-down');
$('#view-stats-alert-info').hide();
$('#statsContainerLoading').show();
if ($('input[name=outputtype]:checked').val() != 'html') {
Expand All @@ -293,13 +279,6 @@ LS.Statistics2 = function () {
//alert('ok');
});

$('.group-question-chevron').click(function () {
//alert('ok');
$group_to_hide = $('#' + $(this).data('grouptohide'));
toggleSection($(this), $group_to_hide)
//$('#'+group_to_hide).hide();
});

// If the graph are displayed
if ($('.chartjs-container').length > 0) {

Expand Down

0 comments on commit 264e4cd

Please sign in to comment.