Skip to content

Commit

Permalink
Deep extend when adding global query params in ufTable
Browse files Browse the repository at this point in the history
At the moment if you were to use `addParams` to set a global `filter` or `sort` for a table, it would overwrite all other filters and sorts applied to the table. It doesn't seem like this was a deliberate design choice when `addParams` was introduced in 3159224. By using a deep extend instead, we can set global filters without overriding any sorts/filters set by the user. It does technically change the behavior, but I don't see a valid use case for the way it currently behaves.
  • Loading branch information
lcharette committed Nov 14, 2020
1 parent 3836585 commit 3310530
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Replaced AdminLTE credit in default footer (old link was dead).
- Lock Travis to Composer V1 to avoid error until Composer V2 support can be fixed.
- Remove whitespace at top of page templates ([#1107])
- Deep extend when adding global query params in ufTable ([#1114])

## [v4.4.3]

Expand Down Expand Up @@ -977,6 +978,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
[#1087]: https://github.com/userfrosting/UserFrosting/issues/1087
[#1092]: https://github.com/userfrosting/UserFrosting/issues/1092
[#1107]: https://github.com/userfrosting/UserFrosting/pull/1107
[#1114]: https://github.com/userfrosting/UserFrosting/pull/1114

[v4.2.0]: https://github.com/userfrosting/UserFrosting/compare/v4.1.22...v4.2.0
[v4.2.1]: https://github.com/userfrosting/UserFrosting/compare/v4.2.0...v.4.2.1
Expand Down
4 changes: 2 additions & 2 deletions app/sprinkles/core/assets/userfrosting/js/uf-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
$.extend(table.config.pager.ajaxObject.data, tableState);

// Merge in any additional parameters
$.extend(table.config.pager.ajaxObject.data, this.settings.addParams);
$.extend(true, table.config.pager.ajaxObject.data, this.settings.addParams);

return url;
};
Expand Down Expand Up @@ -526,7 +526,7 @@
delete tableState.size;

// Merge in any additional request parameters
$.extend(tableState, this.settings.addParams);
$.extend(true, tableState, this.settings.addParams);

// Causes download to begin
window.location = this.settings.dataUrl + '?' + $.param(tableState);
Expand Down

0 comments on commit 3310530

Please sign in to comment.