Bugzilla – Attachment 94744 Details for
Bug 23529
Interlibrary loan javascript is broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23529: Narrow scope of changed
Bug-23529-Narrow-scope-of-changed.patch (text/plain), 14.76 KB, created by
Nick Clemens (kidclamp)
on 2019-10-25 11:32:41 UTC
(
hide
)
Description:
Bug 23529: Narrow scope of changed
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-10-25 11:32:41 UTC
Size:
14.76 KB
patch
obsolete
>From 4af7e206d7ab45ac89cf9a44b3e985254d38fd5e Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Mon, 2 Sep 2019 09:29:14 +0100 >Subject: [PATCH] Bug 23529: Narrow scope of changed > >Whilst working on something else, it came to light that the previous fix >in bug 23229 was waaaaay too heavy handed and basically kills all ILL >related JS :( This is obviously a big problem, this patch fixes that. > >The main problem is that all the ILL related JS is in a single file, >which isn't ideal as bits of it are used on different pages. Ideally, >we'd refactor it out into more manageable chunks which can be included >as required. Until such a time, this patch will do, it just prevents the >"get all requests" AJAX request unless you're on the ILL list page. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../prog/en/modules/ill/ill-requests.tt | 6 +- > koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js | 253 +++++++++++---------- > 2 files changed, 130 insertions(+), 129 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 2fa9c02017..a39b93c235 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 >@@ -540,10 +540,8 @@ > // Set column settings > var columns_settings = [% ColumnsSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %]; > </script> >- [% IF query_type == 'illlist' %] >- [% INCLUDE 'ill-list-table-strings.inc' %] >- [% Asset.js("js/ill-list-table.js") | $raw %] >- [% END %] >+ [% INCLUDE 'ill-list-table-strings.inc' %] >+ [% Asset.js("js/ill-list-table.js") | $raw %] > [% END %] > > [% TRY %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >index 53ae1b23f8..0c97ecea6d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >@@ -362,140 +362,143 @@ $(document).ready(function() { > // Get our data from the API and process it prior to passing > // it to datatables > var filterParam = prefilters ? '&' + prefilters : ''; >- var ajax = $.ajax( >- '/api/v1/illrequests?embed=metadata,patron,capabilities,library,status_alias,comments,requested_partners' >- + filterParam >- ).done(function() { >- var data = JSON.parse(ajax.responseText); >- // 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); >- // Expand columns that need it and create an array >- // of all column names >- $.each(dataCopy, function(k, row) { >- expandExpand(row); >- }); >- >- // Assemble an array of column definitions for passing >- // to datatables >- var colData = []; >- columns_settings.forEach(function(thisCol) { >- var colName = thisCol.columnname; >- // Create the base column object >- var colObj = $.extend({}, thisCol); >- colObj.name = colName; >- colObj.className = colName; >- colObj.defaultContent = ''; >- >- // We may need to process the data going in this >- // column, so do it if necessary >- if ( >- specialCols.hasOwnProperty(colName) && >- specialCols[colName].hasOwnProperty('func') >- ) { >- var renderArray = [ >- specialCols[colName].func >- ]; >- if (!specialCols[colName].skipSanitize) { >- renderArray.push( >- $.fn.dataTable.render.text() >- ); >- } >+ // Only fire the request if we're on the ILL list page >+ if (window.location.search.length == 0) {} >+ var ajax = $.ajax( >+ '/api/v1/illrequests?embed=metadata,patron,capabilities,library,status_alias,comments,requested_partners' >+ + filterParam >+ ).done(function() { >+ var data = JSON.parse(ajax.responseText); >+ // 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); >+ // Expand columns that need it and create an array >+ // of all column names >+ $.each(dataCopy, function(k, row) { >+ expandExpand(row); >+ }); > >- colObj.render = $.fn.dataTable.render.multi( >- renderArray >- ); >- } else { >- colObj.data = colName; >- colObj.render = $.fn.dataTable.render.text() >- } >- // 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; >+ // Assemble an array of column definitions for passing >+ // to datatables >+ var colData = []; >+ columns_settings.forEach(function(thisCol) { >+ var colName = thisCol.columnname; >+ // Create the base column object >+ var colObj = $.extend({}, thisCol); >+ colObj.name = colName; >+ colObj.className = colName; >+ colObj.defaultContent = ''; >+ >+ // We may need to process the data going in this >+ // column, so do it if necessary >+ if ( >+ specialCols.hasOwnProperty(colName) && >+ specialCols[colName].hasOwnProperty('func') >+ ) { >+ var renderArray = [ >+ specialCols[colName].func >+ ]; >+ if (!specialCols[colName].skipSanitize) { >+ renderArray.push( >+ $.fn.dataTable.render.text() >+ ); >+ } >+ >+ colObj.render = $.fn.dataTable.render.multi( >+ renderArray >+ ); >+ } else { >+ colObj.data = colName; >+ colObj.render = $.fn.dataTable.render.text() > } >+ // 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); > }); >- colData.push(colObj); >- }); >- >- // Initialise the datatable >- table = KohaTable("ill-requests", { >- 'aoColumnDefs': [ >- { // Last column shouldn't be sortable or searchable >- 'aTargets': [ 'actions' ], >- 'bSortable': false, >- 'bSearchable': false >- }, >- { // When sorting 'placed', we want to use the >- // unformatted column >- 'aTargets': [ 'placed_formatted'], >- 'iDataSort': 14 >- }, >- { // When sorting 'updated', we want to use the >- // unformatted column >- 'aTargets': [ 'updated_formatted'], >- 'iDataSort': 16 >- }, >- { // When sorting 'completed', we want to use the >- // unformatted column >- 'aTargets': [ 'completed_formatted'], >- 'iDataSort': 19 >- } >- ], >- 'aaSorting': [[ 16, 'desc' ]], // Default sort, updated descending >- 'processing': true, // Display a message when manipulating >- '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 >- 'initComplete': function() { >- >- // Prepare any filter elements that need it >- for (var el in filterable) { >- if (filterable.hasOwnProperty(el)) { >- if (filterable[el].hasOwnProperty('prep')) { >- filterable[el].prep(dataCopy, data); >- } >- if (filterable[el].hasOwnProperty('listener')) { >- filterable[el].listener(); >+ >+ // Initialise the datatable >+ table = KohaTable("ill-requests", { >+ 'aoColumnDefs': [ >+ { // Last column shouldn't be sortable or searchable >+ 'aTargets': [ 'actions' ], >+ 'bSortable': false, >+ 'bSearchable': false >+ }, >+ { // When sorting 'placed', we want to use the >+ // unformatted column >+ 'aTargets': [ 'placed_formatted'], >+ 'iDataSort': 14 >+ }, >+ { // When sorting 'updated', we want to use the >+ // unformatted column >+ 'aTargets': [ 'updated_formatted'], >+ 'iDataSort': 16 >+ }, >+ { // When sorting 'completed', we want to use the >+ // unformatted column >+ 'aTargets': [ 'completed_formatted'], >+ 'iDataSort': 19 >+ } >+ ], >+ 'aaSorting': [[ 16, 'desc' ]], // Default sort, updated descending >+ 'processing': true, // Display a message when manipulating >+ '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 >+ 'initComplete': function() { >+ >+ // Prepare any filter elements that need it >+ for (var el in filterable) { >+ if (filterable.hasOwnProperty(el)) { >+ if (filterable[el].hasOwnProperty('prep')) { >+ filterable[el].prep(dataCopy, data); >+ } >+ if (filterable[el].hasOwnProperty('listener')) { >+ filterable[el].listener(); >+ } > } > } >- } > >- } >- }, columns_settings); >- >- // Custom date range filtering >- $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { >- var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate'); >- var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate'); >- var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate'); >- var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate'); >- var rowPlaced = data[14] ? new Date(data[14]) : null; >- var rowModified = data[16] ? new Date(data[16]) : null; >- var placedPassed = true; >- var modifiedPassed = true; >- if (placedStart && rowPlaced && rowPlaced < placedStart) { >- placedPassed = false >- }; >- if (placedEnd && rowPlaced && rowPlaced > placedEnd) { >- placedPassed = false; >- } >- if (modifiedStart && rowModified && rowModified < modifiedStart) { >- modifiedPassed = false >- }; >- if (modifiedEnd && rowModified && rowModified > modifiedEnd) { >- modifiedPassed = false; >- } >+ } >+ }, columns_settings); >+ >+ // Custom date range filtering >+ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { >+ var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate'); >+ var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate'); >+ var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate'); >+ var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate'); >+ var rowPlaced = data[14] ? new Date(data[14]) : null; >+ var rowModified = data[16] ? new Date(data[16]) : null; >+ var placedPassed = true; >+ var modifiedPassed = true; >+ if (placedStart && rowPlaced && rowPlaced < placedStart) { >+ placedPassed = false >+ }; >+ if (placedEnd && rowPlaced && rowPlaced > placedEnd) { >+ placedPassed = false; >+ } >+ if (modifiedStart && rowModified && rowModified < modifiedStart) { >+ modifiedPassed = false >+ }; >+ if (modifiedEnd && rowModified && rowModified > modifiedEnd) { >+ modifiedPassed = false; >+ } > >- return placedPassed && modifiedPassed; >+ return placedPassed && modifiedPassed; > >- }); >+ }); > >+ } > } > ); > >-- >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 23529
:
92533
|
92545
|
94657
| 94744 |
94745
|
94746