Bug 25387: Warn when merging different authority types

Merging two different authorities types can result in the loss of some
field. This patch adds a warning when merging different type of
authorities and add more display of authorities types during merge.

To test:
1- Find two authorities you what to merge. Be sure that these
authorities have different type
2- Search for these authorities (be sure to have both results on the
results page)
3- For the first authority click on "Actions" then on "Merge", same for
the second one
4- Check that koha is asking you to choose a framework and that
authority types are not displayed
5- Choose a framework, then click on next
6- Check that the authority type is not displayed in the tabs and that
no warning appear
7- Apply the patch
8- Repeat step 1 to 3 again
9- Check that authority type is now displayed next to their ID
10- Repeate setp 5 again
11- Check that the authority types is now displayed in the tabs next to
their ID and that a warning appear

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Marion Durand 2021-10-06 14:49:58 +02:00 committed by Katrin Fischer
parent ce90d65603
commit b2ae5380b0
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
3 changed files with 20 additions and 2 deletions

View file

@ -156,6 +156,11 @@ else {
($recordObj1, $recordObj2) = ($recordObj2, $recordObj1);
}
# Getting frameworktext
my $frameworktext1 = Koha::Authority::Types->find( $recordObj1->authtypecode );
my $frameworktext2 = Koha::Authority::Types->find( $recordObj2->authtypecode );
my $frameworktextdestination = Koha::Authority::Types->find( $framework );
# Creating a loop for display
my @records = (
@ -163,6 +168,7 @@ else {
recordid => $mergereference,
record => $recordObj1->record,
frameworkcode => $recordObj1->authtypecode,
frameworktext => $frameworktext1->authtypetext,
display => $recordObj1->createMergeHash($tagslib),
reference => 1,
},
@ -170,6 +176,7 @@ else {
recordid => $notreference,
record => $recordObj2->record,
frameworkcode => $recordObj2->authtypecode,
frameworktext => $frameworktext2->authtypetext,
display => $recordObj2->createMergeHash($tagslib),
},
);
@ -180,6 +187,8 @@ else {
recordid2 => $notreference,
records => \@records,
framework => $framework,
frameworktext => $frameworktextdestination->authtypetext,
multipleauthtypes => ( $recordObj1->authtypecode ne $recordObj2->authtypecode ) ? 1 : 0,
);
}
else {
@ -194,10 +203,14 @@ else {
);
if ( $recordObj1->authtypecode ne $recordObj2->authtypecode ) {
my $authority_types = Koha::Authority::Types->search( { authtypecode => { '!=' => '' } }, { order_by => ['authtypetext'] } );
my $frameworktext1 = Koha::Authority::Types->find( $recordObj1->authtypecode );
my $frameworktext2 = Koha::Authority::Types->find( $recordObj2->authtypecode );
$template->param(
frameworkselect => $authority_types->unblessed,
frameworkcode1 => $recordObj1->authtypecode,
frameworkcode2 => $recordObj2->authtypecode,
frameworklabel1 => $frameworktext1->authtypetext,
frameworklabel2 => $frameworktext2->authtypetext,
);
}
}

View file

@ -51,6 +51,7 @@
[% WRAPPER tab_item tabname= "tabrecord${record.recordid}" %]
[% record.recordid | html %]
[% IF record.reference %]<span>(ref)</span>[% END %]
<span>([% record.frameworktext | html %])</span>
[% END %]
[% END %]
[% END # /WRAPPER tabs_nav %]
@ -69,7 +70,7 @@
[% END %]
[% BLOCK mergetarget %]
<h2>Destination record</h2>
<h2>Destination record ([% authtypetext | html %])</h2>
<div id="result" class="page-section">
<ul id="resultul"></ul>
</div> <!-- // #result -->

View file

@ -109,7 +109,7 @@ div#result { margin-top: 1em; }
[% PROCESS mergesource sourcerecords=records %]
</div>
<div class="col-sm-6">
[% PROCESS mergetarget %]
[% PROCESS mergetarget authtypetext=frameworktext %]
</div>
</div>
@ -118,6 +118,10 @@ div#result { margin-top: 1em; }
<input type="hidden" name="mergereference" value="[% mergereference | html %]" />
<input type="hidden" name="frameworkcode" value="[% framework | html %]" />
[% IF multipleauthtypes %]
<div class="dialog alert multiple-auth-types">Multiple authority types are used. There may be a data loss while merging.</div>
[% END %]
<fieldset class="action">
<input type="hidden" name="op" value="cud-merge" />
<input type="submit" class="btn btn-primary" value="Merge" />