From 5ebfa9151ecd811736546a88ba2369f865b1f9bc Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Tue, 14 Nov 2017 13:29:33 +0000 Subject: [PATCH] Bug 17282 - Add information about the new Javascript libraries in the about page - fix a QA warning - Move chart settings on top and make them hidden by default - Add options to get all results --- koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc | 8 +++++++- .../prog/en/includes/reports-toolbar.inc | 4 ++++ koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 6 ++++++ .../prog/en/modules/reports/guided_reports_start.tt | 21 +++++++++++++++++---- reports/guided_reports.pl | 7 +++++++ 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc index ceec7a31c5..55a062f8b4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc @@ -1,4 +1,4 @@ -<div id="makechart"> +<div id="makechart" style="display:none;"> [% supposed_x = header_row.shift.cell %] <fieldset> @@ -28,6 +28,12 @@ </select> </li> + <div> + <label for="include-all">Include all rows (ignore pagination)</label> + <input id="include-all" name="chart-include-all" type="checkbox"> + </div> + + <label for="exclude-last">Exclude last line (Rollup)</label> <input id="exclude-last" name="chart-exclude-last" type="checkbox"> diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc index 05ad1123a2..d3846f614c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc @@ -62,6 +62,10 @@ <a class="btn btn-default btn-sm toggle_sql" id="toggle_sql_hid" href="#"><i class="fa fa-eye"></i> Show SQL code</a> <a class="btn btn-default btn-sm toggle_sql" id="toggle_sql_vis" href="#" style="display:none;"><i class="fa fa-eye-slash"></i> Hide SQL code</a> </div> + <div class="btn-group"> + <a class="btn btn-default btn-sm toggle_chart_settings" id="toggle_chart_settings_hid" href="#"><i class="fa fa-eye"></i> Show chart settings</a> + <a class="btn btn-default btn-sm toggle_chart_settings" id="toggle_chart_settings_vis" href="#" style="display:none;"><i class="fa fa-eye-slash"></i> Hide chart settings</a> + </div> [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 6ab111fda0..23f5aece62 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -914,6 +914,12 @@ <h2>Leaflet</h2> <p>The <a href="http://leafletjs.com">Leaflet</a> JavaScript library by Vladimir Agafonkinis licensed under the <a href="https://github.com/Leaflet/Leaflet/blob/master/LICENSE">BSD License</a>.</p> + + <h2>D3.js</h2> + <p><a href="https://d3js.org/">D3.js v3.5.17</a> is a JavaScript library for manipulating documents based on data. It is under the <a href="https://github.com/d3/d3/blob/master/LICENSE">BSD 3-clause Licence</a></p> + + <h2>C3.js</h2> + <p><a href="http://c3js.org/">C3.js v0.4.11</a> is a D3-based reusable chart library under the <a href="https://opensource.org/licenses/mit-license.php">MIT licence</a></p> </div> <div id="translations"> 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 c2dbc70cad..9e0dbda464 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 @@ -206,6 +206,12 @@ $("#delColumn").on("click",function(){ $("#toggle_sql_vis").toggle(); }); + $(".toggle_chart_settings").click(function(){ + $("#makechart").toggle(); + $("#toggle_chart_settings_hid").toggle(); + $("#toggle_chart_settings_vis").toggle(); + }); + $("#table_reports").delegate(".confirmdelete", 'click', function(){ $(this).parents('tr').attr("class","warn"); if(confirm(_("Are you sure you want to delete this saved report?"))){ @@ -963,7 +969,7 @@ canned reports and writing custom SQL reports.</p> $('#draw-chart').click(function() { var btn_text = $("#draw-chart").html(); - $("#draw-chart").html(_('Loading...')); + $("#draw-chart").html(_("Loading...")); var x_elements = $('select[name="x"]').val(); var y_elements = []; @@ -973,7 +979,14 @@ canned reports and writing custom SQL reports.</p> //var headers = [% header_row.json %]; headers = [% header_row.json %]; - var results = [% results.json %] + + var results; + if ($('input[name="chart-include-all"]').prop('checked')) { + results = [% allresults.json %] + } + else { + results = [% results.json %] + } if ($('input[name="chart-exclude-last"]').prop('checked')) { results.splice(-1, 1); @@ -1037,6 +1050,8 @@ canned reports and writing custom SQL reports.</p> <div id="sql_output" style="display:none;"><span class="label">Report SQL:</span><pre>[% sql |html %]</pre></div> </br> +[% INCLUDE 'chart.inc' %] + <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get" id="limitselect"> <input type="hidden" name="phase" value="Run this report"/> <input type="hidden" name="reports" value="[% report_id %]"/> @@ -1069,8 +1084,6 @@ canned reports and writing custom SQL reports.</p> [% END %] </table> -[% INCLUDE 'chart.inc' %] - [% END %] [% END %] diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index bfd0a7646b..f59385ba5b 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -676,6 +676,7 @@ elsif ($phase eq 'Run this report'){ $notes = $report->{notes}; my @rows = (); + my @allrows = (); # if we have at least 1 parameter, and it's not filled, then don't execute but ask for parameters if ($sql =~ /<</ && !@sql_params) { # split on ??. Each odd (2,4,6,...) entry should be a parameter to fill @@ -801,6 +802,7 @@ elsif ($phase eq 'Run this report'){ $sql =~ s/<<$split[$i*2+1]>>/$quoted/; } my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id ); + my ($sth2, $errors2) = execute_query($sql); my $total = nb_rows($sql) || 0; unless ($sth) { die "execute_query failed to return sth for report $report_id: $sql"; @@ -811,6 +813,10 @@ elsif ($phase eq 'Run this report'){ my @cells = map { +{ cell => $_ } } @$row; push @rows, { cells => \@cells }; } + while (my $row = $sth2->fetchrow_arrayref()) { + my @cells = map { +{ cell => $_ } } @$row; + push @allrows, { cells => \@cells }; + } } my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0); @@ -820,6 +826,7 @@ elsif ($phase eq 'Run this report'){ } $template->param( 'results' => \@rows, + 'allresults' => \@allrows, 'sql' => $sql, original_sql => $original_sql, 'id' => $report_id, -- 2.11.0