Bug 38177: Fix lengthMenu by removing extend

$.extend is doing a deep copy of the objects.

```
var dataTablesDefaults = { "lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, __('All')]] };
var mine = {lengthMenu: [[1, 2, 5, 10], [1, 2, 5, 10]]};
$.extend(true, {}, dataTablesDefaults, mine);
```
Returns:
```
[
  1,
  2,
  5,
  10,
  -1
]
```
Which is ugly and not what we want.

We only need to merge the first level. Using the spread operator (...) will do the trick here.

Note that we certainly want to adjust all the other occurrences of
extend for DT's options.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-10-22 10:52:46 +02:00 committed by Katrin Fischer
parent ca0e745c1d
commit b1cd9cccd2
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 6 additions and 5 deletions

View File

@ -89,13 +89,14 @@ export default {
$.fn.dataTable.ext.search = $.fn.dataTable.ext.search.filter(
search => search.name != "apply_filter"
)
$("#" + table_id).dataTable(
$.extend(true, {}, dataTablesDefaults, {
$("#" + table_id).dataTable({
...dataTablesDefaults,
...{
data: resources,
embed: ["package.name"],
ordering: false,
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>',
aLengthMenu: [
lengthMenu: [
[10, 20, 50, 100],
[10, 20, 50, 100],
],
@ -177,8 +178,8 @@ export default {
)
})
},
})
)
},
})
},
},
mounted() {