Bug 42292: (follow-up) Fix OverDrive/OpenLibrary references in opac-results.tt
Three issues introduced by the OPAC port of opac-results.tt:
- The tt-allowed block sets OverDriveEnabled via
`Koha.Preference("OverDriveEnabled")`, but OverDriveEnabled is a
TT-side SET variable (computed from OverDriveLibraryID +
OverDriveClientKey + OverDriveClientSecret), not a system
preference, so Koha.prefs.OverDriveEnabled is always "".
The code at line 621 then reads an unprefixed `OverDriveEnabled`
identifier which is not declared -- the OverDrive result block
never fires.
- The neighbouring block `if (OpenLibrarySearch) { ... }` reads an
unprefixed identifier for a value that is only exposed on
Koha.prefs, so the OpenLibrary result block also never fires.
- Both blocks build a throbber <img> with
`src=\`${interface}/${theme}/images/spinner-small.gif\`` inside a
single-quoted JS string; the backticks are literal characters
there, so the rendered src ends up as that literal template
text, not a usable URL.
Replace the OverDriveEnabled addPrefs entry with a plain
`const OverDriveEnabled = [% OverDriveEnabled ? 1 : 0 | html %];`
that reads the TT SET variable, prefix OpenLibrarySearch with
Koha.prefs, and rebuild the throbber src via normal string
concatenation.
To test:
- With OverDrive configured (OPACOverDrive, OverDriveLibraryID,
OverDriveClientKey, OverDriveClientSecret), run a search in the
OPAC: the OverDrive results panel shows the spinner and then
the API results.
- With OpenLibrarySearch enabled, the OpenLibrary panel does the
same.
- In both cases the spinner image loads (no broken-image icon).
- Disable both prefs -> neither panel is rendered, no console errors.
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
b4035c5a0c
commit
71b121bb6f
|
|
@ -496,10 +496,10 @@
|
|||
OpacCoce: [% Koha.Preference('OpacCoce') ? 1 : 0 | html %],
|
||||
CoceHost: "[% Koha.Preference('CoceHost') | html %]",
|
||||
CoceProviders: "[% Koha.Preference('CoceProviders') | html %]",
|
||||
OverDriveEnabled: [% Koha.Preference("OverDriveEnabled") ? 1 : 0 | html %],
|
||||
OverDriveLibraryID: "[% Koha.Preference("OverDriveLibraryID") | html %]",
|
||||
OpenLibrarySearch: [% Koha.Preference("OpenLibrarySearch") ? 1 : 0 | html %],
|
||||
});
|
||||
const OverDriveEnabled = [% OverDriveEnabled ? 1 : 0 | html %];
|
||||
const DidYouMean = [% DidYouMean ? 1 : 0 | html %];
|
||||
// query_desc and querystring are set in opac-bottom.inc
|
||||
let query_desc_uri = "[% query_desc | uri %]";
|
||||
|
|
@ -619,7 +619,7 @@
|
|||
});
|
||||
}
|
||||
if (OverDriveEnabled && firstPage) {
|
||||
var $overdrive_results = $('<div id="overdrive-results">' + _("Searching %s...").format("OverDrive") + ' <img class="throbber" src=`${interface}/${theme}/images/spinner-small.gif` /></div>');
|
||||
var $overdrive_results = $('<div id="overdrive-results">' + _("Searching %s...").format("OverDrive") + ' <img class="throbber" src="' + interface + "/" + theme + '/images/spinner-small.gif" /></div>');
|
||||
$("#numresults").after($overdrive_results);
|
||||
//Clean querystring, first we remove CCL entities, then decode HTML entities, then swap double quotes for single quotes
|
||||
//as the overdrive API treats double quotes as a search term and returns extra results
|
||||
|
|
@ -641,8 +641,8 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
if (OpenLibrarySearch) {
|
||||
var $openlibrary_results = $('<div id="openlibrary-results">' + _("Searching %s...").format("OpenLibrary") + ' <img class="throbber" src=`${interface}/${theme}/images/spinner-small.gif` /></div>');
|
||||
if (Koha.prefs.OpenLibrarySearch) {
|
||||
var $openlibrary_results = $('<div id="openlibrary-results">' + _("Searching %s...").format("OpenLibrary") + ' <img class="throbber" src="' + interface + "/" + theme + '/images/spinner-small.gif" /></div>');
|
||||
$("#numresults").after($openlibrary_results);
|
||||
KOHA.OpenLibrary.search(querystring, null, function (data) {
|
||||
if (data.error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue