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> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
956755fa15
commit
08992ab711
|
|
@ -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 ($create_linked_biblio) {
|
||||
|
||||
# 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 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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue