Limit repos list to 30 items
This commit is contained in:
parent
7f6210ec6c
commit
7fc77e66ea
|
@ -1,3 +1,5 @@
|
||||||
|
require 'travis/limited_array'
|
||||||
|
|
||||||
Travis.ReposController = Ember.ArrayController.extend
|
Travis.ReposController = Ember.ArrayController.extend
|
||||||
defaultTab: 'recent'
|
defaultTab: 'recent'
|
||||||
sortProperties: ['sortOrder']
|
sortProperties: ['sortOrder']
|
||||||
|
@ -17,7 +19,11 @@ Travis.ReposController = Ember.ArrayController.extend
|
||||||
this["view#{$.camelize(tab)}"](params)
|
this["view#{$.camelize(tab)}"](params)
|
||||||
|
|
||||||
viewRecent: ->
|
viewRecent: ->
|
||||||
@set('content', Travis.Repo.find())
|
content = Travis.LimitedArray.create
|
||||||
|
content: Travis.Repo.find()
|
||||||
|
limit: 30
|
||||||
|
|
||||||
|
@set('content', content)
|
||||||
|
|
||||||
viewOwned: ->
|
viewOwned: ->
|
||||||
@set('content', Travis.Repo.ownedBy(Travis.app.get('currentUser.login')))
|
@set('content', Travis.Repo.ownedBy(Travis.app.get('currentUser.login')))
|
||||||
|
|
24
assets/scripts/lib/travis/limited_array.coffee
Normal file
24
assets/scripts/lib/travis/limited_array.coffee
Normal 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
|
@ -1 +1 @@
|
||||||
0f288886
|
6ca6eaf0
|
Loading…
Reference in New Issue
Block a user