Browse Source

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 <fridolin.somers@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Bug 17364: (follow-up) Add missing filter

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Nick Clemens 4 years ago
committed by Jonathan Druart
parent
commit
b986a8419b
  1. 1
      admin/preferences.pl
  2. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
  3. 1
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
  4. 9
      koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js

1
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';
}

2
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt

@ -112,7 +112,7 @@
[% END %]
</select>
[% ELSIF ( CHUNK.type_modalselect ) %]
<input type="text" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="modalselect preference preference-[% CHUNK.type | html %]" data-source="[% CHUNK.source | html %]" readonly="readonly" value="[% CHUNK.value | html %]"/>
<input type="text" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="modalselect preference preference-[% CHUNK.type | html %]" data-source="[% CHUNK.source | html %]" data-exclusions="[% CHUNK.exclusions | html %]" readonly="readonly" value="[% CHUNK.value | html %]"/>
[% ELSIF ( CHUNK.type_multiple ) %]
<select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]" multiple="multiple">
[% FOREACH CHOICE IN CHUNK.CHOICES %][% IF ( CHOICE.selected ) %]<option value="[% CHOICE.value | html %]" selected="selected">[% ELSE %]<option value="[% CHOICE.value | html %]">[% END %][% CHOICE.text | html %]</option>[% END %]

1
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref

@ -197,6 +197,7 @@ Patrons:
- pref: BorrowerUnwantedField
type: modalselect
source: borrowers
exclusions: branchcode
-
- "Borrowers can have the following titles:"
- pref: BorrowersTitles

9
koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js

@ -225,6 +225,7 @@ $( document ).ready( function () {
$(".modalselect").on("click", function(){
var datasource = $(this).data("source");
var exclusions = $(this).data("exclusions").split('|');
var pref_name = this.id.replace(/pref_/, '');
var pref_value = this.value;
var prefs = pref_value.split("|");
@ -238,7 +239,13 @@ $( document ).ready( function () {
} else {
checked = "";
}
items.push('<label><input class="dbcolumn_selection" type="checkbox" id="' + key + '"' + checked + ' name="pref" value="' + val + '" /> ' + key + '</label>');
if( exclusions.indexOf( val ) >= 0 ){
disabled = ' disabled="disabled" ';
checked = "";
} else {
disabled = "";
}
items.push('<label><input class="dbcolumn_selection" type="checkbox" id="' + key + '"' + checked + disabled + ' name="pref" value="' + val + '" /> ' + key + '</label>');
});
$("<div/>", {
"class": "columns-2",

Loading…
Cancel
Save