From 918bda458c6ffb513fca58c47f68fc70a17e3e8d Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@biblibre.com> Date: Mon, 7 Jul 2014 13:08:13 +0200 Subject: [PATCH] [SIGNED-OFF] Bug 10212: Columns configuration for tables - POC Content-Type: text/plain; charset="utf-8" This patch proves that this feature is useful with a concret use case. Test plan: 1/ Execute the updatedatabase in order to create the new table. 2/ Take a look to the yml structure. 3/ Go on the admin currency page (admin/currency.pl). 4/ Check that you cannot hide the 2 first columns on the table. 5/ Try to hide/show columns. 6/ Go on the columns configuration page (admin/columns_settings.pl). 7/ Only the admin tab are filled with data. Check/uncheck checkboxes and save. 8/ Go on the admin currency page and check that the behavior is what you expected. 9/ Give me some feedback :) Signed-off-by: Owen Leonard <oleonard@myacpl.org> --- .../prog/en/modules/admin/columns_settings.tt | 9 +++- .../prog/en/modules/admin/currency.tt | 45 ++++++++++++++------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt index 5d7d133..cd98a9e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt @@ -13,8 +13,13 @@ [% IF tables.$pagename.keys and tables.$pagename.keys.size > 0 %] [% FOR tablename IN tables.$pagename.keys.sort %] <table> - <caption>[% tablename %]</caption> - <thead><tr><th>Column name</th><th>Is Hidden by default</th><th>Cannot be toggled</th></tr></thead> + <caption> + [% IF tablename == 'currencies-table' %] + Currency + [% END %] + (id=[% tablename %]) + </caption> + <thead><tr><th>Column name</th><th>Is hidden by default</th><th>Cannot be toggled</th></tr></thead> <tbody> [% FOR column IN tables.$pagename.$tablename %] <tr> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt index 3165634..f3dc5dc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt @@ -1,3 +1,5 @@ +[% USE KohaDates %] +[% USE ColumnsSettings %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Administration › Currencies & Exchange rates › [% IF ( add_form ) %][% IF ( searchfield ) %]Modify currency '[% searchfield %]'[% ELSE %]New currency[% END %][% END %] @@ -5,6 +7,11 @@ [% IF ( delete_confirmed ) %]Currency deleted[% END %] [% IF ( else ) %]Currencies[% END %]</title> [% INCLUDE 'doc-head-close.inc' %] +<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> +[% INCLUDE 'datatables.inc' %] +<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.colvis.css" /> +<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.dataTables.colvis.js"></script> +[% INCLUDE 'columns_settings.inc' %] <script type="text/javascript"> //<![CDATA[ @@ -20,6 +27,17 @@ } $(document).ready(function() { + columns_settings = [% ColumnsSettings.GetColumns( 'admin', 'currency', 'currencies-table', 'json' ) %] + var issuest = KohaTable("#currencies-table", { + "sDom": 'C<"clearfix">t', + "aaSorting": [], + "aoColumnDefs": [ + { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, + { "sType": "title-string", "aTargets" : [ "title-string" ] } + ], + "bPaginate": false, + }, columns_settings); + // prevents users to check active with a currency != 1 $("#rate").keyup(function() { check_currency( $(this).val() ); @@ -158,32 +176,35 @@ You searched for [% searchfield %]</span> [% END %] - <table> + <table id='currencies-table'> + <thead> <tr> <th>Currency</th> <th>Rate</th> <th>Symbol</th> <th>ISO code</th> - <th>Last updated</th> + <th class="title-string">Last updated</th> <th>Active</th> - <th colspan="2">Actions </th> + <th>Actions</th> </tr> + </thead> + <tbody> [% FOREACH loo IN loop %] - [% UNLESS ( loop.odd ) %] - <tr class="highlight"> - [% ELSE %] - <tr> - [% END %] + <tr> <td>[% loo.currency %]</td> <td>[% loo.rate %]</td> <td>[% loo.symbol |html %]</td> <td>[% loo.isocode |html %]</td> - <td>[% loo.timestamp %]</td> + <td><span title="[% loo.timestamp %]">[% loo.timestamp | $KohaDates %]</span></td> <td style="color:green;">[% IF ( loo.active ) %]✓[% END %]</td> - <td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.currency %]">Edit</a></td> - <td><a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.currency %]">Delete</a></td> - </tr> + <td> + <a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.currency %]">Edit</a> + | + <a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.currency %]">Delete</a> + </td> + </tr> [% END %] + </tbody> </table> <br /> -- 1.7.9.5