Bugzilla – Attachment 86093 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), 14.43 KB, created by
Josef Moravec
on 2019-03-05 16:58:59 UTC
(
hide
)
Description:
Bug 21063: Add ability to show / hide columns
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-03-05 16:58:59 UTC
Size:
14.43 KB
patch
obsolete
>From 4fda1ddd0f98905fd738ffdf1057bccf8e7ac0a3 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 > >Signed-off-by: Niamh.Walker-Headon@it-tallaght.ie > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > .../prog/en/modules/ill/ill-requests.tt | 173 ++++++++++----------- > 1 file changed, 81 insertions(+), 92 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 18e7820..bef965c 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 >@@ -5,6 +5,7 @@ > [% USE KohaDates %] > [% SET footerjs = 1 %] > [% USE AuthorisedValues %] >+[% USE ColumnsSettings %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › ILL requests</title> >@@ -507,20 +508,33 @@ > <table id="ill-requests"> > <thead> > <tr id="illview-header"> >- <th>Author</th> >- <th>Title</th> >- <th>Patron</th> >- <th>Bibliographic record ID</th> >- <th>Library</th> >- <th>Status</th> >- <th class="placed"> </th> >- <th class="placed_formatted">Date placed</th> >- <th class="updated"> </th> >- <th class="updated_formatted">Updated on</th> >- <th>Request number</th> >- <th>Comments</th> >- <th class="patron_cardnumber">Cardnumber</th> >- <th class="actions"></th> >+ <th scope="col">Request ID</th> >+ <th scope="col">Author</th> >+ <th scope="col">Title</th> >+ <th scope="col">Article 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">Type</th> >+ <th scope="col">Order ID</th> >+ <th scope="col">Biblio ID</th> >+ <th scope="col">Patron</th> >+ <th class="patron_cardnumber">Patron barcode</th> >+ <th scope="col">Branch</th> >+ <th scope="col">Status</th> >+ <th scope="col" class="placed"> </th> >+ <th scope="col" class="placed_formatted">Placed on</th> >+ <th scope="col">Replied</th> >+ <th scope="col" class="updated"> </th> >+ <th scope="col" class="updated_formatted">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">Backend</th> >+ <th scope="col" class="actions"></th> > </tr> > </thead> > <tbody id="illview-body"> >@@ -544,6 +558,7 @@ > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'datatables.inc' %] >+ [% INCLUDE 'columns_settings.inc' %] > [% INCLUDE 'calendar.inc' %] > [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] > <script> >@@ -551,53 +566,24 @@ > > // Illview Datatable setup > >+ var columns_settings = [% ColumnsSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %]; >+ > var table; > > // Filters that are active > var activeFilters = {}; > >- // Fields we don't want to display >- var ignore = [ >- 'accessurl', >- 'backend', >- 'branchcode', >- 'completed', >- 'capabilities', >- 'cost', >- 'medium', >- 'notesopac', >- 'notesstaff', >- 'replied' >- ]; >- > // 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', >- 'placed', >- 'placed_formatted', >- 'updated', >- 'updated_formatted', >- 'illrequest_id', >- 'comments', >- 'patron_cardnumber', >- 'action' >- ]; >- > // Filterable columns > var filterable = { > status: { >@@ -704,17 +690,6 @@ > } > }; > >- // 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) { >@@ -725,7 +700,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) { >@@ -742,12 +717,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) { >@@ -765,13 +734,19 @@ > if ( row.patron_firstname ) { > patronLink = patronLink + row.patron_firstname + ' '; > } >- patronLink = patronLink + row.patron_surname + '</a>'; >+ patronLink = patronLink + row.patron_surname + >+ ' [' + row.patron_cardnumber + ' ]</a>'; > return patronLink; > }; > >- // Our 'render' function for the library name >- var createLibrary = function(data, type, row) { >- return row.library.branchname; >+ // Our 'render' function for biblio_id >+ var createBiblioLink = function(data, type, row) { >+ return (row.biblio_id) ? >+ '<a title="' + _("View biblio details") + '" ' + >+ 'href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + >+ row.biblio_id + '">' + >+ row.biblio_id + >+ '</a>' : ''; > }; > > // Render function for request ID >@@ -779,6 +754,18 @@ > 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) { > if (row.status_alias) { >@@ -833,27 +820,23 @@ > // 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") >+ name: _("Bibliograpic record ID"), >+ func: createBiblioLink > }, >- library: { >- name: _("Library"), >- func: createLibrary >+ metadata_Type: { >+ func: createType > }, > updated: { > name: _("Updated on"), >@@ -913,8 +896,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) { >@@ -924,28 +905,36 @@ > // 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, >- defaultContent: '' >- }; >+ 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 >- table = $('#ill-requests').DataTable($.extend(true, {}, dataTablesDefaults, { >+ var illTable = KohaTable("ill-requests", { > 'aoColumnDefs': [ > { // Last column shouldn't be sortable or searchable > 'aTargets': [ 'actions' ], >@@ -996,7 +985,7 @@ > } > > } >- })); >+ }, columns_settings); > > // Custom date range filtering > $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { >-- >2.1.4
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