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 168-172 function KohaTable(id_selector, dt_parameters, columns_settings, add_filters) { Link Here
168
    return table;
168
    return table;
169
}
169
}
170
170
171
172
/* get_columns_saved_state checks for a DataTables configuration saved
173
* in the browser's local storage. If it is present, the columns
174
* configuration supplied by Koha is overwritten
175
*
176
* It takes two parameters:
177
*  - localstorage_config, the DataTables saved state object from local storage
178
*  - columns_settings, the columns settings object supplied by the template
179
*
180
* An example:
181
*
182
*    var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %];
183
*    var saved_table = localStorage.getItem("DataTables_TABLE_ID_/cgi-bin/koha/PATH/TO/SCRIPT.pl");
184
*    var updated_settings = get_columns_saved_state( saved_table, columns_settings );
185
*
186
*    KohaTable("TABLE_ID", {
187
*        "stateSave": true
188
*    }, updated_settings);
189
*/
190
191
function get_columns_saved_state( localstorage_config, columns_settings ){
192
    var tables = JSON.parse( localstorage_config );
193
    // if a table configuration was found in local storage, parse it
194
    if( tables ){
195
        var stateSave_column_visibility = [];
196
        $(tables.columns).each(function(){
197
            stateSave_column_visibility.push( this.visible === true ? 0 : 1 );
198
        });
199
        $.each( columns_settings, function( index, key ){
200
            if( stateSave_column_visibility[ index ] !== columns_settings[key] ){
201
                columns_settings[ index ].is_hidden = stateSave_column_visibility[ index ];
202
            }
203
        });
204
        return columns_settings;
205
    } else {
206
        return columns_settings;
207
    }
208
}
209
171
</script>
210
</script>
172
<!-- / columns_settings.inc -->
211
<!-- / 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