From cfbf1807fc6c3d475d8d33c48eee78ebbb62d97e Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 1 May 2024 06:41:00 +1200 Subject: [PATCH] Bug 36515: Amend MARC modification templates so control fields can be copied to subfields Test plan: 1. Apply patch and restart services 2. Create a MARC modification template with the action: Copy and replace field 001 to 099$a unless 099$a exists 3. Perform a Batch record modification using your MARC modification template from #2 4. Confirm that the template has successfully moved the 001 control field value to the 099$a subfield Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind Signed-off-by: Katrin Fischer --- Koha/SimpleMARC.pm | 6 +++--- .../prog/js/marc_modification_templates.js | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm index be7f025ea2..6b15b8d939 100644 --- a/Koha/SimpleMARC.pm +++ b/Koha/SimpleMARC.pm @@ -135,9 +135,9 @@ sub copy_and_replace_field { if ( ! ( $record && $fromFieldName && $toFieldName ) ) { return; } - - if ( !defined $fromSubfieldName or $fromSubfieldName eq '' - or !defined $toSubfieldName or $toSubfieldName eq '' + if ( + ( !defined $fromSubfieldName or $fromSubfieldName eq '' ) + and ( !defined $toSubfieldName or $toSubfieldName eq '' ) ) { _copy_move_field( { record => $record, diff --git a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js index 39dfd7226d..594985403a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js +++ b/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js @@ -14,8 +14,11 @@ $(document).ready(function() { var action = $("#action").val(); if ( action == 'move_field' || action == 'copy_field' || action == 'copy_and_replace_field') { if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) { - alert( __("Both subfield values should be filled or empty.") ); - return false; + if ( ( $("#to_field").val() >= 10 && $("#to_subfield").val().length > 0 ) && + ( $("#from_field").val() >= 10 && $("#from_subfield").val().length > 0 ) ) { + alert( __("Both subfield values should be filled or empty.") ); + return false; + } } if ( $("#to_field").val().length <= 0 ) { alert( __("The destination should be filled.") ); @@ -26,11 +29,6 @@ $(document).ready(function() { alert( __("If the field is a control field, the subfield should be empty") ); return false; } - if ( ( $("#from_field").val() < 10 && $("#to_field").val() >= 10 ) || - ( $("#to_field").val() < 10 && $("#from_field").val() >= 10 ) ) { - alert( __("A control field cannot be used with a regular field.") ); - return false; - } } if ( action == 'update_field' ) { if ( $("#from_subfield").val().length <= 0 ) { -- 2.39.5