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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt (-14 lines)
Lines 251-270 Link Here
251
        // This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw
251
        // This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw
252
        var to_highlight = "[% To.json( searchfield ) | $raw %]";
252
        var to_highlight = "[% To.json( searchfield ) | $raw %]";
253
        var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %];
253
        var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %];
254
        var MSG_NOTHING_TO_SAVE = _("Nothing to save");
255
        var MSG_SAVING = _("Saving...");
256
        var MSG_SAVED_PREFERENCE = _("Saved preference %s");
257
        var MSG_MODIFIED = _("modified");
258
        var MSG_MADE_CHANGES = _("You have made changes to system preferences.");
259
        var MSG_CLICK_TO_EXPAND = _("Click to expand this section");
260
        var MSG_CLICK_TO_COLLAPSE = _("Click to collapse this section");
261
        var MSG_INTERNAL_SERVER_ERROR = _( "Internal Server Error, please reload the page" );
262
        var MSG_SESSION_TIMED_OUT = _( "You need to log in again, your session has timed out" );
263
        var MSG_DATA_NOT_SAVED = _( "Error; your data might not have been saved" );
264
        var MSG_LOADING = _( "Loading..." );
265
        var MSG_ALL_VALUE_WARN = _("Note: _ALL_ value will override all other values");
266
        var MSG_UPD_LOC_FORMAT_WARN = _("The following values are not formatted correctly:");
267
        var MSG_INVALID = _( "Error: presence of invalid data prevent saving. Please make the corrections and try again." );
268
    </script>
254
    </script>
269
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
255
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
270
    [% Asset.js("js/ajax.js") | $raw %]
256
    [% Asset.js("js/ajax.js") | $raw %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/ajax.js (-4 / +4 lines)
Lines 15-38 KOHA.AJAX = { Link Here
15
        KOHA.xhr = xhr;
15
        KOHA.xhr = xhr;
16
        if ( !xhr.getResponseHeader( 'content-type' ).match( 'application/json' ) ) {
16
        if ( !xhr.getResponseHeader( 'content-type' ).match( 'application/json' ) ) {
17
            // Something really failed
17
            // Something really failed
18
            humanMsg.displayAlert( MSG_INTERNAL_SERVER_ERROR );
18
            humanMsg.displayAlert( __("Internal Server Error, please reload the page") );
19
            return;
19
            return;
20
        }
20
        }
21
21
22
        var error = eval( '(' + xhr.responseText + ')' );
22
        var error = eval( '(' + xhr.responseText + ')' );
23
23
24
        if ( error.type == 'auth' ) {
24
        if ( error.type == 'auth' ) {
25
            humanMsg.displayMsg( MSG_SESSION_TIMED_OUT );
25
            humanMsg.displayMsg( __("You need to log in again, your session has timed out") );
26
        }
26
        }
27
27
28
        if ( callback ) {
28
        if ( callback ) {
29
            callback( error );
29
            callback( error );
30
        } else {
30
        } else {
31
            humanMsg.displayAlert( MSG_DATA_NOT_SAVED );
31
            humanMsg.displayAlert( __("Error; your data might not have been saved") );
32
        }
32
        }
33
    },
33
    },
