Bug 14510: Allow column visibility in additem.pl to be customized
authorJesse Weaver <pianohacker@gmail.com>
Thu, 9 Jul 2015 22:26:36 +0000 (16:26 -0600)
committerTomas Cohen Arazi <tomascohen@unc.edu.ar>
Fri, 18 Sep 2015 14:57:03 +0000 (11:57 -0300)
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 <jschmidt@switchinc.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
admin/columns_settings.yml
cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt

index b8c6bfc..dd0bd35 100644 (file)
@@ -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:
index 38f5d92..753a515 100755 (executable)
@@ -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);
 }
 
index 87d9da6..52ab38f 100644 (file)
@@ -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++;
     });
index cb799f7..182f3dd 100644 (file)
         [% 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' %]
+                         <div class="alert">Saving changes to column visibility here will override framework visibility settings for the table of items.</div>
+                       [% END %]
             <table>
               <caption>
                 [% IF tablename == 'currencies-table' %]
                   Currency
+                               [% ELSIF pagename == 'additem' AND tablename == 'itemst' %]
+                  Items Editor
                 [% END %]
                 (id=[% tablename %])
               </caption>
index 5028251..988d1ec 100644 (file)
@@ -1,9 +1,12 @@
+[% USE ColumnsSettings %]
+
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Cataloging &rsaquo; [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %]) &rsaquo; Items</title>
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'datatables.inc' %]
 <script type="text/javascript" src="[% themelang %]/js/cataloging.js"></script>
+[% INCLUDE 'columns_settings.inc' %]
 [% INCLUDE 'browser-strings.inc' %]
 <!--[if lt IE 9]>
 <script type="text/javascript" src="[% interface %]/lib/shims/json2.min.js"></script>
@@ -45,14 +48,18 @@ $(document).ready(function(){
                 });
             });
 
-    var itemst = $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
+    var columns_settings = [% ColumnsSettings.GetColumns( 'cataloguing', 'additem', 'itemst', 'json' ) %]
+       // Skip the first column
+       columns_settings.unshift( { cannot_be_toggled: "1" } );
+
+    var itemst = KohaTable("#itemst", {
         "aoColumnDefs": [
           { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
         ],
         'bPaginate': false,
         'bInfo': false,
         "bAutoWidth": false
-    } ) );
+    }, columns_settings);
 
 });
 function Check(f) {
@@ -134,9 +141,13 @@ function confirm_deletion() {
           <thead>
             <tr>
                 <th>&nbsp;</th>
-                [% FOREACH item_header_loo IN item_header_loop %]
-                    <th>
-                        [% item_header_loo.header_value %]
+                [% FOREACH item_header IN item_header_loop %]
+                    [% IF item_header.column_name %]
+                        <th data-colname="[% item_header.column_name %]">
+                    [% ELSE %]
+                        <th>
+                    [% END %]
+                        [% item_header.header_value %]
                     </th>
                 [% END %]
             </tr>