From 27fdaf59bf387d7cdc1762a4df36a6c893a4f2bf Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 3 May 2019 13:56:02 +0000 Subject: [PATCH] Bug 22844: Simplify the process of selecting database columns for system preferences This patch introduces a new way for users to select database columns for system preferences like BorrowerMandatoryField, which currently require hand-typing of database names. This new system uses a JSON file containing label:column pairs for database columns which are relevant to preferences which reference borrower table columns. My intention was to have user-friendly values as the labels, but embedding English strings in JSON would make them untranslatable. The following preferences are affected: - BorrowerMandatoryField - BorrowerUnwantedField - PatronSelfModificationBorrowerUnwantedField - PatronSelfRegistrationBorrowerMandatoryField - PatronSelfRegistrationBorrowerUnwantedField To test, apply the patch and regenerate the staff client CSS. restart_all to make sure the updated .pref file is used. - Go to Administration -> System preferences, and search for "PatronSelf" - The input fields for PatronSelfModificationBorrowerUnwantedField, PatronSelfRegistrationBorrowerMandatoryField, and PatronSelfRegistrationBorrowerUnwantedField should appear as "locked" (read-only) inputs. - Clicking the input field should trigger a modal window with checkboxes for each available column from the borrowers table. - Test that the "select all" and "clear all" links work correctly. - Test that the "cancel" link closes the modal without saving your selections. - Test that the "Save" button closes the modal, copies your selections to the form field, and triggers the preference-saving function (this eliminates the need to click a save button again after closing the modal). - Test this process by making modifications to all three different preferences, confirming that the right data is preselected each time the modal is shown and the right data is saved to the right field each time. Signed-off-by: Hayley Mapley Signed-off-by: Marcel de Rooy Signed-off-by: David Nind --- admin/preferences.pl | 6 ++ .../intranet-tmpl/prog/css/preferences.css | 26 +++++++- .../prog/css/src/staff-global.scss | 5 ++ .../prog/en/modules/admin/preferences.tt | 29 ++++++++- .../modules/admin/preferences/borrowers.json | 53 ++++++++++++++++ .../en/modules/admin/preferences/opac.pref | 12 ++-- .../en/modules/admin/preferences/patrons.pref | 7 ++- .../prog/js/pages/preferences.js | 61 ++++++++++++++++++- 8 files changed, 187 insertions(+), 12 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json diff --git a/admin/preferences.pl b/admin/preferences.pl index 9c785bda94..551b8a3c49 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -64,6 +64,12 @@ sub _get_chunk { if( $options{'syntax'} ){ $chunk->{'syntax'} = $options{'syntax'}; } + + if( $options{'type'} && $options{'type'} eq 'modalselect' ){ + $chunk->{'source'} = $options{'source'}; + $chunk->{'type'} = 'modalselect'; + } + if ( $options{'class'} && $options{'class'} eq 'password' ) { $chunk->{'input_type'} = 'password'; } elsif ( $options{'class'} && $options{'class'} eq 'date' ) { diff --git a/koha-tmpl/intranet-tmpl/prog/css/preferences.css b/koha-tmpl/intranet-tmpl/prog/css/preferences.css index 7ecce1be4d..0b27e49e1f 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/preferences.css +++ b/koha-tmpl/intranet-tmpl/prog/css/preferences.css @@ -1,4 +1,8 @@ -.preference-url, .preference-multi, .preference-long, .preference-file { +.preference-url, +.preference-multi, +.preference-long, +.preference-file, +.preference-modalselect { width: 20em; } @@ -10,6 +14,14 @@ width: 5em; } +input[type="text"].modalselect { + cursor: pointer; +} + +input[type="text"].modalselect:hover { + background-color: #FFC; +} + textarea.preference { width: 35em; height: 20em; @@ -134,4 +146,16 @@ span.overridden { border: 1px solid #EEE; margin: 1em 1em 1em 0; resize: vertical; +} + +#prefModal label { + display: block; + font-weight: bold; + line-height: 1.5em; +} + +.dbcolumn { + font-weight: normal; + font-family: monospace; + color: #666; } \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index 6a4f1e6c3f..f75cb2bb88 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4013,6 +4013,11 @@ input.renew { margin: .5em 0; } +.columns-2 { + columns: 2 auto; + column-gap: 2.5em; +} + .columns-3 { columns: 3 auto; column-gap: 2.5em; 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 eaad2155e3..24a9bbc99d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -98,6 +98,8 @@ [% END %] + [% ELSIF ( CHUNK.type_modalselect ) %] + [% ELSIF ( CHUNK.type_multiple ) %]