Bug 28854: (follow-up) Link bundle items to thier biblios

This patch splits out the title formatting from the bundle item title
display into it's own new js-biblio-format include file and adds biblio
linking options.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2022-06-27 11:54:49 +01:00 committed by Tomas Cohen Arazi
parent 3c485bb1c5
commit 7d0cd2ebae
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 53 additions and 12 deletions

View File

@ -0,0 +1,50 @@
<script>
(function() {
/**
* Format the biblio response from a Koha RESTful API request.
* @param {Object} biblio The biblio json object as returned from the Koha RESTful API
* @param {Object} config A configuration object
* Valid keys are: `link`
* @return {string} The formatted HTML string
*/
window.$biblio_to_html = function( biblio, config ) {
if ( biblio === undefined ) {
return ''; // empty string for no biblio
}
var title = '<span class="biblio-title">';
if ( biblio.title != null && biblio.title != '' ) {
title += escape_str(biblio.title);
} else {
title += __("No title");
}
title += '</span>';
if ( biblio.subtitle != null && biblio.subtitle != '' ) {
title += '<span clas="biblio-subtitle">' + escape_str(biblio.subtitle) + '</span>';
}
if (config && config.link) {
if ( config.link === 'marcdetail' ) {
title = '<a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>';
}
else if ( config.link === 'labeled_marc') {
title = '<a href="/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>';
}
else if ( config.link === 'isbd' ) {
title = '<a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>';
}
else {
title = '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber='+ encodeURIComponent(biblio.biblio_id) +'">' + title + '</a>';
}
}
if ( biblio.medium != null && biblio.medium != '' ) {
title += '<span class="biblio-medium">'+escape_str(biblio.medium)+'</span>';
}
return title;
};
})();
</script>

View File

@ -1598,6 +1598,7 @@ Note that permanent location is a code, and location may be an authval.
[% INCLUDE 'columns_settings.inc' %]
[% INCLUDE 'js-date-format.inc' %]
[% INCLUDE 'js-patron-format.inc' %]
[% INCLUDE 'js-biblio-format.inc' %]
[% Asset.js("js/browser.js") | $raw %]
[% Asset.js("js/table_filters.js") | $raw %]
<script>
@ -1653,22 +1654,12 @@ Note that permanent location is a code, and location may be an authval.
} ],
"columns": [
{
"data": "biblio.title:biblio.medium",
"data": "biblio.title:biblio.subtitle:biblio.medium",
"title": _("Title"),
"searchable": true,
"orderable": true,
"render": function(data, type, row, meta) {
var title = "";
if ( row.biblio.title ) {
title = title.concat('<span class="biblio-title">',row.biblio.title,'</span>');
}
if ( row.biblio.subtitle ) {
title = title.concat('<span class="biblio-subtitle">',row.biblio.subtitle,'</span>');
}
if ( row.biblio.medium ) {
title = title.concat('<span class="biblio-medium">',row.biblio.medium,'</span>');
}
return title;
return $biblio_to_html(row.biblio, { link: 1 });
}
},
{