From bc137cbef32771656caa1c5e8998077365c3aa54 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 == Test plan == - apply the patches - regenerate the staff client CSS (yarn build) - updatedatabase - dbic - flush_memcached - 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 Signed-off-by: Kyle M Hall Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer --- admin/preferences.pl | 6 +++ koha-tmpl/intranet-tmpl/prog/css/preferences.css | 25 ++++++++- .../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, 186 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 3b1676e0e2..c5fd6ebb8f 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 1855af15fd..2745deda46 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; @@ -152,6 +164,17 @@ span.overridden { resize: vertical; } +#prefModal label { + display: block; + font-weight: bold; + line-height: 1.5em; +} + +.dbcolumn { + font-weight: normal; + font-family: monospace; + color: #666; +} #menu ul li.active a.pref_sublink { background: #FFF none; border: 0; 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 b55b97eea8..2f65e0f2d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -4051,6 +4051,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 ccdb6211fa..4ec818f470 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -108,6 +108,8 @@ [% END %] + [% ELSIF ( CHUNK.type_modalselect ) %] + [% ELSIF ( CHUNK.type_multiple ) %]