From c2d3c147d4aa965391801abfd110340d4489ed58 Mon Sep 17 00:00:00 2001 From: Marion Durand Date: Wed, 6 Oct 2021 14:49:58 +0200 Subject: [PATCH] Bug 25387: Merging different authority types create no warning 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 --- authorities/merge.pl | 12 ++++++++++++ .../intranet-tmpl/prog/en/includes/merge-record.inc | 3 ++- .../prog/en/modules/authorities/merge.tt | 12 +++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/authorities/merge.pl b/authorities/merge.pl index 0799c26b04..a5787f8fd5 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,7 @@ else { recordid2 => $notreference, records => \@records, framework => $framework, + frameworktext => $frameworktextdestination->authtypetext, ); } else { @@ -194,10 +202,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 6d14015916..70846a43a4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc @@ -53,6 +53,7 @@ [% record.recordid | html %] [% IF record.reference %](ref)[% END %] + ([% record.frameworktext | html %]) [% END %] @@ -67,7 +68,7 @@ [% BLOCK mergetarget %]
-

Destination record

+

Destination record ([% authtypetext %])

    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 d472c924f8..1057ae5148 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt @@ -104,7 +104,7 @@ div#result { margin-top: 1em; } [% PROCESS mergesource sourcerecords=records %]
    -[% PROCESS mergetarget %] +[% PROCESS mergetarget authtypetext=frameworktext %]
    @@ -113,6 +113,16 @@ div#result { margin-top: 1em; } +[% warning = 'FALSE' %] +[% FOREACH record IN records %] + [% IF (record.frameworkcode != framework) %] + [% IF (warning != 'TRUE') %] + [% warning = 'TRUE' %] +
    Multiple authority types are used. There may be a data loss while merging.
    + [% END %] + [% END %] +[% END %] +
    -- 2.17.1