Fixing dates on backlog sprints edition and creation

stable
Alejandro Alonso 2014-08-27 13:45:28 +02:00
parent 592e81367b
commit 4702eaab66
2 changed files with 17 additions and 5 deletions

View File

@ -37,17 +37,23 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService) ->
estimated_start: null estimated_start: null
estimated_finish: null estimated_finish: null
} }
# FIXME: form should be initialized once and used in
# each submit...
submit = -> submit = ->
form = $el.find("form").checksley() form = $el.find("form").checksley()
if not form.validate() if not form.validate()
return return
newSprint = angular.copy($scope.sprint)
if createSprint if createSprint
promise = $repo.create("milestones", $scope.sprint) newSprint.estimated_start = moment(newSprint.estimated_start).format("YYYY-MM-DD")
newSprint.estimated_finish = moment(newSprint.estimated_finish).format("YYYY-MM-DD")
promise = $repo.create("milestones", newSprint)
else else
promise = $repo.save($scope.sprint) newSprint.setAttr("estimated_start", moment(newSprint.estimated_start).format("YYYY-MM-DD"))
newSprint.setAttr("estimated_finish", moment(newSprint.estimated_finish).format("YYYY-MM-DD"))
promise = $repo.save(newSprint)
promise.then (data) -> promise.then (data) ->
$scope.sprintsCounter += 1 if createSprint $scope.sprintsCounter += 1 if createSprint
@ -77,6 +83,9 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService) ->
createSprint = true createSprint = true
$scope.sprint.project = projectId $scope.sprint.project = projectId
$scope.sprint.name = null $scope.sprint.name = null
$scope.sprint.slug = null
$scope.sprint.estimated_start = moment($scope.sprint.estimated_start).format("DD MMM YYYY")
$scope.sprint.estimated_finish = moment($scope.sprint.estimated_finish).format("DD MMM YYYY")
lastSprintNameDom = $el.find(".last-sprint-name") lastSprintNameDom = $el.find(".last-sprint-name")
sprintName = $scope.sprints?[0].name sprintName = $scope.sprints?[0].name
@ -92,6 +101,8 @@ CreateEditSprint = ($repo, $confirm, $rs, $rootscope, lightboxService) ->
createSprint = false createSprint = false
$scope.$apply -> $scope.$apply ->
$scope.sprint = sprint $scope.sprint = sprint
$scope.sprint.estimated_start = moment($scope.sprint.estimated_start).format("DD MMM YYYY")
$scope.sprint.estimated_finish = moment($scope.sprint.estimated_finish).format("DD MMM YYYY")
$el.find(".delete-sprint").show() $el.find(".delete-sprint").show()
$el.find(".title").text("Edit sprint") #TODO i18n $el.find(".title").text("Edit sprint") #TODO i18n

View File

@ -84,6 +84,7 @@ DateSelectorDirective =->
$.selectedDate = null $.selectedDate = null
$el.picker = new Pikaday({ $el.picker = new Pikaday({
field: $el[0] field: $el[0]
format: "DD MMM YYYY"
onSelect: (date) => onSelect: (date) =>
$.selectedDate = date $.selectedDate = date
onOpen: => onOpen: =>
@ -94,7 +95,7 @@ DateSelectorDirective =->
if sprints.length > 0 if sprints.length > 0
estimatedStart = sprints[0].estimated_finish estimatedStart = sprints[0].estimated_finish
$.selectedDate = estimatedStart $.selectedDate = estimatedStart
$el.val(estimatedStart) $el.val(moment(estimatedStart).format("DD MMM YYYY"))
$el.picker.setDate(estimatedStart) $el.picker.setDate(estimatedStart)
return { return {