Properly add new builds to builds lists

This commit is contained in:
Piotr Sarnacki 2015-02-06 18:33:10 +01:00
parent 7e1a943a80
commit 6877c3afc1
2 changed files with 10 additions and 9 deletions

View File

@ -49,7 +49,9 @@ Repo = Model.extend
builds: (->
id = @get('id')
builds = @store.find('build', event_type: 'push', repository_id: id)
builds = @store.filter('build', event_type: 'push', repository_id: id, (b) ->
b.get('repo.id') == id && b.get('eventType') == 'push'
)
# TODO: move to controller
array = ExpandableRecordArray.create
@ -57,16 +59,16 @@ Repo = Model.extend
content: Ember.A([])
array.load(builds)
id = @get('id')
array.observe(@store.all('build'), (build) -> build.get('isLoaded') && build.get('repo.id') == id && !build.get('isPullRequest') )
array.observe(builds)
array
).property()
pullRequests: (->
id = @get('id')
builds = @store.find('build', event_type: 'pull_request', repository_id: id)
builds = @store.filter('build', event_type: 'pull_request', repository_id: id, (b) ->
b.get('repo.id') == id && b.get('eventType') == 'pull_request'
)
# TODO: move to controller
array = ExpandableRecordArray.create
@ -76,7 +78,7 @@ Repo = Model.extend
array.load(builds)
id = @get('id')
array.observe(@store.all('build'), (build) -> build.get('isLoaded') && build.get('repo.id') == id && build.get('isPullRequest') )
array.observe(builds)
array
).property()

View File

@ -26,8 +26,7 @@ ExpandableRecordArray = Ember.ArrayProxy.extend
@set 'isLoading', false
@set 'isLoaded', true
observe: (collection, filterWith) ->
@set 'filterWith', filterWith
observe: (collection) ->
collection.addArrayObserver this,
willChange: 'observedArrayWillChange'
didChange: 'observedArraydidChange'
@ -42,7 +41,7 @@ ExpandableRecordArray = Ember.ArrayProxy.extend
for object in addedObjects
# TODO: I'm not sure why deleted objects get here, but I'll just filter them
# for now
if !object.get('isDeleted') && @get('filterWith').call(this, object)
if !object.get('isDeleted')
@pushObject(object) unless @contains(object)
pushObject: (record) ->