Bug 38436: Store bKohaColumnsUseNames in data instead of DT's settings

DataTable's settings do no longer allow to store custom properties.
Here we are passing bKohaColumnsUseNames to the constructor, but we
cannot retrieve it later from DT's api.

We need to store it in data().

Test plan:
0. Do not apply this patch
1. In _dt_visibility add console.log(settings.bKohaColumnsUseNames);
   where relevant
2. Open your browser, clear localStorage entries (we want to reach the
   set_default() code)
3. Hit http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=4
Notice that the value is true then false (displayed once per columns).
This is because we are calling _dt_visibility twice:
 * with the 'settings' we passed to the constructor:
1044         [hidden_ids, included_ids] = _dt_visibility(table_settings, settings, this)
 * from set_default() where we pass the settings retrieved from DT's api
900         [hidden_ids, included_ids] = _dt_visibility(table_settings, settings, $("#"+settings.nTable.id));

4. Apply this patch, console.log again and confirm that it's now true.

Notice that everything is then buggy...

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-11-15 14:55:20 +01:00 committed by Katrin Fischer
parent 0d24de094a
commit f29ed160aa
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 4 additions and 2 deletions

View File

@ -746,9 +746,10 @@ function _dt_visibility(table_settings, settings, node){
var columns_settings = table_settings['columns'];
$(columns_settings).each( function() {
let used_id = counter;
if ( settings.bKohaColumnsUseNames ) {
let use_names = $(node).data('bKohaColumnsUseNames');
if ( use_names ) {
if (!node){
console.err("settings.bKohaColumnsUseNames is set but node not passed");
console.err("bKohaColumnsUseNames is set but node not passed");
return;
}
let selector = '#' + node.attr('id');
@ -1060,6 +1061,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){
}
}
$(this).data('bKohaColumnsUseNames', settings.bKohaColumnsUseNames);
var table = $(this).dataTable(settings);
var table_dt = table.DataTable();