internet4000 / explorer-discogs

A work in progress to explore and play Discogs
https://explorer.radio4000.com
2 stars 0 forks source link

Sorting #52

Closed oskarrough closed 6 years ago

oskarrough commented 6 years ago

Adds a generic {{sort-by}} component to sort stuff. For now I only added it to label releases.

Example:

{{#sort-by model "year" "desc" as |sortedModel|}}
  {{#each model as |item|}}
  ...
{{/sort-by}}

Alternatives

Instead of a component we could write a helper, which would be a lot less typing. This is what https://github.com/DockYard/ember-composable-helpers does but I did not want to add a dependency yet/

{{#each-list (sort-by model "year" "desc") as |item|}}
  {{item.title}}
{{/each-list}}

OR, we could add it to each controller but since we need it in so many places a template option looks more tasty.

oskarrough commented 6 years ago

Changed the PR to use a helper instead of a component. Feel easier, less {{}} nested templates.