Allow to change the place of insertion for limited array
This commit is contained in:
parent
fa5de8ba66
commit
79e6f5e037
|
@ -68,6 +68,7 @@ Travis.Store = DS.Store.extend
|
||||||
{ id: id, clientId: clientId }
|
{ id: id, clientId: clientId }
|
||||||
|
|
||||||
receive: (event, data) ->
|
receive: (event, data) ->
|
||||||
|
console.log event, data
|
||||||
[name, type] = event.split(':')
|
[name, type] = event.split(':')
|
||||||
|
|
||||||
mappings = @adapter.get('mappings')
|
mappings = @adapter.get('mappings')
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
didInsertElement: ->
|
didInsertElement: ->
|
||||||
queues = for queue in Travis.QUEUES
|
queues = for queue in Travis.QUEUES
|
||||||
Travis.LimitedArray.create
|
Travis.LimitedArray.create
|
||||||
debug: true
|
insertAtTheBeginning: false
|
||||||
content: Travis.Job.queued(queue.name), limit: 20
|
content: Travis.Job.queued(queue.name), limit: 20
|
||||||
id: "queue_#{queue.name}"
|
id: "queue_#{queue.name}"
|
||||||
name: queue.display
|
name: queue.display
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Travis.LimitedArray = Em.ArrayProxy.extend
|
Travis.LimitedArray = Em.ArrayProxy.extend
|
||||||
limit: 10
|
limit: 10
|
||||||
isLoadedBinding: 'content.isLoaded'
|
isLoadedBinding: 'content.isLoaded'
|
||||||
|
insertAtTheBeginning: true
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@_super.apply this, arguments
|
@_super.apply this, arguments
|
||||||
|
@ -46,7 +47,10 @@ Travis.LimitedArray = Em.ArrayProxy.extend
|
||||||
if addedCount > 0
|
if addedCount > 0
|
||||||
addedObjects = array.slice(index, index + addedCount)
|
addedObjects = array.slice(index, index + addedCount)
|
||||||
for object in addedObjects
|
for object in addedObjects
|
||||||
|
if @get('insertAtTheBeginning')
|
||||||
arrangedContent.unshiftObject(object)
|
arrangedContent.unshiftObject(object)
|
||||||
|
else
|
||||||
|
arrangedContent.pushObject(object)
|
||||||
|
|
||||||
if removedCount
|
if removedCount
|
||||||
removedObjects = array.slice(index, index + removedCount);
|
removedObjects = array.slice(index, index + removedCount);
|
||||||
|
@ -61,5 +65,8 @@ Travis.LimitedArray = Em.ArrayProxy.extend
|
||||||
count = limit - length
|
count = limit - length
|
||||||
while count > 0
|
while count > 0
|
||||||
if next = content.find( (object) -> !arrangedContent.contains(object) )
|
if next = content.find( (object) -> !arrangedContent.contains(object) )
|
||||||
arrangedContent.unshiftObject(next)
|
if @get('insertAtTheBeginning')
|
||||||
|
arrangedContent.unshiftObject(object)
|
||||||
|
else
|
||||||
|
arrangedContent.pushObject(object)
|
||||||
count -= 1
|
count -= 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user