From f9f0b470032b2564051a01321fc9559ff146c571 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 --- admin/preferences.pl | 15 ++++++++++----- koha-tmpl/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, 22 insertions(+), 8 deletions(-) diff --git a/admin/preferences.pl b/admin/preferences.pl index 1353397b9b..4cc77958d8 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -64,11 +64,16 @@ 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->{'type'} = 'modalselect'; + if( $options{'type'} ) { + if( $options{'type'} eq 'modalselect' ){ + $chunk->{'source'} = $options{'source'}; + $chunk->{'exclusions'} = $options{'exclusions'} // ""; + $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 2745deda46..83f823fa87 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/preferences.css +++ b/koha-tmpl/intranet-tmpl/prog/css/preferences.css @@ -2,7 +2,8 @@ .preference-multi, .preference-long, .preference-file, -.preference-modalselect { +.preference-modalselect, +.preference-modaljs { width: 20em; } @@ -14,11 +15,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 dc9377fc01..7373563b5a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -113,6 +113,8 @@ [% ELSIF ( CHUNK.type_modalselect ) %] + [% ELSIF ( CHUNK.type_modaljs ) %] + [% ELSIF ( CHUNK.type_multiple ) %]