From 5d42b5ff641397a4fbaeb601e2e00cd71e05e001 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 9 Mar 2022 01:13:32 +0000 Subject: [PATCH] Bug 30250: Use ApplyFrameworkDefaults when cataloguing This patch adds a system preference ApplyFrameworkDefaults to configure when to apply framework defaults - when cataloguing a new record, when editing a record as new (duplicating), or when changing the framework while editing an existing record. This applies to both bibliographic records and authority records. To test: 1. Update database 2. Go to Administration -> system preferences. Find the ApplyFrameworkDefaults system preference. Confirm "when cataloguing new records" is selected by default. 3. Keep the system preference open in one tab, and open the staff client in another tab. 4. Go to Administration -> bibliographic frameworks. Choose a framework, edit the subfields for a tag, and give a subfield a default value. For example, set 500$a for the BOOKS framework to have a default value of "TEST". This will be Framework A. 5. Ensure you have another framework that does not have the same default value for a subfield as Framework A. This will be Framework B. 6. Go to Cataloguing. Add a new record using Framework A. Confirm your subfield has the default value filled. Cancel and do not save the record. 7. In your System preferences tab, uncheck the option "when cataloguing new records" and save. No options should now be selected. 8. In our other tab, go to cataloguing, add a new record using Framework A. Confirm your subfield does NOT have the default value filled. Fill the required fields, including the subfield that should have a default value, and Save the record. 9. In your system preferences tab, select all options and save. 10. In your other tab, click Edit, then "Edit as new (duplicate)". Confirm your subfield has maintained the value from the source record. Cancel and do not save the record. 11. Edit your original record and delete the value in your subfield that could be filled with a default value by the framework. Save the record with no value in the subfield. 12. Click Edit, then "Edit as new (duplicate)". Confirm your subfield has the default value filled. Framework defaults will only apply to emplty fields. Save the record. 13. Do a catalogue search and find a record that uses Framework B. 14. If you need to, edit the record to make sure there is nothing in your subfield that should have a default value if this record were to use Framework A, and Save. 15. Edit the record. Using the settings dropdown, change the framework to Framework A. Confirm your subfield has the default value filled. 16. Repeat steps 4 to 12 with authority types and authority records. Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- authorities/authorities.pl | 13 ++++++++++--- cataloguing/addbiblio.pl | 12 ++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index b465d4bcc0..5531e708a1 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -112,9 +112,16 @@ sub create_input { $max_length = 40; } - # if there is no value provided but a default value in parameters, get it - if ($value eq '') { - $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} if !$cgi->param('authid'); # only for new records + # Apply optional framework default value when it is a new record, + # or when editing as new (duplicating a record), + # based on the ApplyFrameworkDefaults setting. + # Substitute date parts, user name + my $applydefaults = C4::Context->preference('ApplyFrameworkDefaults'); + if ( $value eq '' && ( + ( $applydefaults =~ /new/ && !$cgi->param('authid') ) || + ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' ) + ) ) { + $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; if (!defined $value) { $value = q{}; } diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 5896de18f4..4ee4c85596 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -292,9 +292,17 @@ sub create_input { my $index_subfield = CreateKey(); # create a specifique key for each subfield - # Apply optional framework default value when it is a new record + # Apply optional framework default value when it is a new record, + # or when editing as new (duplicating a record), + # or when changing a record's framework, + # based on the ApplyFrameworkDefaults setting. # Substitute date parts, user name - if ( $value eq '' && !$cgi->param('biblionumber') ) { + my $applydefaults = C4::Context->preference('ApplyFrameworkDefaults'); + if ( $value eq '' && ( + ( $applydefaults =~ /new/ && !$cgi->param('biblionumber') ) || + ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' ) || + ( $applydefaults =~ /changed/ && $cgi->param('changed_framework') ) + ) ) { $value = $tagslib->{$tag}->{$subfield}->{defaultvalue} // q{}; # get today date & replace <>, <>, <>, <
> if provided in the default value -- 2.39.5