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 <hc@interleaf.ie>
Signed-off-by: Barry Cannon <bc@interleaf.ie>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Andrew Isherwood 2020-12-08 12:21:43 +00:00 committed by Jonathan Druart
parent 57c5d83998
commit 045a59a358
2 changed files with 42 additions and 6 deletions

View file

@ -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 '<a href="' + link.url + '" target="_blank">' +
link.text +
'</a>';
});
};
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 ?
'<a href="'+row.url+'" target="_blank">'+row.title+'</a>' :
row.title;
var links = getLinks(row);
if (links) {
return row.title + ' - ' + links.join(', ');
} else if (row.url) {
return '<a href="' + row.url + '" target="_blank">' +
row.title +
'</a>';
} else {
return row.title;
}
},
source: function(data, type, row) {
return row.opac_url ?

View file

@ -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 '<a href="' + link.url + '" target="_blank">' +
link.text +
'</a>';
});
};
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 ?
'<a href="'+row.url+'" target="_blank">'+row.title+'</a>' :
row.title;
var links = getLinks(row);
if (links) {
return row.title + ' - ' + links.join(', ');
} else if (row.url) {
return '<a href="' + row.url + '" target="_blank">' +
row.title +
'</a>';
} else {
return row.title;
}
},
source: function(data, type, row) {
return row.opac_url ?