Merge branch 'master' of github.com:travis-ci/travis-ember

This commit is contained in:
Sven Fuchs 2012-10-02 23:27:31 +02:00
commit 3e25821733
7 changed files with 77 additions and 13 deletions

View File

@ -1,3 +1,4 @@
require 'travis/expandable_record_array'
require 'travis/model'
@Travis.Repository = Travis.Model.extend
@ -12,11 +13,29 @@ require 'travis/model'
lastBuild: DS.belongsTo('Travis.Build')
builds: (->
Travis.Build.byRepositoryId @get('id'), event_type: 'push'
id = @get('id')
builds = Travis.Build.byRepositoryId id, event_type: 'push'
array = Travis.ExpandableRecordArray.create
type: Travis.Build
content: Ember.A([])
store: @get('store')
array.load(builds)
array
).property()
pullRequests: (->
Travis.Build.byRepositoryId @get('id'), event_type: 'pull_request'
id = @get('id')
builds = Travis.Build.byRepositoryId id, event_type: 'pull_request'
array = Travis.ExpandableRecordArray.create
type: Travis.Build
content: Ember.A([])
store: @get('store')
array.load(builds)
array
).property()
branches: (->

View File

@ -40,9 +40,7 @@
</tbody>
</table>
<p>
<button {{action showMore on="click" target="this" isVisibleBinding="hasMore"}}>
{{t builds.show_more}}
</button>
{{view view.ShowMoreButton}}
</p>
{{else}}
<div class="loading"><span>Loading</span></div>

View File

@ -1,12 +1,28 @@
@Travis.reopen
BuildsView: Travis.View.extend
templateName: 'builds/list'
buildsBinding: 'controller'
buildsBinding: 'controller.builds'
showMore: ->
id = @get('controller.repository.id')
number = @get('controller.builds.lastObject.number')
Travis.Build.olderThanNumber(id, number)
number = @get('builds.lastObject.number')
@get('builds').load Travis.Build.olderThanNumber(id, number)
ShowMoreButton: Em.View.extend
tagName: 'button'
classNameBindings: ['isLoading']
attributeBindings: ['disabled']
isLoadingBinding: 'controller.builds.isLoading'
template: Em.Handlebars.compile('{{view.label}}')
disabledBinding: 'isLoading'
label: (->
if @get('isLoading') then 'Loading' else 'Show more'
).property('isLoading')
click: ->
@get('parentView').showMore()
BuildsItemView: Travis.View.extend
tagName: 'tr'

View File

@ -0,0 +1,29 @@
Travis.ExpandableRecordArray = DS.RecordArray.extend
isLoaded: false
isLoading: false
load: (array) ->
@set 'isLoading', true
self = this
observer = ->
if @get 'isLoaded'
content = self.get 'content'
array.removeObserver 'isLoaded', observer
array.forEach (record) ->
self.pushObject record
self.set 'isLoading', false
self.set 'isLoaded', true
array.addObserver 'isLoaded', observer
pushObject: (record) ->
ids = @get 'content'
id = record.get 'id'
clientId = record.get 'clientId'
return if ids.contains clientId
ids.pushObject clientId

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 @@
bcf31bce
73435ff6