artsy-backbone-mixins
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "artsy-backbone-mixins", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A library of Backbone mixins that DRY up some common domain logic and Artsy API rabbit holes..", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -105,3 +105,3 @@ # artsy-backbone-mixins | ||
class Artwork extends Backbone.Model | ||
class Artworks extends Backbone.Collection | ||
@@ -130,2 +130,60 @@ _.extend @prototype, Fetch(ARTSY_URL) | ||
## AToZ | ||
````coffeescript | ||
{ Fetch } = require 'artsy-backbone-mixins' | ||
{ AToZ } = require('sharify').data | ||
class Artworks extends Backbone.Collection | ||
_.extend @prototype, AToZ | ||
```` | ||
### groupByAlpha | ||
Sorts a collection groupped alphabetically based on the `alphaSortKey` function on the model. | ||
Sample output: | ||
```` | ||
{ | ||
'0-9': [ model_instance, model_instance, model_instance ], | ||
A: [ model_instance, model_instance, model_instance ], | ||
// ... | ||
Z: [ model_instance, model_instance, model_instance ] | ||
} | ||
```` | ||
````coffeescript | ||
artworks.alphaSortKey = -> @get 'sortable_id' | ||
artworks.groupByAlpha() | ||
```` | ||
### groupByAlphaWithColumns | ||
Groups collection output in a format suitable for rendering in an A-Z list with a specified number of columns. | ||
Sample output: | ||
```` | ||
[ | ||
{ letter: '0-9', columns: [ ... ] }, | ||
{ letter: 'A', columns: [ ... ] }, | ||
... | ||
{ letter: 'Z', columns: [ ... ] } | ||
] | ||
// Each column is a 2D array of objects with `href`, and `name` properties: | ||
columns: [ | ||
[ { href: '...', name: '...' }, ... { href: '...', name: '...' } ], | ||
[ { href: '...', name: '...' }, ... { href: '...', name: '...' } ], | ||
[ { href: '...', name: '...' }, ... { href: '...', name: '...' } ] | ||
] | ||
```` | ||
````coffeescript | ||
artworks.alphaSortKey = -> @get 'sortable_id' | ||
artworks.groupByAlpha() | ||
```` | ||
## Contributing | ||
@@ -132,0 +190,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26704
18
206
194