Merge pull request #587 from taigaio/issue/3074/new-sprint-date

issue 3074 - the new sprint date starts at the end of the last open s…
stable
Alejandro 2015-08-04 14:05:45 +02:00
commit de26b64659
1 changed files with 20 additions and 7 deletions

View File

@ -105,6 +105,15 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading,
$confirm.notify("error")
$repo.remove($scope.sprint).then(onSuccess, onError)
getLastSprint = ->
openSprints = _.filter $scope.sprints, (sprint) ->
return !sprint.closed
sortedSprints = _.sortBy openSprints, (sprint) ->
return moment(sprint.estimated_finish, 'YYYY-MM-DD').format('X')
return sortedSprints[sortedSprints.length - 1]
$scope.$on "sprintform:create", (event, projectId) ->
form = $el.find("form").checksley()
form.reset()
@ -115,20 +124,24 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService, $loading,
$scope.sprint.name = null
$scope.sprint.slug = null
lastSprint = $scope.sprints[0]
lastSprint = getLastSprint()
estimatedStart = moment()
if $scope.sprint.estimated_start
estimatedStart = moment($scope.sprint.estimated_start)
else if lastSprint?
if lastSprint
estimatedStart = moment(lastSprint.estimated_finish)
else if $scope.sprint.estimated_start
estimatedStart = moment($scope.sprint.estimated_start)
$scope.sprint.estimated_start = estimatedStart.format(prettyDate)
estimatedFinish = moment().add(2, "weeks")
if $scope.sprint.estimated_finish
estimatedFinish = moment($scope.sprint.estimated_finish)
else if lastSprint?
if lastSprint
estimatedFinish = moment(lastSprint.estimated_finish).add(2, "weeks")
else if $scope.sprint.estimated_finish
estimatedFinish = moment($scope.sprint.estimated_finish)
$scope.sprint.estimated_finish = estimatedFinish.format(prettyDate)
lastSprintNameDom = $el.find(".last-sprint-name")