From 547ef37e044c062709e7bd02061a6a66a2b408f4 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Thu, 9 Jul 2015 16:26:36 -0600 Subject: [PATCH] Bug 14510: Allow column visibility in additem.pl to be customized This patch adds the table of items on additem.pl to the columns customizer. Test plan: 1. Open item editor on a record, and verify that all columns are visible. 2. Apply patch. 3. Reload editor, and verify that column visibility hasn't changed. 4. Open "Hide/show columns," and verify that you can add and remove columns. 5. Change the visibility and togglability of some columns in columns_settings.pl, and verify that these correctly apply to additem.pl. NOTE: The columns that are configurable are selected from the non-hidden columns that have mappings to MARC subfields in the default MARC21 framework (and can thus be displayed in the item editor). Signed-off-by: Jenny Schmidt Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- admin/columns_settings.yml | 76 +++++++++++++++++++ cataloguing/additem.pl | 7 ++ .../prog/en/includes/columns_settings.inc | 7 +- .../prog/en/modules/admin/columns_settings.tt | 5 ++ .../prog/en/modules/cataloguing/additem.tt | 21 +++-- 5 files changed, 109 insertions(+), 7 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index b8c6bfc1d6..dd0bd3562e 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -83,6 +83,82 @@ modules: - columnname: actions + cataloguing: + additem: + itemst: + # NOTE: These columns are selected from the non-hidden columns that have mappings to MARC + # subfields in the default MARC21 framework (and can thus be displayed in the item editor). + - + columnname: withdrawn + - + columnname: itemlost + - + columnname: cn_source + - + columnname: materials + - + columnname: damaged + - + columnname: restricted + - + columnname: cn_sort + - + columnname: notforloan + - + columnname: ccode + - + columnname: itemnumber + - + columnname: homebranch + - + columnname: holdingbranch + - + columnname: location + - + columnname: dateaccessioned + - + columnname: booksellerid + - + columnname: coded_location_qualifier + - + columnname: price + - + columnname: enumchron + - + columnname: stocknumber + - + columnname: stack + - + columnname: issues + - + columnname: renewals + - + columnname: reserves + - + columnname: itemcallnumber + - + columnname: barcode + - + columnname: onloan + - + columnname: datelastseen + - + columnname: datelastborrowed + - + columnname: copynumber + - + columnname: uri + - + columnname: replacementprice + - + columnname: replacementpricedate + - + columnname: itemnotes_nonpublic + - + columnname: itype + - + columnname: itemnotes + members: member: memberresultst: diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 38f5d92fb2..753a5154ec 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -803,6 +803,13 @@ for my $row ( @big_array ) { foreach my $subfield_code (sort keys(%witness)) { my %header_value; $header_value{header_value} = $witness{$subfield_code}; + + my $subfieldlib = $tagslib->{$itemtagfield}->{$subfield_code}; + my $kohafield = $subfieldlib->{kohafield}; + if ( $kohafield && $kohafield =~ /items.(.+)/ ) { + $header_value{column_name} = $1; + } + push(@header_value_loop, \%header_value); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc index 87d9da6772..52ab38fbfd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -9,11 +9,14 @@ function KohaTable(selector, dt_parameters, columns_settings) { var hidden_ids = []; var excluded_ids = []; $(columns_settings).each( function() { + var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( 'th' ); + var used_id = named_id == -1 ? id : named_id; + if ( this['is_hidden'] == "1" ) { - hidden_ids.push( id ); + hidden_ids.push( used_id ); } if ( this['cannot_be_toggled'] == "1" ) { - excluded_ids.push( id ); + excluded_ids.push( used_id ); } id++; }); 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 cb799f7ffd..182f3dd3e2 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 @@ -12,10 +12,15 @@ [% SET tables = module %] [% IF tables.$pagename.keys and tables.$pagename.keys.size > 0 %] [% FOR tablename IN tables.$pagename.keys.sort %] + [% IF pagename == 'additem' AND tablename == 'itemst' %] +
Saving changes to column visibility here will override framework visibility settings for the table of items.
+ [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 5028251221..988d1eca03 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -1,9 +1,12 @@ +[% USE ColumnsSettings %] + [% INCLUDE 'doc-head-open.inc' %] Koha › Cataloging › [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %]) › Items [% INCLUDE 'doc-head-close.inc' %] [% INCLUDE 'datatables.inc' %] +[% INCLUDE 'columns_settings.inc' %] [% INCLUDE 'browser-strings.inc' %]
[% IF tablename == 'currencies-table' %] Currency + [% ELSIF pagename == 'additem' AND tablename == 'itemst' %] + Items Editor [% END %] (id=[% tablename %])