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 <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Alex Buckley 2024-05-01 06:41:00 +12:00 committed by Katrin Fischer
parent 1149e30be3
commit cfbf1807fc
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 8 additions and 10 deletions

View File

@ -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,

View File

@ -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 ) {