From 163904be59e71c916df682493c137a737eab28b9 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 18 May 2022 08:30:48 +0100 Subject: [PATCH] Bug 29560: Add option to create MARC Links when bundling items This patch add a checkbox to the 'Add to bundle' modal allowing the user to optionally add MARC links between the new child record and the current biblio. For MARC21 this will result in a 773 pointing to the host from the item record and for UNIMARC a 461 field will be added. Signed-off-by: Tuomas Kunttu --- Koha/REST/V1/Items.pm | 5 +++++ api/v1/swagger/definitions/bundle_link.yaml | 3 +++ .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 11 ++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm index 5db12b669d..c46687e683 100644 --- a/Koha/REST/V1/Items.pm +++ b/Koha/REST/V1/Items.pm @@ -338,6 +338,7 @@ sub add_to_bundle { ); } + my $add_link = $c->validation->param('body')->{'marc_link'} // 0; return try { my $options = { force_checkin => $body->{force_checkin}, @@ -345,6 +346,10 @@ sub add_to_bundle { }; my $link = $item->add_to_bundle($bundle_item, $options); + if ($add_link) { + $bundle_item->biblio->link_marc_host( + { biblionumber => $item->biblio->biblionumber } ); + } return $c->render( status => 201, openapi => $bundle_item diff --git a/api/v1/swagger/definitions/bundle_link.yaml b/api/v1/swagger/definitions/bundle_link.yaml index b564d039ee..82d042a16b 100644 --- a/api/v1/swagger/definitions/bundle_link.yaml +++ b/api/v1/swagger/definitions/bundle_link.yaml @@ -19,4 +19,7 @@ properties: type: - boolean - "null" + marc_link: + type: boolean + description: Is there a marc link for this item additionalProperties: false diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 05da5acf56..f89d9b9439 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1301,6 +1301,10 @@ Required +
  • + + +
  • @@ -1980,6 +1984,7 @@ }); const barcode = data.external_id; + const marc_link = data.marc_link; /* Report the results */ posting.done(function(data) { @@ -1999,7 +2004,7 @@ .addClass('btn btn-xs') .text(_("Check in and add to bundle")) .on('click', function () { - addToBundle(url, { external_id: barcode, force_checkin: true }); + addToBundle(url, { external_id: barcode, force_checkin: true, marc_link: marc_link }); }); $('#addResult') .empty() @@ -2016,7 +2021,7 @@ .addClass('btn btn-xs') .text(_("Ignore holds and add to bundle")) .on('click', function () { - addToBundle(url, { external_id: barcode, ignore_holds: true }); + addToBundle(url, { external_id: barcode, ignore_holds: true, marc_link: marc_link }); }); $('#addResult') .empty() @@ -2047,7 +2052,7 @@ event.preventDefault(); const url = this.action; - const data = { external_id: this.elements.external_id.value }; + const data = { external_id: this.elements.external_id.value, marc_link: this.elements.bundle_link.checked }; addToBundle(url, data); }); -- 2.30.2