Core libraries and tools part for pro architecture. It's a submodule - use from this perspective http://git.maniak.pro/madmaniak/pro
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
626 B
23 lines
626 B
class Collection.Static extends Collection
|
|
|
|
constructor: ->
|
|
super
|
|
@key_values = L.map @constructor.order, 0
|
|
|
|
more: -> @go ids: @scope
|
|
page: (i, params = {}) ->
|
|
new @constructor undefined, L.merge(params, page: i), @belongs_to
|
|
|
|
prev: ->
|
|
key = @_get_key L.first(@scope)
|
|
@go before: key, (scope) => @scope = L.reverse(scope).concat @scope
|
|
|
|
next: ->
|
|
key = @_get_key L.last(@scope)
|
|
@go after: key, (scope) => @scope = @scope.concat scope
|
|
|
|
_get_key: (id) ->
|
|
object = @_object(id); key = []
|
|
for attr in @key_values
|
|
if v = object[attr] then key.push(v) else return id
|
|
key
|
|
|