View | Details | Raw Unified | Return to bug 9043
Collapse All | Expand All

(-)a/admin/preferences.pl (-2 / +16 lines)
Lines 17-24 Link Here
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
22
21
23
use CGI;
22
use CGI;
24
use Encode;
23
use Encode;
Lines 106-111 sub _get_chunk { Link Here
106
            map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } }
105
            map { { text => $options{'choices'}->{$_}, value => $_, selected => ( $_ eq $value || ( $_ eq '' && ( $value eq '0' || !$value ) ) ) } }
107
            keys %{ $options{'choices'} }
106
            keys %{ $options{'choices'} }
108
        ];
107
        ];
108
    } elsif ( $options{'multiple'} ) {
109
        my @values = split /\|/, $value;
110
        $chunk->{type}    = 'multiple';
111
        $chunk->{CHOICES} = [
112
            sort { $a->{'text'} cmp $b->{'text'} }
113
              map {
114
                my $option_value = $_;
115
                {
116
                    text     => $options{multiple}->{$option_value},
117
                    value    => $option_value,
118
                    selected => grep /^$option_value$/, @values,
119
                }
120
              }
121
              keys %{ $options{multiple} }
122
        ];
109
    }
123
    }
110
124
111
    $chunk->{ 'type_' . $chunk->{'type'} } = 1;
125
    $chunk->{ 'type_' . $chunk->{'type'} } = 1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js (-1 / +12 lines)
Lines 3-9 Link Here
3
KOHA.Preferences = {
3
KOHA.Preferences = {
4
    Save: function ( form ) {
4
    Save: function ( form ) {
5
        modified_prefs = $( form ).find( '.modified' );
5
        modified_prefs = $( form ).find( '.modified' );
6
        // $.serialize removes empty value, we need to keep them.
7
        // If a multiple select has all its entries unselected
8
        var unserialized = new Array();
9
        $(modified_prefs).each(function(){
10
            if ( $(this).attr('multiple') && $(this).val() == null ) {
11
                unserialized.push($(this));
12
            }
13
        });
6
        data = modified_prefs.serialize();
14
        data = modified_prefs.serialize();
15
        $(unserialized).each(function(){
16
            data += '&' + $(this).attr('name') + '=';
17
        });
7
        if ( !data ) {
18
        if ( !data ) {
8
            humanMsg.displayAlert( MSG_NOTHING_TO_SAVE );
19
            humanMsg.displayAlert( MSG_NOTHING_TO_SAVE );
9
            return;
20
            return;
Lines 46-52 $( document ).ready( function () { Link Here
46
        $( this.form ).find( '.save-all' ).removeAttr( 'disabled' );
57
        $( this.form ).find( '.save-all' ).removeAttr( 'disabled' );
47
        $( this ).addClass( 'modified' );
58
        $( this ).addClass( 'modified' );
48
        var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' );
59
        var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' );
49
		if ( !name_cell.find( '.modified-warning' ).length )
60
        if ( !name_cell.find( '.modified-warning' ).length )
50
            name_cell.append( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' );
61
            name_cell.append( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' );
51
        KOHA.Preferences.Modified = true;
62
        KOHA.Preferences.Modified = true;
52
    }
63
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt (+12 lines)
Lines 116-121 Link Here
116
                        </option>
116
                        </option>
117
                        [% END %]
117
                        [% END %]
118
                    </select>
118
                    </select>
119
                    [% ELSIF ( CHUNK.type_multiple ) %]
120
                    <select name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "choice" %]" multiple="multiple">
121
                        [% FOREACH CHOICE IN CHUNK.CHOICES %]
122
                        [% IF ( CHOICE.selected ) %]
123
                        <option value="[% CHOICE.value %]" selected="selected">
124
                        [% ELSE %]
125
                        <option value="[% CHOICE.value %]">
126
                        [% END %]
127
                            [% CHOICE.text %]
128
                        </option>
129
                        [% END %]
130
                    </select>
119
                    [% ELSIF ( CHUNK.type_textarea ) %]
131
                    [% ELSIF ( CHUNK.type_textarea ) %]
120
					<a class="expand-textarea" style="display: none" href="#">Click to Edit</a>
132
					<a class="expand-textarea" style="display: none" href="#">Click to Edit</a>
121
					<textarea name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "short" %]" rows="10" cols="40">[% CHUNK.value %]</textarea>
133
					<textarea name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "short" %]" rows="10" cols="40">[% CHUNK.value %]</textarea>
(-)a/svc/config/systempreferences (-2 / +1 lines)
Lines 95-101 sub set_preferences { Link Here
95
95
96
            next if ( !defined( $pref ) );
96
            next if ( !defined( $pref ) );
97
97
98
            my $value = join( ',', $query->param( $param ) );
98
            my $value = join( '|', $query->param( $param ) );
99
99
100
            C4::Context->set_preference( $pref, $value );
100
            C4::Context->set_preference( $pref, $value );
101
            logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $pref . " | " . $value );
101
            logaction( 'SYSTEMPREFERENCE', 'MODIFY', undef, $pref . " | " . $value );
102
- 

Return to bug 9043