Skip to content

Instantly share code, notes, and snippets.

@machty
Created June 2, 2014 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machty/ec52161e47424dd138d2 to your computer and use it in GitHub Desktop.
Save machty/ec52161e47424dd138d2 to your computer and use it in GitHub Desktop.
possible query-params helper enhancements
  • (query-params)
    • Basic form
      • e.g. (query-params page=nextPage)
      • set page to nextPage
      • any other QPs on target route get automatically filled in based on model-dependent state
      • active state: route considered inactive unless supplied params match
    • PROPOSAL: Specify params to reset
      • e.g. (query-params '-sortOrder' page=nextPage)
      • Like above, sets page to nextPage, but resets the destination value of sortOrder to its default value as originally defined on the controller.
    • PROPOSAL: Specify params to preserve
      • e.g. (query-params 'sortOrder' page=nextPage)
      • Preserves the current value of sortOrder such that it won't be reset according to model dependent state rules.
      • Note that this is just shorthand for (query-params sortOrder=sortOrder page=nextPage), but has a few benefits: 1) brevity, 2) symmetric API to resetting QPs (described above), and 3) sortOrder might be defined on a parent controller, which would require aliasing to expose to the current template.
@andremalan
Copy link

👍

@darkbaby123
Copy link

Is there a way to reset all QP in link-to? Because reseting multiple parameters using (query-params '-sortOrder' '-page' '-filter') is not convenient.

This is my proposal for resetting all things:

  1. (query-params '-all')
  2. (queyr-params reset=true)
  3. (query-params page=nextPage reset='filter1,filter2')

In the 3rd choice the page is set to nextPage, the sortOrder is preserved and the filter1 and filter2 are reset to default value.

Also I remember in a Gist there's a query-params-reset proposal. Is there a reason that it's not good so it's not considered as a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment