From f1340532c6a79105cf80ddf068bdcd9460ad7c66 Mon Sep 17 00:00:00 2001 From: Alex Arnaud Date: Fri, 21 Apr 2017 14:18:52 +0000 Subject: [PATCH] Bug 17282 - Fix QA comments - Add a loading message, - prevent JS error when report fails, - fix (bootstrap 3 ?) displaying problems --- koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 4 + koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc | 4 +- .../en/modules/reports/guided_reports_start.tt | 115 +++++++++++---------- 3 files changed, 68 insertions(+), 55 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index 35479c8..f672297 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -2977,3 +2977,7 @@ fieldset.rows + fieldset.action { .yui-u .rows li p label.widelabel { width: auto; } + +div#makechart ol li { + list-style: none; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc index c0fa2a6..ceec7a3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc @@ -1,7 +1,7 @@
[% supposed_x = header_row.shift.cell %] -
+
Draw a chart
  1. @@ -80,7 +80,7 @@
  2. - +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index f443bbe..5bbdaac 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -898,68 +898,77 @@ canned reports and writing custom SQL reports.

$('#download-chart').hide(); var chart; - $('#draw-chart').click(function() { - var x_elements = $('select[name="x"]').val(); - var y_elements = []; - var groups = []; - var lines = []; - var options = {}; - - //var headers = [% header_row.json %]; - headers = [% header_row.json %]; - var results = [% results.json %] - - if ($('input[name="chart-exclude-last"]').prop('checked')) { - results.splice(-1, 1); - } - $('select[name="y"]').each(function( index ) { - y_elements.push( $(this).val() ); - }); - $('select[name="group"]').each(function( index ) { - groups.push( $(this).val() ); - }); - $('.column-line').each(function( index ) { - if ($(this).prop('checked')) { - lines.push( $(this).attr('name') ); - } - }); + [% UNLESS (errors) %] + $('#draw-chart').click(function() { - // Remove deleted columns from headers and results. - var deleted_indexes = []; - var kept_headers = []; - $.each(headers, function(index, value) { - if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { - // This header is neither a x element nor in y elements. Don't need it. - deleted_indexes.push(index); - } - else { - kept_headers.push({cell: value.cell}); + var btn_text = $("#draw-chart").html(); + $("#draw-chart").html(_('Loading...')); + + var x_elements = $('select[name="x"]').val(); + var y_elements = []; + var groups = []; + var lines = []; + var options = {}; + + //var headers = [% header_row.json %]; + headers = [% header_row.json %]; + var results = [% results.json %] + + if ($('input[name="chart-exclude-last"]').prop('checked')) { + results.splice(-1, 1); } - }); - // Remove coresponding cells. - var kept_results = []; - $.each(results, function(index, value) { - var line = {}; - line['cells'] = []; - $.each(value.cells, function(i, val) { - if ($.inArray(i, deleted_indexes) === -1) { - line['cells'].push({cell: val.cell}); + $('select[name="y"]').each(function( index ) { + y_elements.push( $(this).val() ); + }); + $('select[name="group"]').each(function( index ) { + groups.push( $(this).val() ); + }); + $('.column-line').each(function( index ) { + if ($(this).prop('checked')) { + lines.push( $(this).attr('name') ); + } + }); + + // Remove deleted columns from headers and results. + var deleted_indexes = []; + var kept_headers = []; + $.each(headers, function(index, value) { + if (value.cell != x_elements && $.inArray(value.cell, y_elements) === -1) { + // This header is neither a x element nor in y elements. Don't need it. + deleted_indexes.push(index); + } + else { + kept_headers.push({cell: value.cell}); } }); - kept_results.push(line); - }); - options.type = $('select[name="chart-type"]').val(); - options.horizontal = $('input[name="column-horizontal"]').prop('checked'); - options.lines = lines; + // Remove coresponding cells. + var kept_results = []; + $.each(results, function(index, value) { + var line = {}; + line['cells'] = []; + $.each(value.cells, function(i, val) { + if ($.inArray(i, deleted_indexes) === -1) { + line['cells'].push({cell: val.cell}); + } + }); + kept_results.push(line); + }); + options.type = $('select[name="chart-type"]').val(); + options.horizontal = $('input[name="column-horizontal"]').prop('checked'); + options.lines = lines; - chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); - $('#chart').prepend('
' + "[% name %]" + '
'); - $('#download-chart').show(); - }); + + chart = create_chart(kept_headers, kept_results, x_elements, y_elements, groups, options); + $('#chart').prepend('
' + "[% name %]" + '
'); + $('#download-chart').show(); + $("#draw-chart").html(_(btn_text)); + $("html, body").animate({ scrollTop: $(document).height() }, "slow"); + }); + [% END %] });

[% name %]

-- 2.7.4