Limit repos list to 30 items

This commit is contained in:
Piotr Sarnacki 2012-10-09 18:23:11 +02:00
parent 7f6210ec6c
commit 7fc77e66ea
5 changed files with 34 additions and 4 deletions

View File

@ -1,3 +1,5 @@
require 'travis/limited_array'
Travis.ReposController = Ember.ArrayController.extend
defaultTab: 'recent'
sortProperties: ['sortOrder']
@ -17,7 +19,11 @@ Travis.ReposController = Ember.ArrayController.extend
this["view#{$.camelize(tab)}"](params)
viewRecent: ->
@set('content', Travis.Repo.find())
content = Travis.LimitedArray.create
content: Travis.Repo.find()
limit: 30
@set('content', content)
viewOwned: ->
@set('content', Travis.Repo.ownedBy(Travis.app.get('currentUser.login')))

View File

@ -0,0 +1,24 @@
Travis.LimitedArray = Em.ArrayProxy.extend
limit: 10
init: ->
@_super.apply this, arguments
arrangedContent: (->
if content = @get('content')
content.slice(0, @get('limit'))
).property('content')
contentArrayDidChange: (array, index, removedCount, addedCount) ->
@_super.apply this, arguments
if addedCount > 0
addedObjects = array.slice(index, index + addedCount)
arrangedContent = @get('arrangedContent')
for object in addedObjects
arrangedContent.unshiftObject(object)
limit = @get 'limit'
length = arrangedContent.get 'length'
if length > limit
arrangedContent.replace(limit, length - limit)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
0f288886
6ca6eaf0