From 0afeb3a9ee4786d503a280d695e20e771aa68561 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. --- admin/preferences.pl | 6 +++ koha-tmpl/intranet-tmpl/prog/css/preferences.css | 26 ++++++++- .../intranet-tmpl/prog/css/src/staff-global.scss | 5 ++ .../prog/en/modules/admin/preferences.tt | 29 +++++++++- .../en/modules/admin/preferences/borrowers.json | 53 +++++++++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 12 ++--- .../prog/en/modules/admin/preferences/patrons.pref | 7 +-- .../intranet-tmpl/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 92c5bbe..2862e69 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 7ecce1b..0b27e49 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 c0f13ae..fefd7dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4285,6 +4285,11 @@ span { 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 764f164..c9ef8e7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -92,6 +92,8 @@ [% END %] + [% ELSIF ( CHUNK.type_modalselect ) %] + [% ELSIF ( CHUNK.type_multiple ) %]