Bugzilla – Attachment 174727 Details for
Bug 38436
Adjust code for column visibility (after DataTables upgrade)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38436: Adjust columns_settings.inc for KohaTable
Bug-38436-Adjust-columnssettingsinc-for-KohaTable.patch (text/plain), 4.78 KB, created by
Owen Leonard
on 2024-11-18 15:41:03 UTC
(
hide
)
Description:
Bug 38436: Adjust columns_settings.inc for KohaTable
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2024-11-18 15:41:03 UTC
Size:
4.78 KB
patch
obsolete
>From 2bdb3ed6f3112e5d1563a9ade5bdfff83f12b7bc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 15 Nov 2024 16:04:23 +0100 >Subject: [PATCH] Bug 38436: Adjust columns_settings.inc for KohaTable > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > .../prog/en/includes/columns_settings.inc | 35 ++++++------------- > 1 file changed, 10 insertions(+), 25 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >index b14872e5af..61c61d8d98 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >@@ -6,9 +6,6 @@ > <script> > // default_filters is not used but keeping the same constructor as kohaTable for consistency > function KohaTable(id_selector, dt_parameters, table_settings, add_filters, default_filters, filters_options) { >- var counter = 0; >- var hidden_ids = []; >- var included_ids = []; > var selector = '#' + id_selector; > > if ( table_settings ) { >@@ -30,10 +27,9 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa > localStorage.setItem( table_key, JSON.stringify(data) ) > } > >- function set_default(table_settings, settings){ >+ function set_default(table_settings, table_dt){ > let columns = new Array(table_settings.columns.length).fill({visible: true}); >- let hidden_ids, included_ids; >- [hidden_ids, included_ids] = _dt_visibility(table_settings, settings, $("#"+settings.nTable.id)); >+ let hidden_ids = _dt_visibility(table_settings, table_dt); > hidden_ids.forEach((id, i) => { columns[id] = { visible: false } } ); > // State is not loaded if time is not passed > return { columns, time: new Date() }; >@@ -48,10 +44,10 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa > return JSON.parse(atob(state_from_url)); > } > >- if (!default_save_state) return set_default(table_settings, settings); >+ if (!default_save_state) return set_default(table_settings, this.api()); > > let state = localStorage.getItem(table_key); >- if (!state) return set_default(table_settings, settings); >+ if (!state) return set_default(table_settings, this.api()); > > state = JSON.parse(state); > >@@ -64,20 +60,6 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa > return state; > } > >- $(columns_settings).each( function() { >- var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( selector + ' th' ); >- var used_id = dt_parameters.bKohaColumnsUseNames ? named_id : counter; >- if ( used_id == -1 ) return; >- >- if ( this['is_hidden'] == "1" ) { >- hidden_ids.push( used_id ); >- } >- if ( this['cannot_be_toggled'] == "0" ) { >- included_ids.push( used_id ); >- } >- counter++; >- }); >- > if ( table_settings.hasOwnProperty('default_save_state') && table_settings['default_save_state'] === 0 ) { > localStorage.removeItem(table_key); > } >@@ -188,12 +170,13 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa > > dt_parameters[ "buttons" ] = ['clear_filter']; > >- if( included_ids.length > 0 ){ >+ let included_columns = table_settings.columns.filter(c => !c.cannot_be_toggled); >+ if( included_columns.length > 0 ){ > dt_parameters[ "buttons" ].push( > { > extend: 'colvis', > fade: 100, >- columns: included_ids, >+ columns: included_columns.map(c => "[data-colname='%s']".format(c.columnname)).join(','), > className: "columns_controls", > titleAttr: _("Columns settings"), > text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>', >@@ -297,6 +280,8 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa > } > } > >+ $(table).data('bKohaColumnsUseNames', dt_parameters.bKohaColumnsUseNames); >+ > table.dataTable(new_parameters); > var table_dt = table.DataTable(); > table_dt.on("column-visibility.dt", function(){ >@@ -306,7 +291,7 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters, defa > // has been updated according to the table's configuration > columnsInit(this); > } >- }).columns( hidden_ids ).visible( false ); >+ }); > > if ( add_filters ) { > _dt_add_filters(table, table_dt, filters_options); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38436
:
174587
|
174588
|
174589
|
174590
|
174591
|
174592
|
174593
|
174594
|
174595
|
174634
|
174641
|
174642
|
174688
|
174689
|
174690
|
174691
|
174692
|
174693
|
174694
|
174695
|
174696
|
174697
|
174698
|
174699
|
174700
|
174701
|
174702
|
174721
|
174722
|
174723
|
174724
|
174725
|
174726
|
174727
|
174728
|
174729
|
174730
|
174731
|
174732
|
174733
|
174734
|
174735
|
174736
|
174740
|
174741
|
174742
|
174743
|
174744
|
174745
|
174746
|
174747
|
174748
|
174749
|
174750
|
174751
|
174752
|
174753
|
174754
|
174755
|
174756
|
174766
|
174767
|
174768
|
174769
|
174770
|
174771
|
174772
|
174773
|
174774
|
174775
|
174776
|
174777
|
174778
|
174779
|
174780
|
174781
|
174782
|
174821
|
174967