From 909a72c58f07fbb7f8eb8d858641779239903bdc Mon Sep 17 00:00:00 2001 From: Jan Kissig Date: Thu, 16 May 2024 10:11:53 +0200 Subject: [PATCH] Bug 36880: Record overlay rules are not validated This patch fixes validation of rules, confirmation on deletion of rules and removes some unused source code. 1) Validation of record overlay rules on edit and add action 2) Validation when editing an existing rule 3) Adds confirm when deleting multiple rules Test plan: 1) a) open http://localhost:8081/cgi-bin/koha/admin/marc-overlay-rules.pl b) just click + Add rule c) a new rule with an empty tag is saved 2) a) edit an existing rule b) empty input value for tag c) click Save and check that the rule has now an empty value for tag 3) a) delete a rule by checking the checkbox and clicking Delete selected b) delete a rule by clicking the Delete button under Actions c) notice that b) asks for confirmation apply patch 1) redo steps and check that form does not get submitted and the input is marked as required 2) redo steps and check that clicking on Save will not submit the form and mark input as required 3) redo steps and check that a standard confirm popup appears Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer --- admin/marc-overlay-rules.pl | 19 ++---- .../en/modules/admin/marc-overlay-rules.tt | 59 ++++++++----------- 2 files changed, 29 insertions(+), 49 deletions(-) diff --git a/admin/marc-overlay-rules.pl b/admin/marc-overlay-rules.pl index be2c8ac5aa..fc4c849e95 100755 --- a/admin/marc-overlay-rules.pl +++ b/admin/marc-overlay-rules.pl @@ -66,23 +66,12 @@ my $get_rules = sub { }; my $rules = $get_rules->(); -if ($op eq 'remove' || $op eq 'cud-remove') { +if ($op eq 'cud-remove') { my @remove_ids = $input->multi_param('batchremove'); push @remove_ids, scalar $input->param('id') if $input->param('id'); - if ($op eq 'remove') { - $template->{VARS}->{removeConfirm} = 1; - my %remove_ids = map { $_ => undef } @remove_ids; - for my $rule (@{$rules}) { - $rule->{'removemarked'} = 1 if exists $remove_ids{$rule->{id}}; - } - } - elsif ($op eq 'cud-remove') { - my @remove_ids = $input->multi_param('batchremove'); - push @remove_ids, scalar $input->param('id') if $input->param('id'); - Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete(); - # Update $rules after deletion - $rules = $get_rules->(); - } + Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete(); + # Update $rules after deletion + $rules = $get_rules->(); } elsif ($op eq 'edit') { $template->param( edit => 1 ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt index 58a70e242b..b36b90cdc2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt @@ -66,21 +66,11 @@ The [% pref_MARCOverlayRules_link | $raw | $KohaSpan %] preference is not set, don't forget to enable it for rules to take effect. [% END %] - [% IF removeConfirm %] -
-

Remove rule?

-

Are you sure you want to remove the selected rule(s)?

- -
- -
- -
- [% END %]
[% INCLUDE 'csrf-token.inc' %] + @@ -229,7 +219,7 @@ [% ELSE %] @@ -270,15 +260,11 @@ [% END %] @@ -288,11 +274,6 @@ - - [% INCLUDE 'csrf-token.inc' %] - - -
@@ -311,10 +292,7 @@
Rule - + Cancel [% IF rule.remove %]Remove[% ELSE %]Skip[% END %] [% IF rule.delete %]Delete[% ELSE %]Skip[% END %] - Delete + Delete Edit - [% IF rule.removemarked %] - - [% ELSE %] - - [% END %] +