34
    MarkRunning: function ( selector, text ) {
34
    MarkRunning: function ( selector, text ) {
35
        text = text || _("Loading...");
35
        text = text || __("Loading...");
36
        $( selector )
36
        $( selector )
37
            .prop('disabled', true)
37
            .prop('disabled', true)
38
            .each( function () {
38
            .each( function () {
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js (-14 / +13 lines)
Lines 1-10 Link Here
1
/* global KOHA MSG_MADE_CHANGES CodeMirror MSG_CLICK_TO_EXPAND MSG_CLICK_TO_COLLAPSE to_highlight search_jumped humanMsg MSG_NOTHING_TO_SAVE MSG_MODIFIED MSG_SAVING MSG_SAVED_PREFERENCE dataTablesDefaults themelang */
1
/* global KOHA CodeMirror to_highlight search_jumped humanMsg dataTablesDefaults themelang */
2
// We can assume 'KOHA' exists, as we depend on KOHA.AJAX
2
// We can assume 'KOHA' exists, as we depend on KOHA.AJAX
3
3
4
KOHA.Preferences = {
4
KOHA.Preferences = {
5
    Save: function ( form ) {
5
    Save: function ( form ) {
6
        if ( ! $(form).valid() ) {
6
        if ( ! $(form).valid() ) {
7
            humanMsg.displayAlert( MSG_INVALID );
7
            humanMsg.displayAlert( __("Error: presence of invalid data prevent saving. Please make the corrections and try again.") );
8
            return;
8
            return;
9
        }
9
        }
10
10
Lines 22-31 KOHA.Preferences = { Link Here
22
            data += '&' + $(this).attr('name') + '=';
22
            data += '&' + $(this).attr('name') + '=';
23
        });
23
        });
24
        if ( !data ) {
24
        if ( !data ) {
25
            humanMsg.displayAlert( MSG_NOTHING_TO_SAVE );
25
            humanMsg.displayAlert( __("Nothing to save") );
26
            return;
26
            return;
27
        }
27
        }
28
        KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), MSG_SAVING );
28
        KOHA.AJAX.MarkRunning($(form).find('.save-all'), __("Saving...") );
29
        KOHA.AJAX.Submit( {
29
        KOHA.AJAX.Submit( {
30
            data: data,
30
            data: data,
31
            url: '/cgi-bin/koha/svc/config/systempreferences/',
31
            url: '/cgi-bin/koha/svc/config/systempreferences/',
Lines 38-44 KOHA.Preferences = { Link Here
38
        modified_prefs.each(function(){
38
        modified_prefs.each(function(){
39
            var modified_pref = $(this).attr("id");
39
            var modified_pref = $(this).attr("id");
40
            modified_pref = modified_pref.replace("pref_","");
40
            modified_pref = modified_pref.replace("pref_","");
41
            msg += "<strong>"+ MSG_SAVED_PREFERENCE.format(modified_pref) + "</strong>\n";
41
            msg += "<strong>" + __("Saved preference %s").format(modified_pref) + "</strong>\n";
42
        });
42
        });
43
        humanMsg.displayAlert(msg);
43
        humanMsg.displayAlert(msg);
44
44
Lines 54-66 function mark_modified() { Link Here
54
    $( this ).addClass( 'modified' );
54
    $( this ).addClass( 'modified' );
55
    var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' );
55
    var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' );
56
    if ( !name_cell.find( '.modified-warning' ).length )
56
    if ( !name_cell.find( '.modified-warning' ).length )
57
        name_cell.append( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' );
57
        name_cell.append('<em class="modified-warning">(' + __("modified") + ')</em>');
58
    KOHA.Preferences.Modified = true;
58
    KOHA.Preferences.Modified = true;
59
}
59
}
60
60
61
window.onbeforeunload = function () {
61
window.onbeforeunload = function () {
62
    if ( KOHA.Preferences.Modified ) {
62
    if ( KOHA.Preferences.Modified ) {
63
        return MSG_MADE_CHANGES;
63
        return __("You have made changes to system preferences.");
64
    }
64
    }
65
};
65
};
66
66
Lines 146-162 $( document ).ready( function () { Link Here
146
        $("#pref_" + target ).hide();
146
        $("#pref_" + target ).hide();
147
    });
147
    });
148
148
149
    $("h3").attr("class","expanded").attr("title",MSG_CLICK_TO_EXPAND);
149
    $("h3").attr("class", "expanded").attr("title", __("Click to collapse this section"));
150
    var collapsible = $(".collapsed,.expanded");
150
    var collapsible = $(".collapsed,.expanded");
151
151
152
    $(collapsible).on("click",function(){
152
    $(collapsible).on("click",function(){
153
        var h3Id = $(this).attr("id");
153
        var h3Id = $(this).attr("id");
154
        var panel = $("#collapse_" + h3Id);
154
        var panel = $("#collapse_" + h3Id);
155
        if(panel.is(":visible")){
155
        if(panel.is(":visible")){
156
            $(this).addClass("collapsed").removeClass("expanded").attr("title",MSG_CLICK_TO_EXPAND);
156
            $(this).addClass("collapsed").removeClass("expanded").attr("title", __("Click to expand this section") );
157
            panel.hide();
157
            panel.hide();
158
        } else {
158
        } else {
159
            $(this).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE);
159
            $(this).addClass("expanded").removeClass("collapsed").attr("title", __("Click to collapse this section") );
160
            panel.show();
160
            panel.show();
161
        }
161
        }
162
    });
162
    });
Lines 168-174 $( document ).ready( function () { Link Here
168
        href = href.replace("#","");
168
        href = href.replace("#","");
169
        var panel = $("#collapse_" + href );
169
        var panel = $("#collapse_" + href );
170
        if( panel.is(":hidden") ){
170
        if( panel.is(":hidden") ){
171
            $("#" + href ).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE);
171
            $("#" + href).addClass("expanded").removeClass("collapsed").attr("title", __("Click to collapse this section") );
172
            panel.show();
172
            panel.show();
173
        }
173
        }
174
    });
174
    });
Lines 187-193 $( document ).ready( function () { Link Here
187
    $("#pref_UpdateItemLocationOnCheckin").change(function(){
187
    $("#pref_UpdateItemLocationOnCheckin").change(function(){
188
        var the_text = $(this).val();
188
        var the_text = $(this).val();
189
        var alert_text = '';
189
        var alert_text = '';
190
        if ( the_text.indexOf('_ALL_:') != -1 ) alert_text = MSG_ALL_VALUE_WARN + '\n';
190
        if (the_text.indexOf('_ALL_:') != -1) alert_text = __("Note: _ALL_ value will override all other values") + '\n';
191
        var split_text  =the_text.split("\n");
191
        var split_text  =the_text.split("\n");
192
        var alert_issues = '';
192
        var alert_issues = '';
193
        var issue_count = 0;
193
        var issue_count = 0;
Lines 198-204 $( document ).ready( function () { Link Here
198
                issue_count++;
198
                issue_count++;
199
            }
199
            }
200
        }
200
        }
201
        if (issue_count) alert_text += "\n"+ MSG_UPD_LOC_FORMAT_WARN  +"\n"+alert_issues;
201
        if (issue_count) alert_text += "\n" + __("The following values are not formatted correctly:") + "\n" + alert_issues;
202
        if ( alert_text.length )  alert(alert_text);
202
        if ( alert_text.length )  alert(alert_text);
203
    });
203
    });
204
204
205
- 

Return to bug 26237