Bugzilla – Attachment 2816 Details for
Bug 5285
Let the user choose columns to show batch modification summary table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed fix
0001-Fix-for-Bug-5285-Show-hide-columns-in-the-output-of-.patch (text/plain), 17.28 KB, created by
Owen Leonard
on 2010-12-07 17:24:46 UTC
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2010-12-07 17:24:46 UTC
Size:
17.28 KB
patch
obsolete
>From ac2b8bfa38d2a79710e8cfa1b8b9a2962b84c60e Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 5 Oct 2010 16:18:05 -0400 >Subject: [PATCH] Fix for Bug 5285, Show/hide columns in the output of items in batch operations > >Also adds title/author information to output of batch deletions >--- > .../prog/en/includes/doc-head-close.inc | 2 +- > .../intranet-tmpl/prog/en/js/pages/batchMod.js | 139 ++++++++++++++++++++ > .../prog/en/modules/tools/batchMod-del.tmpl | 50 ++++---- > .../prog/en/modules/tools/batchMod-edit.tmpl | 54 ++++---- > tools/batchMod.pl | 13 ++- > 5 files changed, 201 insertions(+), 57 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >index 1970440..bbbd648 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >@@ -62,7 +62,7 @@ > > <!-- yui js --> > <script type="text/javascript" src="<!-- TMPL_VAR NAME="yuipath" -->/utilities/utilities.js"></script> >-<script type="text/javascript" src="<!-- TMPL_VAR NAME="yuipath" -->/datasource/datasource.js"></script> >+<script type="text/javascript" src="<!-- TMPL_VAR NAME="yuipath" -->/datasource/datasource-min.js"></script> > <!-- TMPL_IF NAME="CircAutocompl" --> > <script type="text/javascript" src="<!-- TMPL_VAR NAME="yuipath" -->/autocomplete/autocomplete-min.js"></script> > <!-- /TMPL_IF --> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js >new file mode 100644 >index 0000000..3b9b7ec >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js >@@ -0,0 +1,139 @@ >+// Set expiration date for cookies >+ var date = new Date(); >+ date.setTime(date.getTime()+(365*24*60*60*1000)); >+ var expiration = date.toGMTString(); >+ >+ >+function hideColumns(){ >+ valCookie = YAHOO.util.Cookie.get("showColumns", function(stringValue){ >+ return stringValue.split("/"); >+ }); >+ if(valCookie){ >+ $("#showall").attr("checked","").parent().removeClass("selected"); >+ for( i=0; i<valCookie.length; i++ ){ >+ if(valCookie[i] != ''){ >+ index = valCookie[i] - 2; >+ $("#itemst td:nth-child("+valCookie[i]+"),#itemst th:nth-child("+valCookie[i]+")").toggle(); >+ $("#checkheader"+index).attr("checked","").parent().removeClass("selected"); >+ } >+ } >+ } >+} >+ >+function hideColumn(num) { >+ $("#hideall,#showall").attr("checked","").parent().removeClass("selected"); >+ valCookie = YAHOO.util.Cookie.get("showColumns", function(stringValue){ >+ return stringValue.split("/"); >+ }); >+ // set the index of the table column to hide >+ $("#"+num).parent().removeClass("selected"); >+ var hide = Number(num.replace("checkheader","")) + 2; >+ // hide header and cells matching the index >+ $("#itemst td:nth-child("+hide+"),#itemst th:nth-child("+hide+")").toggle(); >+ // set or modify cookie with the hidden column's index >+ if(valCookie){ >+ var found = false; >+ for( $i=0; $i<valCookie.length; $i++ ){ >+ if (hide == valCookie[i]) { >+ found = true; >+ break; >+ } >+ } >+ if( !found ){ >+ valCookie.push(hide); >+ var cookieString = valCookie.join("/"); >+ YAHOO.util.Cookie.set("showColumns", cookieString, { >+ expires: date >+ }); >+ } >+ } else { >+ YAHOO.util.Cookie.set("showColumns", hide, { >+ expires: date >+ }); >+ } >+} >+ >+// Array Remove - By John Resig (MIT Licensed) >+// http://ejohn.org/blog/javascript-array-remove/ >+Array.prototype.remove = function(from, to) { >+ var rest = this.slice((to || from) + 1 || this.length); >+ this.length = from < 0 ? this.length + from : from; >+ return this.push.apply(this, rest); >+}; >+ >+function showColumn(num){ >+ $("#hideall").attr("checked","").parent().removeClass("selected"); >+ $("#"+num).parent().addClass("selected"); >+ valCookie = YAHOO.util.Cookie.get("showColumns", function(stringValue){ >+ return stringValue.split("/"); >+ }); >+ // set the index of the table column to hide >+ show = Number(num.replace("checkheader","")) + 2; >+ // hide header and cells matching the index >+ $("#itemst td:nth-child("+show+"),#itemst th:nth-child("+show+")").toggle(); >+ // set or modify cookie with the hidden column's index >+ if(valCookie){ >+ var found = false; >+ for( i=0; i<valCookie.length; i++ ){ >+ if (show == valCookie[i]) { >+ valCookie.remove(i); >+ found = true; >+ } >+ } >+ if( found ){ >+ var cookieString = valCookie.join("/"); >+ YAHOO.util.Cookie.set("showColumns", cookieString, { >+ expires: date >+ }); >+ } >+ } >+} >+function showAllColumns(){ >+ $("#selections").checkCheckboxes(); >+ $("#selections span").addClass("selected"); >+ $("#itemst td:nth-child(2),#itemst tr th:nth-child(2)").nextAll().show(); >+ YAHOO.util.Cookie.remove("showColumns"); >+ $("#hideall").attr("checked","").parent().removeClass("selected"); >+} >+function hideAllColumns(){ >+ $("#selections").unCheckCheckboxes(); >+ $("#selections span").removeClass("selected"); >+ $("#itemst td:nth-child(2),#itemst th:nth-child(2)").nextAll().hide(); >+ $("#hideall").attr("checked","checked").parent().addClass("selected"); >+ var cookieString = allColumns.join("/"); >+ YAHOO.util.Cookie.set("showColumns", cookieString, { >+ expires: date >+ }); >+} >+ >+ $(document).ready(function() { >+ hideColumns(); >+ $("#itemst").tablesorter({ >+ widgets : ['zebra'], >+ headers: {0:{sorter: false}} >+ }); >+ $("#selectallbutton").click(function(){ >+ $("#itemst").checkCheckboxes(); >+ return false; >+ }); >+ $("#clearallbutton").click(function(){ >+ $("#itemst").unCheckCheckboxes(); >+ return false; >+ }); >+ $("#selections input").change(function(e){ >+ var num = $(this).attr("id"); >+ if(num == 'showall'){ >+ showAllColumns(); >+ e.stopPropagation(); >+ } else if(num == 'hideall'){ >+ hideAllColumns(); >+ e.stopPropagation(); >+ } else { >+ if($(this).attr("checked")){ >+ showColumn(num); >+ } else { >+ hideColumn(num); >+ } >+ } >+ }); >+ }); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl >index 441f4c5..f757240 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl >@@ -2,32 +2,25 @@ > <title>Koha › Tools › Batch item deletion</title> > <!-- TMPL_INCLUDE NAME="doc-head-close.inc" --> > <!-- TMPL_INCLUDE NAME="background-job.inc" --> >-<style type="text/css"> >- #jobpanel,#jobstatus,#jobfailed { display : none; } >- #jobstatus { margin:.4em; } >- #jobprogress{ width:200px;height:10px;border:1px solid #666;background:url('/intranet-tmpl/prog/img/progress.png') -300px 0px no-repeat; } >-</style> >+<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/css/pages/batchMod.css" /> > <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >-<script type="text/JavaScript" language="JavaScript"> >+<script src="<!-- TMPL_VAR name="themelang" -->/lib/yui/cookie/cookie-min.js"></script> >+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+<script type="text/javascript"> > //<![CDATA[ >- $(document).ready(function() { >- $("#itemst").tablesorter({ >- widgets : ['zebra'] >- }); >- $("#selectallbutton").click(function() { >- $("#itemst").find("input:checkbox").each(function() { >- $(this).attr("checked", true); >- }); >- }); >- $("#clearallbutton").click(function() { >- $("#itemst").find("input:checkbox").each(function() { >- $(this).attr("checked", false); >- }); >- }); >- >- }); >+ >+// Prepare array of all column headers, incrementing each index by >+// two to accomodate control and title columns >+var allColumns = new Array(<!-- TMPL_LOOP NAME="item_header_loop" -->'<!-- TMPL_VAR NAME="__counter__" -->'<!-- TMPL_UNLESS NAME="__last__" -->,<!-- /TMPL_UNLESS --><!-- /TMPL_LOOP -->); >+for( x=0; x<allColumns.length; x++ ){ >+ allColumns[x] = Number(allColumns[x]) + 2; >+} > //]]> > </script> >+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/js/pages/batchMod.js"></script> >+<!--[if IE]> >+<style type="text/css">#selections { display: none; }</style> >+<![endif]--> > </head> > <body> > <!-- TMPL_INCLUDE NAME="header.inc" --> >@@ -81,24 +74,31 @@ > <!-- TMPL_IF name="item_loop" --> > <!-- TMPL_IF NAME="show" --><div id="toolbar"><a id="selectallbutton" href="#">Select All</a> | <a id="clearallbutton" href="#">Clear All</a></div><!-- /TMPL_IF --> > <div id="cataloguing_additem_itemlist"> >- <div style="overflow:auto"> >+ >+ <p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span> >+ <!-- TMPL_LOOP NAME="item_header_loop" --> >+ <span class="selected"><input id="checkheader<!-- TMPL_VAR NAME="__counter" -->" type="checkbox" checked="checked" /> <label for="checkheader<!-- TMPL_VAR NAME="__counter__" -->"><!-- TMPL_VAR NAME="header_value" --></label> </span> >+ <!-- /TMPL_LOOP --> >+ </p> >+ > <table id="itemst"> > <thead> > <tr> > <!-- TMPL_IF NAME="show" --><th> </th><!-- /TMPL_IF --> >- <!-- TMPL_LOOP NAME="item_header_loop" --> >+ <th>Title</th> >+ <!-- TMPL_LOOP NAME="item_header_loop" --> > <th> <!-- TMPL_VAR NAME="header_value" --> </th> >- <!-- /TMPL_LOOP --> >+ <!-- /TMPL_LOOP --> > </tr> > </thead> > <tbody> > <!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF NAME="show" --><!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF--><!--/TMPL_IF--> >+ <td><label for="row<!-- TMPL_VAR NAME="itemnumber" -->"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF --></label></td> > <!-- TMPL_LOOP NAME="item_value" --> <td><!-- TMPL_VAR ESCAPE="HTML" NAME="field" --></td> > <!-- /TMPL_LOOP --> </tr> > <!-- /TMPL_LOOP --> > </tbody> > </table> >- </div> > </div> > <!-- /TMPL_IF --> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl >index f314c7c..cdf3ef5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl >@@ -2,32 +2,26 @@ > <title>Koha › Tools › Batch item modification</title> > <!-- TMPL_INCLUDE NAME="doc-head-close.inc" --> > <!-- TMPL_INCLUDE NAME="background-job.inc" --> >-<style type="text/css"> >- #jobpanel,#jobstatus,#jobfailed { display : none; } >- #jobstatus { margin:.4em; } >- #jobprogress{ width:200px;height:10px;border:1px solid #666;background:url('/intranet-tmpl/prog/img/progress.png') -300px 0px no-repeat; } >-</style> >+<link rel="stylesheet" type="text/css" href="<!-- TMPL_VAR name="themelang" -->/css/pages/batchMod.css" /> > <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >-<script type="text/JavaScript" language="JavaScript"> >+<script src="<!-- TMPL_VAR name="themelang" -->/lib/yui/cookie/cookie-min.js"></script> >+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+<script type="text/javascript"> > //<![CDATA[ >- $(document).ready(function() { >- $("#itemst").tablesorter({ >- widgets : ['zebra'], >- headers: {0:{sorter: false}} >- }); >- $("#selectallbutton").click(function() { >- $("#itemst").find("input:checkbox").each(function() { >- $(this).attr("checked", true); >- }); >- }); >- $("#clearallbutton").click(function() { >- $("#itemst").find("input:checkbox").each(function() { >- $(this).attr("checked", false); >- }); >- }); >- }); >+ >+// Prepare array of all column headers, incrementing each index by >+// two to accomodate control and title columns >+var allColumns = new Array(<!-- TMPL_LOOP NAME="item_header_loop" -->'<!-- TMPL_VAR NAME="__counter__" -->'<!-- TMPL_UNLESS NAME="__last__" -->,<!-- /TMPL_UNLESS --><!-- /TMPL_LOOP -->); >+for( x=0; x<allColumns.length; x++ ){ >+ allColumns[x] = Number(allColumns[x]) + 2; >+} > //]]> > </script> >+<script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/js/pages/batchMod.js"></script> >+<!--[if IE]> >+<style type="text/css">#selections { display: none; }</style> >+<![endif]--> >+<link type="text/css" rel="stylesheet" href="<!-- TMPL_VAR NAME="themelang" -->/css/addbiblio.css" /> > </head> > <body> > <!-- TMPL_INCLUDE NAME="header.inc" --> >@@ -74,26 +68,30 @@ > <!-- TMPL_IF name="item_loop" --> > <!-- TMPL_IF NAME="show" --><div id="toolbar"><a id="selectallbutton" href="#">Select All</a> | <a id="clearallbutton" href="#">Clear All</a></div><!-- TMPL_ELSE --><!-- /TMPL_IF --> > <div id="cataloguing_additem_itemlist"> >- <div style="overflow:auto"> >+ >+<p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span> >+ <!-- TMPL_LOOP NAME="item_header_loop" --> >+ <span class="selected"><input id="checkheader<!-- TMPL_VAR NAME="__counter" -->" type="checkbox" checked="checked" /> <label for="checkheader<!-- TMPL_VAR NAME="__counter__" -->"><!-- TMPL_VAR NAME="header_value" --></label> </span> >+ <!-- /TMPL_LOOP --> >+</p> > <table id="itemst"> > <thead> > <tr> >- <!-- TMPL_IF NAME="show" --><th> </th><!-- /TMPL_IF --> >+ <th> </th> > <th>Title</th> >- <!-- TMPL_LOOP NAME="item_header_loop" --> >+ <!-- TMPL_LOOP NAME="item_header_loop" --> > <th> <!-- TMPL_VAR NAME="header_value" --> </th> > <!-- /TMPL_LOOP --> > </tr> > </thead> > <tbody> >- <!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF NAME="show" --><!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF--><!-- /TMPL_IF --> >- <td><!-- TMPL_VAR ESCAPE="HTML" NAME="bibinfo" --></td> >+ <!-- TMPL_LOOP NAME="item_loop" --> <tr> <!-- TMPL_IF NAME="show" --><!-- TMPL_IF Name="nomod"--> <td class="error">Cannot Edit</td><!--TMPL_ELSE--><td><input type="checkbox" name="itemnumber" value="<!--TMPL_VAR Name="itemnumber"-->" id="row<!-- TMPL_VAR NAME="itemnumber" -->" checked="checked" /></td><!--/TMPL_IF--><!--TMPL_ELSE--><td> </td><!-- /TMPL_IF --> >+ <td><label for="row<!-- TMPL_VAR NAME="itemnumber" -->"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a><!-- TMPL_IF NAME="author" -->, by <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF --></label></td> > <!-- TMPL_LOOP NAME="item_value" --> <td><!-- TMPL_VAR ESCAPE="HTML" NAME="field" --></td> > <!-- /TMPL_LOOP --> </tr> > <!-- /TMPL_LOOP --> > </tbody> > </table> >- </div> > </div> > <!-- /TMPL_IF --><!-- /item_loop --> > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index b2007bc..43e5029 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -456,8 +456,11 @@ sub BuildItemsData{ > > # grab title, author, and ISBN to identify bib that the item > # belongs to in the display >- my $biblio=GetBiblioData($$itemdata{biblionumber}); >- $this_row{bibinfo} = join("\n", @$biblio{qw(title author ISBN)}); >+ my $biblio=GetBiblioData($$itemdata{biblionumber}); >+ $this_row{title} = $biblio->{title}; >+ $this_row{author} = $biblio->{author}; >+ $this_row{isbn} = $biblio->{isbn}; >+ $this_row{biblionumber} = $biblio->{biblionumber}; > > if (%this_row) { > push(@big_array, \%this_row); >@@ -476,7 +479,11 @@ sub BuildItemsData{ > $row_data{itemnumber} = $row->{itemnumber}; > #reporting this_row values > $row_data{'nomod'} = $row->{'nomod'}; >- $row_data{bibinfo} = $row->{bibinfo}; >+ $row_data{bibinfo} = $row->{bibinfo}; >+ $row_data{author} = $row->{author}; >+ $row_data{title} = $row->{title}; >+ $row_data{isbn} = $row->{isbn}; >+ $row_data{biblionumber} = $row->{biblionumber}; > push(@item_value_loop,\%row_data); > } > my @header_loop=map { { header_value=> $witness{$_}} } @witnesscodessorted; >-- >1.7.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 5285
:
2671
| 2816 |
2865
|
2876