travis-web/assets/scripts/app/models/extensions.coffee
Piotr Sarnacki 61f820cada Specify _finishedAt and _startedAt as dependencies for duration
Because of our partial loading implementation we need to specify
finishedAt and startedAt differently than we would normally do. For some
reason duration was not recalculated while loading record and specifying
raw attributes helps here.
2014-08-15 06:25:19 +02:00

15 lines
467 B
CoffeeScript

Travis.DurationCalculations = Ember.Mixin.create
duration: (->
if @get('notStarted')
null
else if duration = @get('_duration')
duration
else
Travis.Helpers.durationFrom(@get('startedAt'), @get('finishedAt'))
).property('_duration', 'finishedAt', 'startedAt', 'notStarted', '_finishedAt', '_startedAt')
updateTimes: ->
unless @get('isFinished')
@notifyPropertyChange '_duration'
@notifyPropertyChange 'finished_at'