Bugzilla – Attachment 32814 Details for
Bug 12987
Update table footer with the visible rows
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 12987: Update table footer with the visible rows
PASSED-QA-Bug-12987-Update-table-footer-with-the-v.patch (text/plain), 3.82 KB, created by
Katrin Fischer
on 2014-10-27 22:44:16 UTC
(
hide
)
Description:
[PASSED QA] Bug 12987: Update table footer with the visible rows
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-10-27 22:44:16 UTC
Size:
3.82 KB
patch
obsolete
>From 89751012c36faed8c39b4007fb8bd5ca58d0d344 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 24 Sep 2014 17:16:01 +0200 >Subject: [PATCH] [PASSED QA] Bug 12987: Update table footer with the visible > rows > >This patch is the preparation step for others. > >On acqui/acqui-home.pl and admin/aqbudgets.pl, it will be possible to >see the totals in the footer updated with the filtered rows. > >Test plan: >This cannot be tested alone, you have to apply it with others (see the >"Blocked" bug reports). > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../prog/en/includes/format_price.inc | 27 +++++++++++++++++++ > koha-tmpl/intranet-tmpl/prog/en/js/datatables.js | 31 ++++++++++++++++++++++ > 2 files changed, 58 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/format_price.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/format_price.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/format_price.inc >new file mode 100644 >index 0000000..b0e5a8d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/format_price.inc >@@ -0,0 +1,27 @@ >+[% USE Koha %] >+<script type="text/javascript"> >+ [%# This should use the Format template plugin, but not pushed yet %] >+ [% IF Koha.Preference("CurrencyFormat") == 'FR' %] >+ var default_value = { >+ thousands_sep: ' ', >+ decimal_point: ',', >+ decimal_digits: 2 >+ }; >+ [% ELSE %] >+ var default_value = { >+ thousands_sep: ',', >+ decimal_point: '.', >+ decimal_digits: 2 >+ }; >+ [% END %] >+ Number.prototype.format_price = function( value, params ) { >+ params = params == undefined ? {} : params; >+ var thousands_sep = params.thousands_sep == undefined ? default_value.thousands_sep : params.thousands_sep, >+ decimal_point = params.decimal_point == undefined ? default_value.decimal_point : params.decimal_point, >+ //symbol = params.symbol == undefined ? '$' : params.symbol, // Not implemented yet >+ decimal_digits = params.decimal_digits == undefined ? default_value.decimal_digits : params.decimal_digits; >+ >+ var re = '\\d(?=(\\d{' + 3 + '})+' + '\\D' + ')', value = this.toFixed(decimal_digits); >+ return value.replace('.', decimal_point).replace(new RegExp(re, 'g'), '$&' + thousands_sep); >+ } >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >index 49ccb74..b3d97fe 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js >@@ -607,3 +607,34 @@ function parse_callnumber ( html ) { > return ""; > } > } >+ >+// see http://www.datatables.net/examples/advanced_init/footer_callback.html >+function footer_column_sum( api, column_numbers ) { >+ // Remove the formatting to get integer data for summation >+ var intVal = function ( i ) { >+ if ( typeof i === 'number' ) { >+ if ( isNaN(i) ) return 0; >+ return i; >+ } else if ( typeof i === 'string' ) { >+ var value = i.replace(/[a-zA-Z ,.]/g, '')*1; >+ if ( isNaN(value) ) return 0; >+ return value; >+ } >+ return 0; >+ }; >+ >+ >+ for ( var indice = 0 ; indice < column_numbers.length ; indice++ ) { >+ var column_number = column_numbers[indice]; >+ >+ var total = 0; >+ var cells = api.column( column_number, { page: 'current' } ).nodes().to$().find("span.total_amount"); >+ $(cells).each(function(){ >+ total += intVal( $(this).html() ); >+ }); >+ total /= 100; // Hard-coded decimal precision >+ >+ // Update footer >+ $( api.column( column_number ).footer() ).html(total.format_price()); >+ }; >+} >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12987
:
31853
|
31854
|
31976
|
32019
|
32094
|
32095
|
32812
|
32813
| 32814 |
32815