Bugzilla – Attachment 69045 Details for
Bug 7317
Add an Interlibrary Loan Module to Circulation and OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7317: (followup) Remove extra columns from backends on the main list
Bug-7317-followup-Remove-extra-columns-from-backen.patch (text/plain), 15.13 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-11-08 19:33:52 UTC
(
hide
)
Description:
Bug 7317: (followup) Remove extra columns from backends on the main list
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-11-08 19:33:52 UTC
Size:
15.13 KB
patch
obsolete
>From 26e17897d707425e41d017b1149c3638fad8c313 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 8 Nov 2017 16:12:35 -0300 >Subject: [PATCH] Bug 7317: (followup) Remove extra columns from backends on > the main list > >This patch removes the extra columns functionality, simplifying the code. >It removes redundant code (in both Perl and JS), unused vars. > >It removes the use of here_link and hardcodes the script path on the template. > >It also adjusts the AJAX call so it uses the 'library' param instead of 'branch'. > >The library column now displays the library name instead of the ID. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > ill/ill-requests.pl | 9 +- > .../prog/en/modules/ill/ill-requests.tt | 189 ++++++--------------- > 2 files changed, 50 insertions(+), 148 deletions(-) > >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index 6d375125b4..034ce02939 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -217,12 +217,6 @@ if ( $backends_available ) { > exit; > }; > } elsif ( $op eq 'illlist') { >- # Display all current ILLs >- my $requests = $illRequests->search(); >- >- $template->param( >- requests => $requests >- ); > > # If we receive a pre-filter, make it available to the template > my $possible_filters = ['borrowernumber']; >@@ -255,8 +249,7 @@ $template->param( > backends => $backends, > media => [ "Book", "Article", "Journal" ], > query_type => $op, >- branches => Koha::Libraries->search, >- here_link => "/cgi-bin/koha/ill/ill-requests.pl" >+ branches => Koha::Libraries->search > ); > > output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >index 1613637e99..2fcb424c82 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >@@ -2,6 +2,21 @@ > [% USE Koha %] > [% USE KohaDates %] > >+[% columns = [ 'metadata_Author', 'metadata_Title', 'borrowername', 'biblio_id', 'library', 'status', 'updated', 'illrequest_id', 'action' ] %] >+ >+[% BLOCK translate_column %] >+[%- SWITCH column -%] >+[%- CASE 'metadata_Author' -%]Author >+[%- CASE 'metadata_Title' -%]Title >+[%- CASE 'borrowername' -%]Patron >+[%- CASE 'biblio_id' -%]Biblio ID >+[%- CASE 'library' -%]Library >+[%- CASE 'status' -%]Status >+[%- CASE 'updated' -%]Updated on >+[%- CASE 'illrequest_id' -%]Request number >+[%- END -%] >+[% END %] >+ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › ILL requests ›</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -18,8 +33,8 @@ > var ignore = [ > 'accessurl', > 'backend', >+ 'branchcode', > 'completed', >- 'branch', > 'capabilities', > 'cost', > 'medium', >@@ -45,7 +60,7 @@ > 'metadata_Title', > 'borrowername', > 'biblio_id', >- 'branchcode', >+ 'library', > 'status', > 'updated', > 'illrequest_id', >@@ -98,23 +113,6 @@ > core.map(function(thisCore) { > allCols[thisCore] = 1; > }); >- var unionColumns = function(row) { >- Object.keys(row).forEach(function(col) { >- if (ignore.indexOf(col) == -1) { >- allCols[col] = 1; >- } >- }); >- }; >- >- // Some rows may not have fields that other rows have, >- // so make sure all rows have the same fields >- var fillMissing = function(row) { >- Object.keys(allCols).forEach(function(thisCol) { >- row[thisCol] = (!row.hasOwnProperty(thisCol)) ? >- null : >- row[thisCol]; >- }); >- }; > > // Strip the expand prefix if it exists, we do this for display > var stripPrefix = function(value) { >@@ -134,6 +132,11 @@ > '</a>'; > }; > >+ // Our 'render' function for the library name >+ var createLibrary = function(data, type, row) { >+ return row.library.branchname; >+ }; >+ > // Render function for request ID > var createRequestId = function(data, type, row) { > return row.id_prefix + row.illrequest_id; >@@ -149,28 +152,20 @@ > switch( status_name ) { > case "New request": > return _("New request"); >- break; > case "Requested": > return _("Requested"); >- break; > case "Requested from partners": > return _("Requested from partners"); >- break; > case "Request reverted": > return _("Request reverted"); >- break; > case "Queued request": > return _("Queued request"); >- break; > case "Cancellation requested": > return _("Cancellation requested"); >- break; > case "Completed": > return _("Completed"); >- break; > case "Delete request": > return _("Delete request"); >- break; > default: > return status_name; > } >@@ -209,19 +204,12 @@ > biblio_id: { > name: _("Biblio ID") > }, >- branchcode: { >- name: _("Library") >+ library: { >+ name: _("Library"), >+ func: createLibrary > } > }; > >- // Helper for handling prefilter column names >- function toColumnName(myVal) { >- return myVal >- .replace(/^filter/, '') >- .replace(/([A-Z])/g, "_$1") >- .replace(/^_/,'').toLowerCase(); >- } >- > // Toggle request attributes in Illview > $('#toggle_requestattributes').on('click', function(e) { > e.preventDefault(); >@@ -248,7 +236,7 @@ > // Get our data from the API and process it prior to passing > // it to datatables > var ajax = $.ajax( >- '/api/v1/illrequests?embed=metadata,patron,capabilities,branch' >+ '/api/v1/illrequests?embed=metadata,patron,capabilities,library' > ).done(function() { > var data = JSON.parse(ajax.responseText); > // Make a copy, we'll be removing columns next and need >@@ -260,34 +248,19 @@ > // of all column names > $.each(dataCopy, function(k, row) { > expandExpand(row); >- unionColumns(row); > }); >+ > // Append any extra columns we need to tag on > if (extra.length > 0) { > extra.forEach(function(thisExtra) { > allCols[thisExtra] = 1; > }); > } >- // Different requests will have different columns, >- // make sure they all have the same >- $.each(dataCopy, function(k, row) { >- fillMissing(row); >- }); > > // Assemble an array of column definitions for passing > // to datatables > var colData = []; > Object.keys(allCols).forEach(function(thisCol) { >- // We may have defined a pretty name for this column >- var colName = ( >- specialCols.hasOwnProperty(thisCol) && >- specialCols[thisCol].hasOwnProperty('name') >- ) ? >- specialCols[thisCol].name : >- thisCol; >- // Create the table header for this column >- var str = '<th>' + stripPrefix(colName) + '</th>'; >- $(str).appendTo('#illview-header'); > // Create the base column object > var colObj = { > name: thisCol, >@@ -306,84 +279,25 @@ > colData.push(colObj); > }); > >- // Create the toggle links for all metadata fields >- var links = []; >- expanded.metadata.forEach(function(thisExpanded) { >- if (core.indexOf(thisExpanded) == -1) { >- links.push( >- '<a href="#" class="toggle-vis" data-column="' + >- thisExpanded + '">' + stripPrefix(thisExpanded) + >- '</a>' >- ); >- } >- }); >- $('#column-toggle').append(links.join(' | ')); >- > // Initialise the datatable >- var myTable = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { >- aoColumnDefs: [ // Last column shouldn't be sortable or searchable >+ $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { >+ 'aoColumnDefs': [ // Last column shouldn't be sortable or searchable > { >- aTargets: [ 'action' ], >- bSortable: false, >- bSearchable: false >+ 'aTargets': [ 'action' ], >+ 'bSortable': false, >+ 'bSearchable': false > }, > ], >- aaSorting: [[ 6, 'desc' ]], // Default sort, updated descending >- processing: true, // Display a message when manipulating >- language: { >- loadingRecords: "Please wait - loading requests...", >- zeroRecords: "No requests were found" >- }, >- iDisplayLength: 10, // 10 results per page >- sPaginationType: "full_numbers", // Pagination display >- deferRender: true, // Improve performance on big datasets >- data: dataCopy, >- columns: colData, >- originalData: data // Enable render functions to access >+ 'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending >+ 'processing': true, // Display a message when manipulating >+ 'iDisplayLength': 10, // 10 results per page >+ 'sPaginationType': "full_numbers", // Pagination display >+ 'deferRender': true, // Improve performance on big datasets >+ 'data': dataCopy, >+ 'columns': colData, >+ 'originalData': data // Enable render functions to access > // our original data > })); >- >- // Reset columns to default >- var resetColumns = function() { >- Object.keys(allCols).forEach(function(thisCol) { >- myTable.column(thisCol + ':name').visible(core.indexOf(thisCol) != -1); >- }); >- myTable.columns.adjust().draw(false); >- }; >- >- // Handle the click event on a toggle link >- $('a.toggle-vis').on('click', function(e) { >- e.preventDefault(); >- var column = myTable.column( >- $(this).data('column') + ':name' >- ); >- column.visible(!column.visible()); >- }); >- >- // Reset column toggling >- $('#reset-toggle').click(function() { >- resetColumns(); >- }); >- >- // Handle a prefilter request and do the prefiltering >- var filters = $('#ill-requests').data(); >- if (typeof filters !== 'undefined') { >- var filterNames = Object.keys(filters).filter( >- function(thisData) { >- return thisData.match(/^filter/); >- } >- ); >- filterNames.forEach(function(thisFilter) { >- var filterName = toColumnName(thisFilter) + ':name'; >- var regex = '^'+filters[thisFilter]+'$'; >- myTable.columns(filterName).search(regex, true, false); >- }); >- myTable.draw(); >- } >- >- // Initialise column hiding >- resetColumns(); >- > } > ); > >@@ -464,8 +378,8 @@ > [% END %] > <!-- Start of GENERIC_EMAIL case --> > [% IF whole.value.partners %] >- [% ill_url = here_link _ "?method=illview&illrequest_id=" _ request.illrequest_id %] >- <form method="POST" action=[% here_link %]> >+ [% ill_url = "/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=" _ request.illrequest_id %] >+ <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl"> > <fieldset class="rows"> > <legend>Interlibrary loan request details</legend> > <ol> >@@ -516,7 +430,7 @@ > <!-- generic_confirm ends here --> > > [% ELSIF query_type == 'edit_action' %] >- <form method="POST" action=[% here_link %]> >+ <form method="POST" action="/cgi-bin/koha/ill/ill-requests.pl"> > <fieldset class="rows"> > <legend>Request details</legend> > <ol> >@@ -700,18 +614,13 @@ > <div id="results"> > <h3>Details for all requests</h3> > >- <div id="column-toggle"> >- Toggle additional columns: >- </div> >- <div id="reset-toggle"><a href="#">Reset toggled columns</a></div> >- >- <table >- [% FOREACH filter IN prefilters %] >- data-filter-[% filter.name %]="[% filter.value %]" >- [% END %] >- id="ill-requests"> >+ <table id="ill-requests"> > <thead> >- <tr id="illview-header"></tr> >+ <tr id="illview-header"> >+ [% FOR column IN columns %] >+ <th>[% PROCESS translate_column column=column %]</th> >+ [% END %] >+ </tr> > </thead> > <tbody id="illview-body"> > </tbody> >-- >2.14.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 7317
:
59893
|
59894
|
59895
|
59920
|
60485
|
60486
|
60487
|
60488
|
63081
|
63082
|
63083
|
63084
|
63085
|
63086
|
63087
|
63088
|
63089
|
63090
|
63113
|
63175
|
63176
|
63354
|
63421
|
63472
|
63475
|
65469
|
65470
|
65471
|
65472
|
65473
|
65474
|
65475
|
65476
|
66266
|
67242
|
67243
|
67244
|
67245
|
67246
|
67247
|
67248
|
67249
|
67250
|
67251
|
67252
|
67253
|
67254
|
67255
|
67256
|
67257
|
67258
|
67259
|
67260
|
67261
|
67262
|
67263
|
67264
|
67281
|
67282
|
67283
|
67284
|
67285
|
67286
|
67287
|
67288
|
67289
|
67290
|
67291
|
67292
|
67293
|
67294
|
67295
|
67296
|
67297
|
67298
|
67299
|
67300
|
67301
|
67302
|
67303
|
68185
|
68186
|
68328
|
68391
|
68406
|
68407
|
68408
|
68409
|
68418
|
68444
|
68445
|
68483
|
68484
|
68485
|
68487
|
68516
|
68517
|
68518
|
68519
|
68520
|
68521
|
68522
|
68523
|
68524
|
68525
|
68542
|
68543
|
68544
|
68545
|
68546
|
68547
|
68548
|
68549
|
68550
|
68551
|
68552
|
68558
|
68559
|
68560
|
68561
|
68562
|
68563
|
68564
|
68565
|
68566
|
68567
|
68858
|
68874
|
68877
|
68878
|
68885
|
68886
|
68921
|
68922
|
68926
|
68927
|
68928
|
68929
|
68931
|
68932
|
68933
|
68988
|
68989
|
68999
|
69000
|
69006
|
69008
|
69009
|
69012
|
69014
|
69044
| 69045 |
69046
|
69056
|
69059
|
69060
|
69061
|
69063
|
69064
|
69065
|
69066
|
69069
|
69070
|
69071
|
69074