From 53d3e3b5ae928d64ccd25899e8f49ae7a083f85d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 21 Sep 2016 11:40:09 -0300 Subject: [PATCH] Bug 17318: Allow chosing fixed normalization routines This patch changes the matching-rules.pl page, so it allows the user to choose from the different hardcoded normalization routines. It is done using TT blocks and the routine descriptions are translatable. To test: - Create some matching rule - Have free text values on the 'Normalization rule' field - Apply the patches - Create a new routine => SUCCESS: You can now only choose between fixed option - Save the rule - Open it for editing => SUCCESS: Chosen rules are preserved - Edit the original free-text including rule => SUCCESS: Rules fall back to 'None' - Sign off :-D TODO: A followup will add a warning about the current value and the fact that saving the matching rule will overwrite those, with 'none'. Sponsored-by: FIT --- admin/matching-rules.pl | 10 ++- .../prog/en/modules/admin/matching-rules.tt | 96 ++++++++++++++++++---- 2 files changed, 85 insertions(+), 21 deletions(-) diff --git a/admin/matching-rules.pl b/admin/matching-rules.pl index 191d38b..20d9f82 100755 --- a/admin/matching-rules.pl +++ b/admin/matching-rules.pl @@ -26,7 +26,7 @@ use C4::Auth; use C4::Context; use C4::Output; use C4::Koha; -use C4::Matcher; +use C4::Matcher qw/valid_normalization_routines/; my $script_name = "/cgi-bin/koha/admin/matching-rules.pl"; @@ -47,8 +47,12 @@ $template->param(script_name => $script_name); my $matcher_id = $input->param("matcher_id"); -$template->param(max_matchpoint => 0); -$template->param(max_matchcheck => 0); +$template->param( max_matchpoint => 0 ); +$template->param( max_matchcheck => 0 ); +my @valid_norms = C4::Matcher::valid_normalization_routines(); +unshift @valid_norms, 'none'; +$template->param( valid_norms => \@valid_norms ); + my $display_list = 0; if ($op eq "edit_matching_rule") { edit_matching_rule_form($template, $matcher_id); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt index acb33a7..07bbc7a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt @@ -13,6 +13,39 @@ [% INCLUDE 'doc-head-close.inc' %] +[% BLOCK norms_text %] +[% SWITCH norm %] +[% CASE 'none' %]None +[% CASE 'remove_spaces' %]Remove spaces +[% CASE 'upper_case' %]Uppercase +[% CASE 'lower_case' %]Lowercase +[% CASE 'legacy_default' %]Legacy default +[% CASE %][% norm %] +[% END %] +[% END %] + +[% BLOCK norms_options %] +[%# PARAMS: selected_norm %] +[% FOREACH norm IN valid_norms %] +[% IF ( norm == selected_norm ) %] + +[% ELSE %] + +[% END %] +[% END %] +[% END %] + +[% BLOCK norms_select %] +[%# PARAMS: selected_norm, id, name %] +[% UNLESS valid_norms.grep(selected_norm).size %] +[%# Fallback to 'none' %] +[% selected_norm = 'none' %] +[% END %] + +[% END %] +