return table;
}
+
+/* get_columns_saved_state checks for a DataTables configuration saved
+* in the browser's local storage. If it is present, the columns
+* configuration supplied by Koha is overwritten
+*
+* It takes two parameters:
+* - localstorage_config, the DataTables saved state object from local storage
+* - columns_settings, the columns settings object supplied by the template
+*
+* An example:
+*
+* var columns_settings = [% ColumnsSettings.GetColumns( 'module', 'page', 'table', 'json' ) | $raw %];
+* var saved_table = localStorage.getItem("DataTables_TABLE_ID_/cgi-bin/koha/PATH/TO/SCRIPT.pl");
+* var updated_settings = get_columns_saved_state( saved_table, columns_settings );
+*
+* KohaTable("TABLE_ID", {
+* "stateSave": true
+* }, updated_settings);
+*/
+
+function get_columns_saved_state( localstorage_config, columns_settings ){
+ var tables = JSON.parse( localstorage_config );
+ // if a table configuration was found in local storage, parse it
+ if( tables ){
+ var stateSave_column_visibility = [];
+ $(tables.columns).each(function(){
+ stateSave_column_visibility.push( this.visible === true ? 0 : 1 );
+ });
+ $.each( columns_settings, function( index, key ){
+ if( stateSave_column_visibility[ index ] !== columns_settings[key] ){
+ columns_settings[ index ].is_hidden = stateSave_column_visibility[ index ];
+ }
+ });
+ return columns_settings;
+ } else {
+ return columns_settings;
+ }
+}
+
</script>
<!-- / columns_settings.inc -->
[% INCLUDE 'str/tinymce_i18n.inc' %]
<script>
var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
+ var saved_table = localStorage.getItem("DataTables_libraries_/cgi-bin/koha/admin/branches.pl");
+ var updated_settings = get_columns_saved_state(saved_table, table_settings);
+
$(document).ready(function() {
var libraries_url = '/api/v1/libraries';
},
'embed': [ 'smtp_server' ],
'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>',
+ "stateSave": true,
"columnDefs": [ {
"targets": [0,1,3,4,7,9,10,11,12,13,14,15,16],
"render": function (data, type, row, meta) {
"orderable": false
}
]
- }, table_settings);
+ }, updated_settings);
[% UNLESS library %]
$("#Aform").on("submit", function( event ) {