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 206-210 function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) { Link Here
206
    return table;
206
    return table;
207
}
207
}
208
208
209
210
/* get_columns_saved_state checks for a DataTables configuration saved
211
* in the browser's local storage. If it is present, the columns
212
* configuration supplied by Koha is overwritten
213
*
214
* It takes two parameters:
215
*  - localstorage_config, the DataTables saved state object from local storage
216
*  - columns_settings, the columns settings object supplied by the template
217
*
218
* An example:
219
*
220
*    var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %];
221
*    var saved_table = localStorage.getItem("DataTables_TABLE_ID_/cgi-bin/koha/PATH/TO/SCRIPT.pl");
222
*    var updated_settings = get_columns_saved_state( saved_table, columns_settings );
223
*
224
*    KohaTable("TABLE_ID", {
225
*        "stateSave": true
226
*    }, updated_settings);
227
*/
228
229
function get_columns_saved_state( localstorage_config, columns_settings ){
230
    var tables = JSON.parse( localstorage_config );
231
    // if a table configuration was found in local storage, parse it
232
    if( tables ){
233
        var stateSave_column_visibility = [];
234
        $(tables.columns).each(function(){
235
            stateSave_column_visibility.push( this.visible === true ? 0 : 1 );
236
        });
237
        $.each( columns_settings, function( index, key ){
238
            if( stateSave_column_visibility[ index ] !== columns_settings[key] ){
239
                columns_settings[ index ].is_hidden = stateSave_column_visibility[ index ];
240
            }
241
        });
242
        return columns_settings;
243
    } else {
244
        return columns_settings;
245
    }
246
}
247
209
</script>
248
</script>
210
<!-- / columns_settings.inc -->
249
<!-- / columns_settings.inc -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-2 / +5 lines)
Lines 342-347 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
342
    [% INCLUDE 'str/tinymce_i18n.inc' %]
342
    [% INCLUDE 'str/tinymce_i18n.inc' %]
343
    <script>
343
    <script>
344
        var columns_settings = [% TablesSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
344
        var columns_settings = [% TablesSettings.GetColumns( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
345
        var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
346
        var updated_settings = get_columns_saved_state(saved_table, columns_settings);
347
345
        $(document).ready(function() {
348
        $(document).ready(function() {
346
349
347
            var libraries_url = '/api/v1/libraries';
350
            var libraries_url = '/api/v1/libraries';
Lines 351-356 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
351
                },
354
                },
352
                'embed': [ 'smtp_server' ],
355
                'embed': [ 'smtp_server' ],
353
                '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>',
356
                '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>',
357
                "stateSave": true,
354
                "columnDefs": [ {
358
                "columnDefs": [ {
355
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
359
                    "targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
356
                    "render": function (data, type, row, meta) {
360
                    "render": function (data, type, row, meta) {
Lines 514-520 Libraries &rsaquo; Administration &rsaquo; Koha Link Here
514
                        "orderable": false
518
                        "orderable": false
515
                    }
519
                    }
516
                ]
520
                ]
517
            }, columns_settings);
521
            }, updated_settings);
518
522
519
            [% UNLESS library %]
523
            [% UNLESS library %]
520
                $("#Aform").on("submit", function( event ) {
524
                $("#Aform").on("submit", function( event ) {
521
- 

Return to bug 22276