Bugzilla – Attachment 174770 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: Store loaded_from_state in data instead of DT's settings
Bug-38436-Store-loadedfromstate-in-data-instead-of.patch (text/plain), 5.25 KB, created by
Jonathan Druart
on 2024-11-19 10:21:02 UTC
(
hide
)
Description:
Bug 38436: Store loaded_from_state in data instead of DT's settings
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-11-19 10:21:02 UTC
Size:
5.25 KB
patch
obsolete
>From 237e1ef600eac9305f7bd6fb1c1ce5e4659f90af Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 15 Nov 2024 15:04:40 +0100 >Subject: [PATCH] Bug 38436: Store loaded_from_state in data instead of DT's > settings > >This has been introduced by bug 33484 as we needed to know if the state >was loaded (from URL or localStorage). > >If the state is loaded then we need to: >1. not redirect if only one patron to display (to prevent a blocking > situation) >2. display the table (ie. not defer loading) > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >--- > .../intranet-tmpl/prog/en/includes/patron-search.inc | 11 ++++++----- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 7 +++---- > 2 files changed, 9 insertions(+), 9 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 87afa1e7c95..f18ec6d2ac1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -423,13 +423,15 @@ > [% END %] > [% SET order_column_index = 0 %] > [% SET embed = ['extended_attributes','library'] %] >- patrons_table = $("#[% table_id | html %]").kohaTable({ >+ let table_node = $("#[% table_id | html %]"); >+ patrons_table = table_node.kohaTable({ > "ajax": { > "url": patron_search_url, > "dataSrc": function ( json ) { > [% IF redirect_if_one_result %] > // redirect if there is only 1 result. > // Do not redirect if state has been loaded >+ let loaded_from_state = table_node.data('loaded_from_state'); > if ( !loaded_from_state && first_draw && json.recordsFiltered == 1 ) { > let url = '[% redirect_url | url %]'.indexOf("?") != -1 > ? '[% redirect_url | url %]&borrowernumber=' + json.data[0].patron_id >@@ -777,8 +779,7 @@ > parent_block.find(".searchpattern").parent().hide(); > }); > >- let table_dt = patrons_table.DataTable(); >- let loaded_from_state = table_dt.settings()[0].loaded_from_state; >+ let loaded_from_state = patrons_table.data('loaded_from_state'); > if ( !defer_loading || loaded_from_state ) { > patron_search_form.submit(); > } >@@ -882,7 +883,7 @@ > $("#[% table_id | html %]_search_results").show(); > > let table_dt = patrons_table.DataTable(); >- let loaded_from_state = table_dt.settings()[0].loaded_from_state; >+ let loaded_from_state = patrons_table.data('loaded_from_state'); > if ( !loaded_from_state ) { > table_dt.search("").columns().search(""); > [% FOR c IN columns %] >@@ -898,7 +899,7 @@ > [% END %] > [% END %] > } >- table_dt.settings()[0].loaded_from_state = false; >+ patrons_table.data('loaded_from_state', false); > first_draw = 1; // Only redirect if we are coming from here > table_dt.draw(); > [% IF display_search_description %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index ceaa5f44f45..bebcee9a2e9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -907,7 +907,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){ > const url = new URL(window.location.href); > let state_from_url = url.searchParams.get( table_key + '_state'); > if ( state_from_url ) { >- settings.loaded_from_state = true; >+ $("#" + settings.nTable.id).data('loaded_from_state', true); > return JSON.parse(atob(state_from_url)); > } > >@@ -919,7 +919,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){ > state = JSON.parse(state); > > if (default_save_state_search ) { >- settings.loaded_from_state = true; >+ $("#" + settings.nTable.id).data('loaded_from_state', true); > } else { > delete state.search; > state.columns.forEach(c => delete c.search ); >@@ -953,7 +953,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){ > ); > }; > let stateLoadParams = function (settings, data) { >- if (!settings.loaded_from_state) return; >+ if (!$("#" + settings.nTable.id).data('loaded_from_state')) return; > > if (data.external_filters) { > Object.keys(external_filter_nodes).forEach((k, i) => { >@@ -1036,7 +1036,6 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){ > 'emptyTable': (options.emptyTable) ? options.emptyTable : __("No data available in table") > }, > 'ajax': _dt_default_ajax({default_filters, options}), >- loaded_from_state: false, > }, options); > } > >-- >2.34.1
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