[Bug 35288] New: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Bug ID: 35288 Summary: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: koha@trust-box.at QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl The "new" ApplyFrameworkDefaults option is to coarse sometimes ie quite often you also want to apply default values even if then field wasn't empty before e.g. on duplicating a new controlnumber should be generated etc so I suggest (and already wrote) a new plugin hook (see https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33669) -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Change sponsored?|--- |Sponsored See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=33669 Assignee|koha-bugs@lists.koha-commun |koha@trust-box.at |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=35289 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |35289 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35289 [Bug 35289] addbiblio.pl calls generate_subfield_form with inconsistent parameters -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Bug 35288 depends on bug 35289, which changed state. Bug 35289 Summary: addbiblio.pl calls generate_subfield_form with inconsistent parameters https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35289 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |RESOLVED Resolution|--- |DUPLICATE -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #1 from Mark Hofstetter <koha@trust-box.at> --- Created attachment 158710 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=158710&action=edit Bug 35288: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling The "new" ApplyFrameworkDefaults option is to coarse sometimes ie quite often you also want to apply default values even if then field wasn't empty before e.g. on duplicating a new controlnumber should be generated etc This patch adds a new plugin call 'framework_defaults_override' and tidies up the code a little Plugin call: Koha::Plugins->call( 'framework_defaults_override', $tag, $subfield, $value, $form_mode ); ie marc tag, marc subfield, the "before value", the action which triggered the change possible actions are new, duplicate, changed (Framework), imported (via SRU) the plugin has to return a hashref containing two keys apply_override - undef or a true if the default value from the framework should be applied override_default_value - a completly new derived value sub framework_defaults_override { my ( $self, $tag, $subfield, $value, $form_mode ) = @_; # $framework_override->{override_default_value} # $framework_override->{apply_override} my $r = {override_default_value => undef, apply_override => undef}; if ($tag eq '245' && $subfield eq 'a') { $r->{apply_override} = 1; $r->{override_default_value} = $value .' added'; } return $r; } for a demo implementation please see https://github.com/HKS3/hks3-munde-framework-defaults-demo/blob/main/hks3-mu... To test: 1) apply patch 2) install demo plugin (and don't enable it yet) 3) create a record with a 245a field set to a value eg "My Title" 4) enable ApplyFrameworkDefaults for all 4 cases "Select all" 5) in Cataloging Edit the previously generated record 6) change framework via settings 7) nothing should happen to the title in 245a 8) enable plugin 9) repeat point 5+6 10) the title in 245a should change to "My Title added" 11) please sign off Sponsored-by: Styrian State Library Co-authored-by: Thomas Klausner <domm@plix.at> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |koha@trust-box.at -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #2 from Mark Hofstetter <koha@trust-box.at> --- another real life example using this plugin hook https://github.com/HKS3/ApplyFrameworkDefaultsLibelle -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com --- Comment #3 from Lucas Gass <lucas@bywatersolutions.com> --- Mark, Don't we need unit tests for this change? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #4 from Mark Hofstetter <koha@trust-box.at> --- yes definitely, (there is always a but here, so here it comes) but 1. I just wanted to build a quick working prototype (needed for customer) 2. for the community to evaluate, if it's generally considered usefull 3. at the moment I am not sure how to test, as it's highly dependent on the UI if you could point me to a useful test strategy or a similar test which relies on changing the framework in Biblio Edit I'd be glad to make a test -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #5 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- This works, I'd like to move it along. I'll let the QA decide about the need for unit tests or not. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #158710|0 |1 is obsolete| | --- Comment #6 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Created attachment 176105 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=176105&action=edit Bug 35288: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling The "new" ApplyFrameworkDefaults option is to coarse sometimes ie quite often you also want to apply default values even if then field wasn't empty before e.g. on duplicating a new controlnumber should be generated etc This patch adds a new plugin call 'framework_defaults_override' and tidies up the code a little Plugin call: Koha::Plugins->call( 'framework_defaults_override', $tag, $subfield, $value, $form_mode ); ie marc tag, marc subfield, the "before value", the action which triggered the change possible actions are new, duplicate, changed (Framework), imported (via SRU) the plugin has to return a hashref containing two keys apply_override - undef or a true if the default value from the framework should be applied override_default_value - a completly new derived value sub framework_defaults_override { my ( $self, $tag, $subfield, $value, $form_mode ) = @_; # $framework_override->{override_default_value} # $framework_override->{apply_override} my $r = {override_default_value => undef, apply_override => undef}; if ($tag eq '245' && $subfield eq 'a') { $r->{apply_override} = 1; $r->{override_default_value} = $value .' added'; } return $r; } for a demo implementation please see https://github.com/HKS3/hks3-munde-framework-defaults-demo/blob/main/hks3-mu... To test: 1) apply patch 2) install demo plugin (and don't enable it yet) 3) create a record with a 245a field set to a value eg "My Title" 4) enable ApplyFrameworkDefaults for all 4 cases "Select all" 5) in Cataloging Edit the previously generated record 6) change framework via settings 7) nothing should happen to the title in 245a 8) enable plugin 9) repeat point 5+6 10) the title in 245a should change to "My Title added" 11) please sign off Sponsored-by: Styrian State Library Co-authored-by: Thomas Klausner <domm@plix.at> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Patch doesn't apply -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Patch doesn't apply |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #176105|0 |1 is obsolete| | --- Comment #7 from Mark Hofstetter <koha@trust-box.at> --- Created attachment 178506 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=178506&action=edit Bug 35288: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling The "new" ApplyFrameworkDefaults option is to coarse sometimes ie quite often you also want to apply default values even if then field wasn't empty before e.g. on duplicating a new controlnumber should be generated etc This patch adds a new plugin call 'framework_defaults_override' and tidies up the code a little Plugin call: Koha::Plugins->call( 'framework_defaults_override', $tag, $subfield, $value, $form_mode ); ie marc tag, marc subfield, the "before value", the action which triggered the change possible actions are new, duplicate, changed (Framework), imported (via SRU) the plugin has to return a hashref containing two keys apply_override - undef or a true if the default value from the framework should be applied override_default_value - a completly new derived value sub framework_defaults_override { my ( $self, $tag, $subfield, $value, $form_mode ) = @_; # $framework_override->{override_default_value} # $framework_override->{apply_override} my $r = {override_default_value => undef, apply_override => undef}; if ($tag eq '245' && $subfield eq 'a') { $r->{apply_override} = 1; $r->{override_default_value} = $value .' added'; } return $r; } for a demo implementation please see https://github.com/HKS3/hks3-munde-framework-defaults-demo/blob/main/hks3-mu... To test: 1) apply patch 2) install demo plugin (and don't enable it yet) 3) create a record with a 245a field set to a value eg "My Title" 4) enable ApplyFrameworkDefaults for all 4 cases "Select all" 5) in Cataloging Edit the previously generated record 6) change framework via settings 7) nothing should happen to the title in 245a 8) enable plugin 9) repeat point 5+6 10) the title in 245a should change to "My Title added" 11) please sign off Sponsored-by: Styrian State Library Co-authored-by: Thomas Klausner <domm@plix.at> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #8 from Mark Hofstetter <koha@trust-box.at> --- should apply again -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Janusz Kaczmarek <januszop@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |januszop@gmail.com Status|Needs Signoff |Failed QA --- Comment #9 from Janusz Kaczmarek <januszop@gmail.com> --- There is a problem with this patch: the patch sets $form_mode to 'new' when one is importing record through Z39.50 ($op is not defined for Z39.50 import so the first condition $op eq '' is true, and $form_mode is set to 'new'). In this case $form_mode should be set to 'imported' but is not. To confirm: 1. set ApplyFrameworkDefaults to 'when cataloguing new records only' 2. in the default framework set any default value that you are not expecting to be present in a record imported from a Z39.50 source 3. import a record from z Z39.50 server 4. you will see the defined default value in the editor while you should not The problem of not identifying properly Z39.50 context for default values is present also in the current main branch, and could be easily corrected by changing line 96 of Koha/UI/Form/Builder/Biblio.pm from && ( ( $applydefaults =~ /new/ && !$self->{biblionumber} ) into && ( ( $applydefaults =~ /new/ && ! defined $self->{biblionumber} ) But with this patch (35288) the logic of setting the context changes completely. Having this patch there is no sense to make a separate patch for the spotted problem, but it would be more wise IMO to correct this patch to set the context for Z39.50 import properly. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <koha@trust-box.at> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=30681 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <mark@hofstetter.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff Comma delimited| |Styrian State Library list of Sponsors| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Mark Hofstetter <mark@hofstetter.at> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #178506|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #10 from Mark Hofstetter <mark@hofstetter.at> --- Created attachment 196020 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196020&action=edit Bug 35288: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling The "new" ApplyFrameworkDefaults option is to coarse sometimes ie quite often you also want to apply default values even if then field wasn't empty before e.g. on duplicating a new controlnumber should be generated etc This patch adds a new plugin call 'framework_defaults_override' and tidies up the code a little Plugin call: Koha::Plugins->call( 'framework_defaults_override', $tag, $subfield, $value, $form_mode ); ie marc tag, marc subfield, the "before value", the action which triggered the change possible actions are new, duplicate, changed (Framework), imported (via SRU) the plugin has to return a hashref containing two keys apply_override - undef or a true if the default value from the framework should be applied override_default_value - a completly new derived value sub framework_defaults_override { my ( $self, $tag, $subfield, $value, $form_mode ) = @_; # $framework_override->{override_default_value} # $framework_override->{apply_override} my $r = {override_default_value => undef, apply_override => undef}; if ($tag eq '245' && $subfield eq 'a') { $r->{apply_override} = 1; $r->{override_default_value} = $value .' added'; } return $r; } for a demo implementation please see https://github.com/HKS3/hks3-munde-framework-defaults-demo/blob/main/hks3-mu... To test: 1) apply patch 2) install demo plugin (and don't enable it yet) 3) create a record with a 245a field set to a value eg "My Title" 4) enable ApplyFrameworkDefaults for all 4 cases "Select all" 5) in Cataloging Edit the previously generated record 6) change framework via settings 7) nothing should happen to the title in 245a 8) enable plugin 9) repeat point 5+6 10) the title in 245a should change to "My Title added" 11) please sign off Sponsored-by: Styrian State Library Co-authored-by: Thomas Klausner <domm@plix.at> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Janusz Kaczmarek <januszop@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 Janusz Kaczmarek <januszop@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196020|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35288 --- Comment #11 from Janusz Kaczmarek <januszop@gmail.com> --- Created attachment 196021 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196021&action=edit Bug 35288: ApplyFrameworkDefaults add plugin to add more fine grained defaults handling The "new" ApplyFrameworkDefaults option is to coarse sometimes ie quite often you also want to apply default values even if then field wasn't empty before e.g. on duplicating a new controlnumber should be generated etc This patch adds a new plugin call 'framework_defaults_override' and tidies up the code a little Plugin call: Koha::Plugins->call( 'framework_defaults_override', $tag, $subfield, $value, $form_mode ); ie marc tag, marc subfield, the "before value", the action which triggered the change possible actions are new, duplicate, changed (Framework), imported (via SRU) the plugin has to return a hashref containing two keys apply_override - undef or a true if the default value from the framework should be applied override_default_value - a completly new derived value sub framework_defaults_override { my ( $self, $tag, $subfield, $value, $form_mode ) = @_; # $framework_override->{override_default_value} # $framework_override->{apply_override} my $r = {override_default_value => undef, apply_override => undef}; if ($tag eq '245' && $subfield eq 'a') { $r->{apply_override} = 1; $r->{override_default_value} = $value .' added'; } return $r; } for a demo implementation please see https://github.com/HKS3/hks3-munde-framework-defaults-demo/blob/main/hks3-mu... To test: 1) apply patch 2) install demo plugin (and don't enable it yet) 3) create a record with a 245a field set to a value eg "My Title" 4) enable ApplyFrameworkDefaults for all 4 cases "Select all" 5) in Cataloging Edit the previously generated record 6) change framework via settings 7) nothing should happen to the title in 245a 8) enable plugin 9) repeat point 5+6 10) the title in 245a should change to "My Title added" 11) please sign off Sponsored-by: Styrian State Library Co-authored-by: Thomas Klausner <domm@plix.at> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Janusz Kaczmarek <januszop@gmail.com> -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org