From b690c5696fcb09afbf3fb15d68ffd14977071fae Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 8 Dec 2020 12:21:43 +0000 Subject: [PATCH] Bug 27170: Add support for new 'links' property This commit adds support for the new 'links' property that will allow an availability plugin to return an array of links for a result. These links are parsed and appended to the title field of a results record. Signed-off-by: Holly Cooper Signed-off-by: Barry Cannon --- .../intranet-tmpl/prog/js/ill-availability.js | 24 ++++++++++++++++--- .../bootstrap/js/ill-availability.js | 24 ++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-availability.js b/koha-tmpl/intranet-tmpl/prog/js/ill-availability.js index 289b934ffa..8515200063 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-availability.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-availability.js @@ -1,5 +1,16 @@ $(document).ready(function() { + var getLinks = function(row) { + if (row.links.length === 0) { + return false; + } + return row.links.map(function(link) { + return '' + + link.text + + ''; + }); + }; + window.doSearch = function() { // In case the source doesn't supply data required for DT to calculate // pagination, we need to do it ourselves @@ -51,9 +62,16 @@ $(document).ready(function() { // Here we store them var renders = { title: function(data, type, row) { - return row.url ? - ''+row.title+'' : - row.title; + var links = getLinks(row); + if (links) { + return row.title + ' - ' + links.join(', '); + } else if (row.url) { + return '' + + row.title + + ''; + } else { + return row.title; + } }, source: function(data, type, row) { return row.opac_url ? diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js b/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js index 9c0be4c105..239a3bfecd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/ill-availability.js @@ -1,5 +1,16 @@ $(document).ready(function() { + var getLinks = function(row) { + if (row.links.length === 0) { + return false; + } + return row.links.map(function(link) { + return '' + + link.text + + ''; + }); + }; + window.doSearch = function() { // In case the source doesn't supply data required for DT to calculate // pagination, we need to do it ourselves @@ -51,9 +62,16 @@ $(document).ready(function() { // Here we store them var renders = { title: function(data, type, row) { - return row.url ? - ''+row.title+'' : - row.title; + var links = getLinks(row); + if (links) { + return row.title + ' - ' + links.join(', '); + } else if (row.url) { + return '' + + row.title + + ''; + } else { + return row.title; + } }, source: function(data, type, row) { return row.opac_url ? -- 2.20.1