Bugzilla – Attachment 76941 Details for
Bug 21063
Allow columns in intranet ILL request datatable to be customisable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21063: Add ability to show / hide columns
Bug-21063-Add-ability-to-show--hide-columns.patch (text/plain), 12.50 KB, created by
Andrew Isherwood
on 2018-07-13 10:16:23 UTC
(
hide
)
Description:
Bug 21063: Add ability to show / hide columns
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2018-07-13 10:16:23 UTC
Size:
12.50 KB
patch
obsolete
>From 6f53a64ef7a71509c27bcfd2226df8f404cecfc4 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Fri, 13 Jul 2018 11:06:06 +0100 >Subject: [PATCH] Bug 21063: Add ability to show / hide columns > >This patch adds the "Column visibility" functionality to the main ILL >request list table. > >To test: >- Ensure ILL is enabled and you have some requests >- Apply patch >- From the "Koha administration screen, select "Configure columns" >- In the "Columns settings" page: > => TEST: Ensure an "Interlibrary loans" category exists > - Upon expanding the category: > => TEST: Ensure a table is displayed showing columns > => TEST: Ensure the "action" column has "Cannot be toggled" > pre-selected > => TEST: Change values for columns and ensure they're saved >- From the main staff menu, select "ILL requests" >- In the table: > => TEST: Click the "Column visibility" button and ensure a modal > containing all columns (except "Action") is displayed > => TEST: Select various columns and ensure they are shown and hidden >--- > .../prog/en/modules/ill/ill-requests.tt | 152 +++++++++------------ > 1 file changed, 68 insertions(+), 84 deletions(-) > >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 db5b77c61f..4b717dc8f4 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,7 @@ > [% USE Branches %] > [% USE Koha %] > [% USE KohaDates %] >+[% USE ColumnsSettings %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › ILL requests ›</title> >@@ -9,61 +10,26 @@ > [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] > [% Asset.css("css/datatables.css") %] > [% INCLUDE 'datatables.inc' %] >+[% INCLUDE 'columns_settings.inc' %] > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { > > // Illview Datatable setup > >- // Fields we don't want to display >- var ignore = [ >- 'accessurl', >- 'backend', >- 'branchcode', >- 'completed', >- 'capabilities', >- 'cost', >- 'medium', >- 'notesopac', >- 'notesstaff', >- 'placed', >- 'replied' >- ]; >+ var columns_settings = [% ColumnsSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %]; > > // Fields we need to expand (flatten) > var expand = [ > 'metadata', >- 'patron' >+ 'patron', >+ 'library' > ]; > > // Expanded fields > // This is auto populated > var expanded = {}; > >- // The core fields that should be displayed first >- var core = [ >- 'metadata_Author', >- 'metadata_Title', >- 'borrowername', >- 'biblio_id', >- 'library', >- 'status', >- 'updated', >- 'illrequest_id', >- 'action' >- ]; >- >- // Remove any fields we're ignoring >- var removeIgnore = function(dataObj) { >- dataObj.forEach(function(thisRow) { >- ignore.forEach(function(thisIgnore) { >- if (thisRow.hasOwnProperty(thisIgnore)) { >- delete thisRow[thisIgnore]; >- } >- }); >- }); >- }; >- > // Expand any fields we're expanding > var expandExpand = function(row) { > expand.forEach(function(thisExpand) { >@@ -74,7 +40,7 @@ > var expandObj = row[thisExpand]; > Object.keys(expandObj).forEach( > function(thisExpandCol) { >- var expColName = thisExpand + '_' + thisExpandCol; >+ var expColName = thisExpand + '_' + thisExpandCol.replace(/\s/g,'_'); > // Keep a list of fields that have been expanded > // so we can create toggle links for them > if (expanded[thisExpand].indexOf(expColName) == -1) { >@@ -91,12 +57,6 @@ > }); > }; > >- // Build a de-duped list of all column names >- var allCols = {}; >- core.map(function(thisCore) { >- allCols[thisCore] = 1; >- }); >- > // Strip the expand prefix if it exists, we do this for display > var stripPrefix = function(value) { > expand.forEach(function(thisExpand) { >@@ -112,19 +72,27 @@ > 'href="/cgi-bin/koha/members/moremember.pl?' + > 'borrowernumber='+row.borrowernumber+'">' + > row.patron_firstname + ' ' + row.patron_surname + >+ ' [' + row.patron_cardnumber + ' ]' > '</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; > }; > >+ // Render function for type >+ var createType = function(data, type, row) { >+ if (!row.hasOwnProperty('metadata_Type') || !row.metadata_Type) { >+ if (row.hasOwnProperty('medium') && row.medium) { >+ row.metadata_Type = row.medium; >+ } else { >+ row.metadata_Type = null; >+ } >+ } >+ return row.metadata_Type; >+ }; >+ > // Render function for request status > var createStatus = function(data, type, row, meta) { > var origData = meta.settings.oInit.originalData; >@@ -169,27 +137,22 @@ > // Columns that require special treatment > var specialCols = { > action: { >- name: '', > func: createActionLink > }, >- borrowername: { >- name: _("Patron"), >+ borrowernumber: { > func: createPatronLink > }, > illrequest_id: { >- name: _("Request number"), > func: createRequestId > }, > status: { >- name: _("Status"), > func: createStatus > }, >- biblio_id: { >- name: _("Biblio ID") >+ metadata_Medium: { >+ func: createType > }, >- library: { >- name: _("Library"), >- func: createLibrary >+ metadata_Type: { >+ func: createType > } > }; > >@@ -225,8 +188,6 @@ > // Make a copy, we'll be removing columns next and need > // to be able to refer to data that has been removed > var dataCopy = $.extend(true, [], data); >- // Remove all columns we're not interested in >- removeIgnore(dataCopy); > // Expand columns that need it and create an array > // of all column names > $.each(dataCopy, function(k, row) { >@@ -236,27 +197,35 @@ > // Assemble an array of column definitions for passing > // to datatables > var colData = []; >- Object.keys(allCols).forEach(function(thisCol) { >+ columns_settings.forEach(function(thisCol) { >+ var colName = thisCol.columnname; > // Create the base column object >- var colObj = { >- name: thisCol, >- className: thisCol >- }; >+ var colObj = $.extend({}, thisCol); >+ colObj.name = colName; >+ colObj.className = colName; > // We may need to process the data going in this > // column, so do it if necessary > if ( >- specialCols.hasOwnProperty(thisCol) && >- specialCols[thisCol].hasOwnProperty('func') >+ specialCols.hasOwnProperty(colName) && >+ specialCols[colName].hasOwnProperty('func') > ) { >- colObj.render = specialCols[thisCol].func; >+ colObj.render = specialCols[colName].func; > } else { >- colObj.data = thisCol; >+ colObj.data = colName; > } >+ // Make sure properties that aren't present in the API >+ // response are populated with null to avoid Datatables >+ // choking on their absence >+ dataCopy.forEach(function(thisData) { >+ if (!thisData.hasOwnProperty(colName)) { >+ thisData[colName] = null; >+ } >+ }); > colData.push(colObj); > }); > > // Initialise the datatable >- $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { >+ var illTable = KohaTable("ill-requests", { > 'aoColumnDefs': [ // Last column shouldn't be sortable or searchable > { > 'aTargets': [ 'actions' ], >@@ -264,7 +233,7 @@ > 'bSearchable': false > }, > ], >- 'aaSorting': [[ 6, 'desc' ]], // Default sort, updated descending >+ 'aaSorting': [[ 7, 'desc' ]], // Default sort, updated descending > 'processing': true, // Display a message when manipulating > 'iDisplayLength': 10, // 10 results per page > 'sPaginationType': "full_numbers", // Pagination display >@@ -273,7 +242,7 @@ > 'columns': colData, > 'originalData': data // Enable render functions to access > // our original data >- })); >+ }, columns_settings); > } > ); > >@@ -602,15 +571,30 @@ > <table id="ill-requests"> > <thead> > <tr id="illview-header"> >- <th>Author</th> >- <th>Title</th> >- <th>Patron</th> >- <th>Biblio ID</th> >- <th>Library</th> >- <th>Status</th> >- <th>Updated on</th> >- <th>Request number</th> >- <th class="actions"></th> >+ <th scope="col">Request ID</th> >+ <th scope="col">Patron</th> >+ <th scope="col">Biblio ID</th> >+ <th scope="col">Branch</th> >+ <th scope="col">Status</th> >+ <th scope="col">Placed on</th> >+ <th scope="col">Replied</th> >+ <th scope="col" class="updated">Updated on</th> >+ <th scope="col">Completed on</th> >+ <th scope="col">Access URL</th> >+ <th scope="col">Cost</th> >+ <th scope="col">OPAC notes</th> >+ <th scope="col">Staff notes</th> >+ <th scope="col">Order ID</th> >+ <th scope="col">Backend</th> >+ <th scope="col">Author</th> >+ <th scope="col">Title</th> >+ <th scope="col">Issue</th> >+ <th scope="col">Volume</th> >+ <th scope="col">Year</th> >+ <th scope="col">Pages</th> >+ <th scope="col">Article title</th> >+ <th scope="col">Type</th> >+ <th scope="col" class="actions"></th> > </tr> > </thead> > <tbody id="illview-body"> >-- >2.11.0
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 21063
:
76940
|
76941
|
76942
|
76943
|
79559
|
79560
|
80690
|
80691
|
80802
|
80841
|
82153
|
82154
|
82155
|
82156
|
82504
|
82505
|
82506
|
82507
|
84405
|
84786
|
84787
|
84788
|
84789
|
84790
|
84862
|
85854
|
85855
|
85869
|
85889
|
85893
|
85894
|
85895
|
85896
|
86060
|
86092
|
86093
|
86094
|
86095
|
86096
|
86097
|
86098
|
86099
|
86100
|
86101
|
86102
|
86103
|
86104
|
86105
|
86106
|
86235