bogdan / datagrid

Gem to create tables grids with sortable columns and filters
MIT License
1.02k stars 115 forks source link

Preserve nested query params on order links #297

Closed fabriciofreitag closed 2 years ago

fabriciofreitag commented 3 years ago

Having an URL like such:

.../admin/customers?admin_customers_grid%5Bencrypted%5D=nwB5Hd9n%2FnFMW9rjGwjtLHFhzHpnJcLLgLrHBzezvdvMAAtDFwk%2FLJ52Au9pmEPLiggin8%2BgpHN4OvQHvqQNP7Bo%2BsRYnG3gddKdphjl5ojI2e4GeRvxT%2BC2%2FTpvYiVojszq1SsT9sjZ0lSlGwgIQRPkM0SvabcPugXgK9oD7%2Bw%3D&commit=Search

Will ultimately generate order links (through datagrid_order_path) without the parameters nested within the admin_customers_grid key.

The solution to that (I believe) would be to change this to use deep_merge instead of merge.

bogdan commented 3 years ago

Valid point: you may submit a PR or I'll fix it some time next week.

bogdan commented 2 years ago

After considering that, I am not so convinced about deep_merge here.

The order should be applied to the grid that is currently displayed on the page no matter what are URL parameter, so if url parameters has grid[k1]=v1 but the grid being displayed on the page has grid[k1]=v2 the resulting URL for ordering the grid should have grid[k1]=v2 not v1 because for the user the grid he asked to be ordered is the one having v2.