Fix sorting on the left sidebar

This commit is contained in:
Piotr Sarnacki 2015-11-30 13:50:14 +01:00
parent e1a334678d
commit a56e4a39c3
3 changed files with 14 additions and 8 deletions

View File

@ -60,7 +60,8 @@ var ReposListComponent = Ember.Component.extend({
} else { } else {
return []; return [];
} }
}.property('repos.[]', 'repos') }.property('repos.[]', 'repos.@each.lastBuildFinishedAt',
'repos.@each.lastBuildId')
}); });
export default ReposListComponent; export default ReposListComponent;

View File

@ -86,13 +86,14 @@ Controller = Ember.Controller.extend
this["view_#{tab}".camelize()](params) this["view_#{tab}".camelize()](params)
viewOwned: -> viewOwned: ->
@set('isLoaded', false); @set('isLoaded', false)
@get('currentUser._rawPermissions').then (data) => if user = @get('currentUser')
repos = Repo.accessibleBy(@store, data.pull).then( (reposRecordArray) => user.get('_rawPermissions').then (data) =>
@set('isLoaded', true) repos = Repo.accessibleBy(@store, data.pull).then( (reposRecordArray) =>
@set('repos', reposRecordArray) @set('isLoaded', true)
) @set('repos', reposRecordArray)
# TODO: handle error )
# TODO: handle error
viewRunning: -> viewRunning: ->

View File

@ -17,6 +17,10 @@ Repo = Model.extend
#lastBuild: DS.belongsTo('build') #lastBuild: DS.belongsTo('build')
defaultBranch: DS.belongsTo('branch', async: false) defaultBranch: DS.belongsTo('branch', async: false)
# just for sorting
lastBuildFinishedAt: Ember.computed.oneWay('defaultBranch.lastBuild.finishedAt')
lastBuildId: Ember.computed.oneWay('defaultBranch.lastBuild.id')
withLastBuild: -> withLastBuild: ->
@filter( (repo) -> repo.get('defaultBranch.lastBuild') ) @filter( (repo) -> repo.get('defaultBranch.lastBuild') )