From 76f800f740ae796062cbdbaf2717eb35af75b1df Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 6 Nov 2020 11:17:56 +0000 Subject: [PATCH] Bug 17364: Add ability to exclude some columns from selection for system preferences Bug 22844 Added the option to provide a modal for selecting database columns for system preferences Some system preferences are limited to a subset of the columns allowed. For instance, setting branchcode in BorrowerUnwantedFields prevents adding new patrons This patch allows for defining exclusions in the .pref file To test: 1 - Alter BorroweUnwantedFields and select branchcode 2 - Attempt to add a new patron 3 - Get a message like "Something went wrong. Check the logs" 4 - Apply patches 5 - Alter the preference again 6 - Note that branchcode is unchecked and disabled 7 - Save the pref 8 - Add a patron 9 - It succeeds Signed-off-by: Fridolin Somers Signed-off-by: Katrin Fischer Bug 17364: (follow-up) Add missing filter Signed-off-by: Fridolin Somers Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit b986a8419b2012565e5bf2d4f942b06901c7ad74) Signed-off-by: Fridolin Somers --- admin/preferences.pl | 1 + .../intranet-tmpl/prog/en/modules/admin/preferences.tt | 2 +- .../prog/en/modules/admin/preferences/patrons.pref | 1 + koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js | 9 ++++++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/admin/preferences.pl b/admin/preferences.pl index a39b6dd8f9..1353397b9b 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -67,6 +67,7 @@ sub _get_chunk { if( $options{'type'} && $options{'type'} eq 'modalselect' ){ $chunk->{'source'} = $options{'source'}; + $chunk->{'exclusions'} = $options{'exclusions'} // ""; $chunk->{'type'} = 'modalselect'; } 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 54dfe5f951..dc9377fc01 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -112,7 +112,7 @@ [% END %] [% ELSIF ( CHUNK.type_modalselect ) %] - + [% ELSIF ( CHUNK.type_multiple ) %] ' + key + ''); + if( exclusions.indexOf( val ) >= 0 ){ + disabled = ' disabled="disabled" '; + checked = ""; + } else { + disabled = ""; + } + items.push(''); }); $("
", { "class": "columns-2", -- 2.39.5