From f11f49d6762ffd4745f8315d5e7c8e2b5f7495f9 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 --- admin/preferences.pl | 1 + koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt | 2 +- .../intranet-tmpl/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..d3d5e50203 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.11.0