Bugzilla – Attachment 29005 Details for
Bug 9043
Adding system preferences to control the visibility of the content on the Advanced Search page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9043: Syspref improvement: add new type "multiple"
Bug-9043-Syspref-improvement-add-new-type-multiple.patch (text/plain), 5.37 KB, created by
Jonathan Druart
on 2014-06-19 11:01:34 UTC
(
hide
)
Description:
Bug 9043: Syspref improvement: add new type "multiple"
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-06-19 11:01:34 UTC
Size:
5.37 KB
patch
obsolete
>From 8a5bd2c242e37a3819e17b4088ca88e27dac103e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 19 Feb 2013 14:48:04 +0100 >Subject: [PATCH] Bug 9043: Syspref improvement: add new type "multiple" > >This patch adds a new type "multiple" for syspref. >This new type allows to select several values for one syspref. > >Signed-off-by: Koha Team Lyon 3 <koha@univ-lyon3.fr> >--- > admin/preferences.pl | 18 ++++++++++++++++-- > .../intranet-tmpl/prog/en/js/pages/preferences.js | 13 ++++++++++++- > .../intranet-tmpl/prog/en/modules/admin/preferences.tt | 12 ++++++++++++ > svc/config/systempreferences | 2 +- > 4 files changed, 41 insertions(+), 4 deletions(-) > >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 1513adc..2464554 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -17,8 +17,7 @@ > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use strict; >-use warnings; >+use Modern::Perl; > > use CGI; > use Encode; >@@ -106,6 +105,21 @@ sub _get_chunk { > map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } } > keys %{ $options{'choices'} } > ]; >+ } elsif ( $options{'multiple'} ) { >+ my @values = split /\|/, $value; >+ $chunk->{type} = 'multiple'; >+ $chunk->{CHOICES} = [ >+ sort { $a->{'text'} cmp $b->{'text'} } >+ map { >+ my $option_value = $_; >+ { >+ text => $options{multiple}->{$option_value}, >+ value => $option_value, >+ selected => grep /^$option_value$/, @values, >+ } >+ } >+ keys %{ $options{multiple} } >+ ]; > } > > $chunk->{ 'type_' . $chunk->{'type'} } = 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js >index 80b8429..23e60a8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js >@@ -3,7 +3,18 @@ > KOHA.Preferences = { > Save: function ( form ) { > modified_prefs = $( form ).find( '.modified' ); >+ // $.serialize removes empty value, we need to keep them. >+ // If a multiple select has all its entries unselected >+ var unserialized = new Array(); >+ $(modified_prefs).each(function(){ >+ if ( $(this).attr('multiple') && $(this).val() == null ) { >+ unserialized.push($(this)); >+ } >+ }); > data = modified_prefs.serialize(); >+ $(unserialized).each(function(){ >+ data += '&' + $(this).attr('name') + '='; >+ }); > if ( !data ) { > humanMsg.displayAlert( MSG_NOTHING_TO_SAVE ); > return; >@@ -46,7 +57,7 @@ $( document ).ready( function () { > $( this.form ).find( '.save-all' ).removeAttr( 'disabled' ); > $( this ).addClass( 'modified' ); > var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' ); >- if ( !name_cell.find( '.modified-warning' ).length ) >+ if ( !name_cell.find( '.modified-warning' ).length ) > name_cell.append( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' ); > KOHA.Preferences.Modified = true; > } >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 63ecaaf..d58be5b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >@@ -116,6 +116,18 @@ > </option> > [% END %] > </select> >+ [% ELSIF ( CHUNK.type_multiple ) %] >+ <select name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "choice" %]" multiple="multiple"> >+ [% FOREACH CHOICE IN CHUNK.CHOICES %] >+ [% IF ( CHOICE.selected ) %] >+ <option value="[% CHOICE.value %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% CHOICE.value %]"> >+ [% END %] >+ [% CHOICE.text %] >+ </option> >+ [% END %] >+ </select> > [% ELSIF ( CHUNK.type_textarea ) %] > <a class="expand-textarea" style="display: none" href="#">Click to Edit</a> > <textarea name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "short" %]" rows="10" cols="40">[% CHUNK.value %]</textarea> >diff --git a/svc/config/systempreferences b/svc/config/systempreferences >index deeca51..6fceb97 100755 >--- a/svc/config/systempreferences >+++ b/svc/config/systempreferences >@@ -95,7 +95,7 @@ sub set_preferences { > > next if ( !defined( $pref ) ); > >- my $value = join( ',', $query->param( $param ) ); >+ my $value = join( '|', $query->param( $param ) ); > > C4::Context->set_preference( $pref, $value ); > logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $pref . " | " . $value ); >-- >2.0.0.rc2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9043
:
13385
|
13858
|
15312
|
15328
|
15329
|
15546
|
15547
|
15792
|
19150
|
19151
|
20316
|
20317
|
20318
|
20717
|
20718
|
21643
|
21644
|
21645
|
27524
|
27525
|
27526
|
29005
|
29006
|
29007
|
29914
|
29915
|
29916
|
29945
|
29946
|
30183
|
30184
|
30185
|
30186
|
30967
|
30968
|
30969
|
31170
|
31557
|
31558
|
31559
|
31560
|
31561
|
33428
|
33429
|
33430
|
33431
|
33432
|
33617
|
33620
|
33947