Bugzilla – Attachment 177882 Details for
Bug 38255
Do not use dataTable constructor directly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38255: Allow instantiation without parameters
Bug-38255-Allow-instantiation-without-parameters.patch (text/plain), 4.49 KB, created by
Jonathan Druart
on 2025-02-12 13:44:59 UTC
(
hide
)
Description:
Bug 38255: Allow instantiation without parameters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-02-12 13:44:59 UTC
Size:
4.49 KB
patch
obsolete
>From 2549852fccf176e0efa0ec56749ae1964185941c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 17 Dec 2024 10:48:28 +0100 >Subject: [PATCH] Bug 38255: Allow instantiation without parameters > >`$(node).kohaTable()` should work. > >Without this patch we got `Uncaught TypeError: settings is null` > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 34 +++++++++---------- > .../opac-tmpl/bootstrap/js/datatables.js | 34 +++++++++---------- > 2 files changed, 32 insertions(+), 36 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 6b8370b1fe7..de9f3a71b7e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -1230,15 +1230,13 @@ function _dt_save_restore_state(table_settings, external_filter_nodes = {}) { > * @return {Object} The dataTables instance > */ > $.fn.kohaTable = function ( >- options, >+ options = {}, > table_settings, > add_filters, > default_filters, > filters_options, > external_filter_nodes > ) { >- var settings = null; >- > // Early return if the node does not exist > if (!this.length) return; > >@@ -1262,23 +1260,23 @@ function _dt_save_restore_state(table_settings, external_filter_nodes = {}) { > options.processing = true; > options.pagingType = "full_numbers"; > } >+ } > >- settings = $.extend( >- true, >- {}, >- dataTablesDefaults, >- { >- paging: true, >- searching: true, >- language: { >- emptyTable: options.emptyTable >- ? options.emptyTable >- : __("No data available in table"), >- }, >+ var settings = $.extend( >+ true, >+ {}, >+ dataTablesDefaults, >+ { >+ paging: true, >+ searching: true, >+ language: { >+ emptyTable: options.emptyTable >+ ? options.emptyTable >+ : __("No data available in table"), > }, >- options >- ); >- } >+ }, >+ options >+ ); > > settings["buttons"] = _dt_buttons({ settings, table_settings }); > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js >index d16b428263b..5abae7494d6 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js >@@ -295,9 +295,7 @@ function _dt_visibility(table_settings, table_dt) { > * available from the columns_settings template toolkit include > * @return {Object} The dataTables instance > */ >- $.fn.kohaTable = function (options, table_settings) { >- var settings = null; >- >+ $.fn.kohaTable = function (options = {}, table_settings = undefined) { > // Early return if the node does not exist > if (!this.length) return; > >@@ -310,23 +308,23 @@ function _dt_visibility(table_settings, table_dt) { > dataTablesDefaults.initComplete(settings, json); > }; > } >+ } > >- settings = $.extend( >- true, >- {}, >- dataTablesDefaults, >- { >- paging: true, >- searching: true, >- language: { >- emptyTable: options.emptyTable >- ? options.emptyTable >- : __("No data available in table"), >- }, >+ var settings = $.extend( >+ true, >+ {}, >+ dataTablesDefaults, >+ { >+ paging: true, >+ searching: true, >+ language: { >+ emptyTable: options.emptyTable >+ ? options.emptyTable >+ : __("No data available in table"), > }, >- options >- ); >- } >+ }, >+ options >+ ); > > settings["buttons"] = _dt_buttons({ settings, table_settings }); > >-- >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 38255
:
175181
|
175182
|
175183
|
175184
|
175185
|
175352
|
175598
|
175599
|
175872
|
175873
|
176062
|
176063
|
176064
|
176065
|
176066
|
176067
|
176068
|
176069
|
176070
|
176071
|
176146
|
176348
|
176349
|
176350
|
176351
|
176352
|
176353
|
176354
|
176355
|
176356
|
176357
|
176358
|
176550
|
176551
|
176552
|
176553
|
176554
|
176555
|
176556
|
176557
|
176558
|
176559
|
176560
|
177076
|
177077
|
177078
|
177079
|
177080
|
177081
|
177082
|
177083
|
177084
|
177085
|
177086
|
177214
|
177215
|
177216
|
177217
|
177218
|
177219
|
177220
|
177221
|
177222
|
177223
|
177224
|
177262
|
177875
|
177876
|
177877
|
177878
|
177879
|
177880
|
177881
| 177882 |
177883
|
177884
|
177885
|
177886