Bugzilla – Attachment 153494 Details for
Bug 34282
ILL batches - availability checking has issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34282: Fix availability check in ILL batches
Bug-34282-Fix-availability-check-in-ILL-batches.patch (text/plain), 8.58 KB, created by
Pedro Amorim
on 2023-07-14 15:47:19 UTC
(
hide
)
Description:
Bug 34282: Fix availability check in ILL batches
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-07-14 15:47:19 UTC
Size:
8.58 KB
patch
obsolete
>From 5f288af84f2abcb8e7076e4ef81338fdf6e08650 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 14 Jul 2023 15:46:56 +0000 >Subject: [PATCH] Bug 34282: Fix availability check in ILL batches > >Staging modal area had issues listing availability checks for each request in the batch creation process > >To test: >1) Run bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev-plus.sh) >2) Install a metadata enrichment plugin, e.g. https://github.com/PTFS-Europe/koha-plugin-api-pubmed/releases >3) Install and configure an availability plugin, e.g. eds https://github.com/PTFS-Europe/koha-plugin-ill-avail-eds/releases >4) Enable ILLCheckAvailability sys pref >5) Create a new ILL batch and input some pubmedids, i.e. 34898594, 31452466 >6) Verify that the availability results show and are working, for each request in the batch >--- > ill/ill-requests.pl | 7 +- > .../prog/en/includes/ill-batch-modal.inc | 3 + > .../prog/en/modules/ill/ill-requests.tt | 1 + > .../intranet-tmpl/prog/js/ill-batch-modal.js | 71 +++++++++++++------ > 4 files changed, 55 insertions(+), 27 deletions(-) > >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index c10bfa5caf..a1842fec4e 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -323,6 +323,7 @@ if ( $backends_available ) { > # Prepare availability searching, if required > # Get the definition for the z39.50 plugin > if ( C4::Context->preference('ILLCheckAvailability') ) { >+ # FIXME: the below get_services call is bugged, needs to be updated > my $availability = Koha::Illrequest::Workflow::Availability->new($request->metadata); > my $services = $availability->get_services({ > ui_context => 'partners', >@@ -553,8 +554,6 @@ sub get_ill_availability { > } > } > >- my $availability = Koha::Illrequest::Workflow::Availability->new($id_types); >- return $availability->get_services({ >- ui_context => 'staff' >- }); >+ my $availability = Koha::Illrequest::Workflow::Availability->new($id_types, 'staff'); >+ return $availability->get_services(); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc >index 72903bb48d..9d60711576 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc >@@ -72,6 +72,9 @@ > <th scope="col">Metadata</th> > <th scope="col">Request ID</th> > <th scope="col">Request Status</th> >+ [% IF Koha.Preference('ILLCheckAvailability') %] >+ <th scope="col">Availability</th> >+ [% END %] > <th scope="col"></th> > </tr> > </thead> >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 e2af162d83..faa9343030 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 >@@ -909,6 +909,7 @@ > [% INCLUDE 'select2.inc' %] > [% IF metadata_enrichment_services %] > <script> >+ var ill_check_availability_syspref = '[% Koha.Preference('ILLCheckAvailability') | html %]'; > var metadata_enrichment_services = [% metadata_enrichment_services | $raw %]; > </script> > <script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js >index 9a913a9ee2..20d54781bc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js >@@ -86,7 +86,9 @@ > updateTable(); > updateRowCount(); > updateProcessTotals(); >- checkAvailability(); >+ if (ill_check_availability_syspref == 1){ >+ checkAvailability(); >+ } > } > } > ); >@@ -247,22 +249,23 @@ > !availabilitySent[row.value] > ) { > availabilitySent[row.value] = 1; >- getAvailability(row.value, row.metadata); >+ getAvailability(row); > } > }); > }; > > // Check availability services for immediate availability, if found, > // create a link in the table linking to the item >- function getAvailability(identifier, metadata) { >+ function getAvailability(row) { >+ let metadata = row.metadata; > // Prep the metadata for passing to the availability plugins > let availability_object = {}; > if (metadata.issn) availability_object['issn'] = metadata.issn; > if (metadata.doi) availability_object['doi'] = metadata.doi; > if (metadata.pubmedid) availability_object['pubmedid'] = metadata.pubmedid; > var prepped = encodeURIComponent(base64EncodeUnicode(JSON.stringify(availability_object))); >- for (i = 0; i < batch_availability_services.length; i++) { >- var service = batch_availability_services[i]; >+ row.av_hits = []; >+ batch_availability_services.map(async (service) => { > window.doApiRequest( > service.endpoint + prepped > ) >@@ -272,16 +275,17 @@ > .then(function (data) { > if (data.results.search_results && data.results.search_results.length > 0) { > var result = data.results.search_results[0]; >- tableContent.data = tableContent.data.map(function (row) { >- if (row.value === identifier) { >- row.url = result.url; >- row.availabilitySupplier = service.name; >- } >- return row; >- }); >+ row.av_hits.push({name:service.name, url:result.url}); >+ return row; >+ }else { >+ row.av_hits.push({ name: service.name, empty: 1 }) > } >+ }) >+ .then(function (response) { >+ updateTable(); > }); >- } >+ }); >+ // } > }; > > // Help btoa with > 8 bit strings >@@ -820,15 +824,7 @@ > label.innerText = ill_batch_metadata[prop] + ': '; > > // Add a link to the availability URL if appropriate >- var value; >- if (!data.url) { >- value = document.createElement('span'); >- } else { >- value = document.createElement('a'); >- value.setAttribute('href', data.url); >- value.setAttribute('target', '_blank'); >- value.setAttribute('title', ill_batch_available_via + ' ' + data.availabilitySupplier); >- } >+ var value = document.createElement('span'); > value.classList.add('metadata-value'); > value.innerText = meta[prop]; > div.appendChild(label); >@@ -930,6 +926,30 @@ > return data.requestStatus || '-'; > } > >+ function createRequestAvailability(x, y, data) { >+ >+ // If the fetch failed >+ if (data.failed.length > 0) { >+ return data.failed; >+ } >+ >+ let str = ''; >+ let has_some = false; >+ if(typeof data.av_hits !== 'undefined' && data.av_hits.length>0){ >+ data.av_hits.forEach((av_hit) => { >+ if(!av_hit.empty){ >+ has_some = true; >+ str += '<li><a target="_blank" href="' + av_hit.url + '">' + av_hit.name + '</a></li>' >+ } >+ }); >+ >+ if(!has_some){ >+ str = ill_batch_none; >+ } >+ } >+ return str || ill_populate_waiting; >+ }; >+ > function buildTable(identifiers) { > table = KohaTable('identifier-table', { > processing: true, >@@ -963,8 +983,13 @@ > width: '6.5%', > render: createRequestStatus > }, >+ ...( ill_check_availability_syspref == 1 ? [{ >+ data: '', >+ width: '13%', >+ render: createRequestAvailability, }] : [] >+ ), > { >- width: '18%', >+ width: '6.5%', > render: createActions, > className: 'action-column' > } >-- >2.30.2
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 34282
:
153494
|
153564
|
154304
|
154308
|
156385
|
159894