From 8e7ea9baafcba3e02a4c13ba707b4f45abf5c695 Mon Sep 17 00:00:00 2001 From: Marion Durand Date: Wed, 6 Oct 2021 14:49:58 +0200 Subject: [PATCH] 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 Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer (cherry picked from commit b2ae5380b0741e1d2277a58f264df88f243ecadb) Signed-off-by: Lucas Gass --- authorities/merge.pl | 13 +++++++++++++ .../intranet-tmpl/prog/en/includes/merge-record.inc | 3 ++- .../prog/en/modules/authorities/merge.tt | 6 +++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/authorities/merge.pl b/authorities/merge.pl index 2c82340468..1e34e9f7be 100755 --- a/authorities/merge.pl +++ b/authorities/merge.pl @@ -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, ); } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc index cdf3aefb54..d9a9db593d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc @@ -51,6 +51,7 @@ [% WRAPPER tab_item tabname= "tabrecord${record.recordid}" %] [% record.recordid | html %] [% IF record.reference %](ref)[% END %] + ([% record.frameworktext | html %]) [% END %] [% END %] [% END # /WRAPPER tabs_nav %] @@ -69,7 +70,7 @@ [% END %] [% BLOCK mergetarget %] -

Destination record

+

Destination record ([% authtypetext | html %])

    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt index 5c577c7556..7ebfd2e448 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt @@ -109,7 +109,7 @@ div#result { margin-top: 1em; } [% PROCESS mergesource sourcerecords=records %]
    -[% PROCESS mergetarget %] +[% PROCESS mergetarget authtypetext=frameworktext %]
    @@ -118,6 +118,10 @@ div#result { margin-top: 1em; } +[% IF multipleauthtypes %] +
    Multiple authority types are used. There may be a data loss while merging.
    +[% END %] +
    -- 2.39.5