Bugzilla – Attachment 166386 Details for
Bug 36618
Make creation of bibliographic records optional for ERM local titles
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36618: Make biblio creation optional for ERM local titles
Bug-36618-Make-biblio-creation-optional-for-ERM-lo.patch (text/plain), 7.17 KB, created by
Nick Clemens (kidclamp)
on 2024-05-08 11:12:24 UTC
(
hide
)
Description:
Bug 36618: Make biblio creation optional for ERM local titles
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-05-08 11:12:24 UTC
Size:
7.17 KB
patch
obsolete
>From 46852b2f09ae20b68c3befa84eaf71cd2c7bc1f6 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Wed, 17 Apr 2024 10:31:27 +0000 >Subject: [PATCH] Bug 36618: Make biblio creation optional for ERM local titles > >This patch makes biblio creation on local title creation optional. > >Test plan: >1) Navigate to the local title creation form >2) Create a title and leave the "Create record" box unchecked >3) Submit the form >4) Search the catalogue for the title you have just created - no biblio result will be available >5) Repeat steps 2 - 3 but this time check the box to create a record >6) You should now be able to find a record in the catalogue for the title you just imported > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/ERM/EHoldings/Title.pm | 43 +++++++++++-------- > Koha/REST/V1/ERM/EHoldings/Titles/Local.pm | 11 +++-- > .../definitions/erm_eholdings_title.yaml | 5 +++ > .../ERM/EHoldingsLocalTitlesFormAdd.vue | 22 ++++++++++ > 4 files changed, 58 insertions(+), 23 deletions(-) > >diff --git a/Koha/ERM/EHoldings/Title.pm b/Koha/ERM/EHoldings/Title.pm >index 129924b0285..e11c06abf5f 100644 >--- a/Koha/ERM/EHoldings/Title.pm >+++ b/Koha/ERM/EHoldings/Title.pm >@@ -38,30 +38,35 @@ Koha::ERM::EHoldings::Title - Koha ERM Title Object class > =cut > > sub store { >- my ($self) = @_; >+ my ( $self, $args ) = @_; >+ >+ my $create_linked_biblio = $args->{create_linked_biblio} || 0; > > # FIXME This is terrible and ugly, we need to: > # * Provide a mapping for each attribute of title > # * Create a txn > >- # If the 'title' is already linked to a biblio, then we update the title subfield only >- if ( $self->biblio_id ) { >- my $biblio = Koha::Biblios->find( $self->biblio_id ); >- my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); >- my $record = $biblio->metadata->record(); >- my $title_field = $record->field($title_tag); >- $title_field->update( $title_subfield => $self->publication_title ); >- C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); >- } else { >- >- # If it's not linked, we create a simple biblio and save the biblio id to the 'title' >- my $marc_record = TransformKohaToMarc( >- { >- 'biblio.title' => $self->publication_title, >- } >- ); >- my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); >- $self->biblio_id($biblio_id); >+ if ($create_linked_biblio) { >+ >+ # If the 'title' is already linked to a biblio, then we update the title subfield only >+ if ( $self->biblio_id ) { >+ my $biblio = Koha::Biblios->find( $self->biblio_id ); >+ my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); >+ my $record = $biblio->metadata->record(); >+ my $title_field = $record->field($title_tag); >+ $title_field->update( $title_subfield => $self->publication_title ); >+ C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); >+ } else { >+ >+ # If it's not linked, we create a simple biblio and save the biblio id to the 'title' >+ my $marc_record = TransformKohaToMarc( >+ { >+ 'biblio.title' => $self->publication_title, >+ } >+ ); >+ my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); >+ $self->biblio_id($biblio_id); >+ } > } > > $self = $self->SUPER::store; >diff --git a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >index 10c1a9ee8f7..d8d16741be6 100644 >--- a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >+++ b/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm >@@ -87,9 +87,11 @@ sub add { > > my $body = $c->req->json; > >- my $resources = delete $body->{resources} // []; >+ my $resources = delete $body->{resources} // []; >+ my $create_linked_biblio = delete $body->{create_linked_biblio} // 0; > >- my $title = Koha::ERM::EHoldings::Title->new_from_api($body)->store; >+ my $title = Koha::ERM::EHoldings::Title->new_from_api($body) >+ ->store( { create_linked_biblio => $create_linked_biblio } ); > > $title->resources($resources); > >@@ -158,9 +160,10 @@ sub update { > > my $body = $c->req->json; > >- my $resources = delete $body->{resources} // []; >+ my $resources = delete $body->{resources} // []; >+ my $create_linked_biblio = delete $body->{create_linked_biblio} // 0; > >- $title->set_from_api($body)->store; >+ $title->set_from_api($body)->store( { create_linked_biblio => $create_linked_biblio } ); > > $title->resources($resources); > >diff --git a/api/v1/swagger/definitions/erm_eholdings_title.yaml b/api/v1/swagger/definitions/erm_eholdings_title.yaml >index 7185009fefc..7ed823fcadd 100644 >--- a/api/v1/swagger/definitions/erm_eholdings_title.yaml >+++ b/api/v1/swagger/definitions/erm_eholdings_title.yaml >@@ -144,6 +144,11 @@ properties: > description: Resource containing this title > items: > $ref: erm_eholdings_resource.yaml >+ create_linked_biblio: >+ description: should a linked biblio be created >+ type: >+ - boolean >+ - "null" > > additionalProperties: false > required: >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesFormAdd.vue >index 30f9bbb8dff..bd4ff14f669 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesFormAdd.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesFormAdd.vue >@@ -366,6 +366,27 @@ > </li> > </ol> > </fieldset> >+ <fieldset class="rows"> >+ <legend> >+ {{ >+ $__("%s linked biblio record").format( >+ title.title_id ? "Update" : "Create" >+ ) >+ }}: >+ </legend> >+ <label for="create_linked_biblio" >+ >{{ >+ $__("%s record").format( >+ title.title_id ? "Update" : "Create" >+ ) >+ }}:</label >+ > >+ <input >+ type="checkbox" >+ id="create_linked_biblio" >+ v-model="title.create_linked_biblio" >+ /> >+ </fieldset> > <EHoldingsTitlesFormAddResources :resources="title.resources" /> > <fieldset class="action"> > <input type="submit" :value="$__('Submit')" /> >@@ -429,6 +450,7 @@ export default { > preceding_publication_title_id: "", > access_type: "", > resources: [], >+ create_linked_biblio: false, > }, > initialized: false, > } >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36618
:
164992
|
164993
|
166149
|
166150
|
166380
|
166381
|
166382
| 166386 |
166387
|
166388
|
167111