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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc (+39 lines)
Lines 219-223 function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { Link Here
219
    return table;
219
    return table;
220
}
220
}
221
221
222
223
/* get_columns_saved_state checks for a DataTables configuration saved
224
* in the browser's local storage. If it is present, the columns
225
* configuration supplied by Koha is overwritten
226
*
227
* It takes two parameters:
228
*  - localstorage_config, the DataTables saved state object from local storage
229
*  - columns_settings, the columns settings object supplied by the template
230
*
231
* An example:
232
*
233
*    var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %];
234
*    var saved_table = localStorage.getItem("DataTables_TABLE_ID_/cgi-bin/koha/PATH/TO/SCRIPT.pl");
235
*    var updated_settings = get_columns_saved_state( saved_table, columns_settings );
236
*
237
*    KohaTable("TABLE_ID", {
238
*        "stateSave": true
239
*    }, updated_settings);
240
*/
241
242
function get_columns_saved_state( localstorage_config, columns_settings ){
243
    var tables = JSON.parse( localstorage_config );
244
    // if a table configuration was found in local storage, parse it
245
    if( tables ){
246
        var stateSave_column_visibility = [];
247
        $(tables.columns).each(function(){
248
            stateSave_column_visibility.push( this.visible === true ? 0 : 1 );
249
        });
250
        $.each( columns_settings, function( index, key ){
251
            if( stateSave_column_visibility[ index ] !== columns_settings[key] ){
252
                columns_settings[ index ].is_hidden = stateSave_column_visibility[ index ];
253
            }
254
        });
255
        return columns_settings;
256
    } else {
257
        return columns_settings;
258
    }
259
}
260
222
</script>
261
</script>
223
<!-- / columns_settings.inc -->
262
<!-- / columns_settings.inc -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-2 / +5 lines)
Lines 492-497 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
492
    [% INCLUDE 'str/tinymce_i18n.inc' %]
492
    [% INCLUDE 'str/tinymce_i18n.inc' %]
493
    <script>
493
    <script>
494
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
494
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
495
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
496
        var updated_settings = get_columns_saved_state(saved_table, table_settings);
497
495
        $(document).ready(function() {
498
        $(document).ready(function() {
496
499
497
            var libraries_url = '/api/v1/libraries';
500
            var libraries_url = '/api/v1/libraries';
Lines 501-506 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
501
                },
504
                },
502
                'embed': [ 'smtp_server' ],
505
                'embed': [ 'smtp_server' ],
503
                'emptyTable': '<div class="dialog message">'+_("There are no libraries defined.")+' <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">'+_("Start defining libraries")+'</a>.</div>',
506
                'emptyTable': '<div class="dialog message">'+_("There are no libraries defined.")+' <a href="/cgi-bin/koha/admin/branches.pl?op=add_form">'+_("Start defining libraries")+'</a>.</div>',
507
                "stateSave": true,
504
                "columnDefs": [ {
508
                "columnDefs": [ {
505
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
509
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
506
                    "render": function (data, type, row, meta) {
510
                    "render": function (data, type, row, meta) {
Lines 667-673 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
667
                        "orderable": false
671
                        "orderable": false
668
                    }
672
                    }
669
                ]
673
                ]
670
            }, table_settings);
674
            }, updated_settings);
671
675
672
            [% UNLESS library %]
676
            [% UNLESS library %]
673
                $("#Aform").on("submit", function( event ) {
677
                $("#Aform").on("submit", function( event ) {
674
- 

Return to bug 22276