Slightly better implementation of showAll for jobs in queues

This commit is contained in:
Piotr Sarnacki 2012-11-28 00:26:37 +01:00
parent 9c8f93f705
commit d1633e796a
3 changed files with 14 additions and 8 deletions

View File

@ -20,7 +20,7 @@
</ul>
{{#if queue.isMore}}
<a {{action loadMoreJobs this.queue target="view"}} class="show-more-jobs">
<a {{action showAll this.queue target="view"}} class="show-more-jobs">
{{queue.leftLength}} more jobs - show all
</a>
{{/if}}

View File

@ -38,12 +38,9 @@
templateName: 'queues/list'
controller: Em.ArrayController.create()
loadMoreJobs: (event) ->
showAll: (event) ->
queue = event.context
# nasty hack to not have to implement showAll for
# limitedArray
# TODO: implement it properly later
queue.incrementProperty('limit', 1000000)
queue.showAll()
didInsertElement: ->
queues = for queue in Travis.QUEUES

View File

@ -6,9 +6,12 @@ Travis.LimitedArray = Em.ArrayProxy.extend
@_super.apply this, arguments
arrangedContent: (->
if content = @get('content')
content = @get('content')
if @get('disable')
content
else if content
content.slice(0, @get('limit'))
).property('content', 'limit')
).property('content', 'limit', 'disable')
totalLength: (->
@get('content.length')
@ -27,9 +30,15 @@ Travis.LimitedArray = Em.ArrayProxy.extend
@get('leftLength') > 0
).property('leftLength')
showAll: ->
@set 'limit', 1000000000
@set 'disable', true
contentArrayDidChange: (array, index, removedCount, addedCount) ->
@_super.apply this, arguments
return if @get('disable')
limit = @get 'limit'
arrangedContent = @get('arrangedContent')
length = arrangedContent.get 'length'