From 9c36e3608a87ef0c47e9285b330fd78628269ba4 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Mon, 11 Jan 2021 14:50:17 +0000 Subject: [PATCH] Bug 27378: Add new 'modaljs' syspref type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new 'modaljs' syspref type. This is similar to the existing 'modalselect' syspref type but instead of using a file to create a list of selectable options which are displayed in the modal, it assumes that anything can happen within the modal driven by JS, and whatever happens is going to return a string, that will be saved as the syspref value. In our case, the string will be all the details of the “chunks” concatenated into a string Signed-ff-by: Barry Cannon --- admin/preferences.pl | 17 +++++++++++------ .../intranet-tmpl/prog/css/preferences.css | 9 ++++++--- .../prog/en/modules/admin/preferences.tt | 2 ++ .../intranet-tmpl/prog/js/pages/preferences.js | 4 ++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/admin/preferences.pl b/admin/preferences.pl index f405419999..f0eeb0b507 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -58,12 +58,17 @@ sub _get_chunk { if( $options{'syntax'} ){ $chunk->{'syntax'} = $options{'syntax'}; } - - if( $options{'type'} && $options{'type'} eq 'modalselect' ){ - $chunk->{'source'} = $options{'source'}; - $chunk->{'exclusions'} = $options{'exclusions'} // ""; - $chunk->{'required'} = $options{'required'} // ""; - $chunk->{'type'} = 'modalselect'; + if( $options{'type'} ) { + if( $options{'type'} eq 'modalselect' ){ + $chunk->{'source'} = $options{'source'}; + $chunk->{'exclusions'} = $options{'exclusions'} // ""; + $chunk->{'required'} = $options{'required'} // ""; + $chunk->{'type'} = 'modalselect'; + } elsif( $options{'type'} eq 'modaljs' ){ + $chunk->{'type'} = 'modaljs'; + $chunk->{'initiator'} = $options{'initiator'}; + $chunk->{'processor'} = $options{'processor'}; + } } if ( $options{'class'} && $options{'class'} eq 'password' ) { diff --git a/koha-tmpl/intranet-tmpl/prog/css/preferences.css b/koha-tmpl/intranet-tmpl/prog/css/preferences.css index 60114036c9..35966f420c 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/preferences.css +++ b/koha-tmpl/intranet-tmpl/prog/css/preferences.css @@ -3,7 +3,8 @@ .preference-multi, .preference-long, .preference-file, -.preference-modalselect { +.preference-modalselect, +.preference-modaljs { width: 20em; } @@ -15,11 +16,13 @@ width: 5em; } -input[type="text"].modalselect { +input[type="text"].modalselect, +input[type="text"].modaljs { cursor: pointer; } -input[type="text"].modalselect:hover { +input[type="text"].modalselect:hover, +input[type="text"].modaljs:hover { background-color: #FFC; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt index 6842a59b13..61ffc7fb87 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -131,6 +131,8 @@ [% ELSIF ( CHUNK.type_modalselect ) %] + [% ELSIF ( CHUNK.type_modaljs ) %] + [% ELSIF ( CHUNK.type_multiple ) %]