@@ -, +, @@ 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(-) --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -3137,3 +3137,7 @@ fieldset.rows + fieldset.action { table#ill-requests { width: 100% !important; } + +div#makechart ol li { + list-style: none; +} --- a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc +++ a/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. - +
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -958,68 +958,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 %]

--