From 51dfd8eb7a841256dc2377236f93d27476cc453c Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 23 Feb 2026 16:24:23 +0000 Subject: [PATCH] Bug 26355: (follow-up) Allow the setting of multiple information messages --- Koha/REST/V1/Patrons/SelfRenewal.pm | 7 +-- admin/categories.pl | 26 ++++++++-- .../prog/en/modules/admin/categories.tt | 47 +++++++++++++++---- .../PatronSelfRenewal/PatronSelfRenewal.vue | 14 ++++-- .../PatronSelfRenewal/VerificationChecks.vue | 28 ++++++++--- t/db_dependent/api/v1/patrons_self_renewal.t | 12 ++--- 6 files changed, 100 insertions(+), 34 deletions(-) diff --git a/Koha/REST/V1/Patrons/SelfRenewal.pm b/Koha/REST/V1/Patrons/SelfRenewal.pm index 646f0be9ce8..b28a0edaf9a 100644 --- a/Koha/REST/V1/Patrons/SelfRenewal.pm +++ b/Koha/REST/V1/Patrons/SelfRenewal.pm @@ -49,10 +49,11 @@ sub start { return try { my $category = $patron->category; + my @information_messages = split( /\|/, $category->self_renewal_information_message ); my $self_renewal_settings = { - self_renewal_failure_message => $category->self_renewal_failure_message, - self_renewal_information_message => $category->self_renewal_information_message, - opac_patron_details => C4::Context->preference('OPACPatronDetails') + self_renewal_failure_message => $category->self_renewal_failure_message, + self_renewal_information_messages => \@information_messages, + opac_patron_details => C4::Context->preference('OPACPatronDetails') }; return $c->render( diff --git a/admin/categories.pl b/admin/categories.pl index cee0f9e2d10..ec2b66e4847 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -47,8 +47,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( if ( $op eq 'add_form' ) { + my $category = Koha::Patron::Categories->find($categorycode); $template->param( - category => scalar Koha::Patron::Categories->find($categorycode), + category => scalar $category, + self_renewal_information_messages => parse_renewal_info_message( $category->self_renewal_information_message ) ); if ( C4::Context->preference('EnhancedMessagingPreferences') ) { @@ -83,7 +85,7 @@ if ( $op eq 'add_form' ) { my $self_renewal_availability_start = $input->param('self_renewal_availability_start'); my $self_renewal_fines_block = $input->param('self_renewal_fines_block'); my $self_renewal_failure_message = $input->param('self_renewal_failure_message'); - my $self_renewal_information_message = $input->param('self_renewal_information_message'); + my @self_renewal_information_message = $input->multi_param('self_renewal_information_message'); my $self_renewal_if_expired = $input->param('self_renewal_if_expired'); my @branches = grep { $_ ne q{} } $input->multi_param('branches'); @@ -130,7 +132,7 @@ if ( $op eq 'add_form' ) { $category->self_renewal_availability_start($self_renewal_availability_start); $category->self_renewal_fines_block($self_renewal_fines_block); $category->self_renewal_failure_message($self_renewal_failure_message); - $category->self_renewal_information_message($self_renewal_information_message); + $category->self_renewal_information_message( parse_renewal_info_message( \@self_renewal_information_message ) ); $category->self_renewal_if_expired($self_renewal_if_expired); eval { $category->store; @@ -174,8 +176,8 @@ if ( $op eq 'add_form' ) { self_renewal_availability_start => $self_renewal_availability_start, self_renewal_fines_block => $self_renewal_fines_block, self_renewal_failure_message => $self_renewal_failure_message, - self_renewal_information_message => $self_renewal_information_message, - self_renewal_if_expired => $self_renewal_if_expired, + self_renewal_information_message => parse_renewal_info_message( \@self_renewal_information_message ), + self_renewal_if_expired => $self_renewal_if_expired, } ); eval { @@ -246,3 +248,17 @@ $template->param( output_html_with_http_headers $input, $cookie, $template->output; exit 0; + +sub parse_renewal_info_message { + my ($message) = @_; + + if ( ref($message) eq 'ARRAY' ) { + my $info_message = join( '|', @$message ); + return $info_message; + } else { + my @info_messages = split( /\|/, $message ); + return scalar(@info_messages) > 0 ? \@info_messages : [""]; + } + + return $message; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index 24dcf3e6c18..0b2b09c5bf0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -554,14 +554,22 @@ the [%- pref_noissuescharge_link | $raw | $KohaSpan -%] system preference. -
  • - - [% IF (category.self_renewal_information_message) %] - - [% ELSE %] - - [% END %] -
  • + [% FOREACH info_message IN self_renewal_information_messages %] +
  • + + [% IF (info_message) %] + + [% ELSE %] + + [% END %] + Clear + New +
  • + [% END %] +
    Information to be displayed to the patron at the start of the renewal process. This will be displayed as a Yes/No question and you can add multiple questions - an answer of 'Yes' proceeds to the next question, 'No' + exits the process and displays the Self-renewal failure message.
  • [% IF (category.self_renewal_failure_message) %] @@ -922,6 +930,29 @@ [% INCLUDE 'select2.inc' %] [% Asset.js("js/categories.js") | $raw %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/PatronSelfRenewal.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/PatronSelfRenewal.vue index c5484a43711..cfdc2e69fe7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/PatronSelfRenewal.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/PatronSelfRenewal.vue @@ -28,10 +28,14 @@ />
    @@ -96,7 +100,7 @@ export default { ...response.self_renewal_settings, }; activeStep.value = response.self_renewal_settings - .self_renewal_information_message + .self_renewal_information_messages?.length ? "verification" : response.self_renewal_settings.opac_patron_details === "1" diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/VerificationChecks.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/VerificationChecks.vue index 74d8c06b31e..0284af2ed1f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/VerificationChecks.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Islands/PatronSelfRenewal/VerificationChecks.vue @@ -1,6 +1,6 @@