fix sprint progress bar directive

stable
Juanfran 2014-08-19 12:08:08 +02:00
parent d3b8aec8ab
commit ffed61dfeb
2 changed files with 35 additions and 1 deletions

View File

@ -54,7 +54,12 @@ BacklogSprintDirective = ($repo, $rootscope) ->
# Update progress bars # Update progress bars
$scope.$watch $attrs.tgBacklogSprint, (value) -> $scope.$watch $attrs.tgBacklogSprint, (value) ->
sprint = $scope.$eval($attrs.tgBacklogSprint) sprint = $scope.$eval($attrs.tgBacklogSprint)
progressPercentage = Math.round(100 * (sprint.closed_points / sprint.total_points))
if sprint.total_points
progressPercentage = Math.round(100 * (sprint.closed_points / sprint.total_points))
else
progressPercentage = 0
$el.find(".current-progress").css("width", "#{progressPercentage}%") $el.find(".current-progress").css("width", "#{progressPercentage}%")
$el.find(".sprint-table").disableSelection() $el.find(".sprint-table").disableSelection()

View File

@ -46,6 +46,35 @@ DateRangeDirective = ->
module.directive("tgDateRange", DateRangeDirective) module.directive("tgDateRange", DateRangeDirective)
#############################################################################
## Sprint Progress Bar Directive
#############################################################################
SprintProgressBarDirective = ->
renderProgress = ($el, percentage, visual_percentage) ->
if $el.hasClass(".current-progress")
$el.css("width", "#{percentage}%")
else
$el.find(".current-progress").css("width", "#{visual_percentage}%")
$el.find(".number").html("#{percentage} %")
link = ($scope, $el, $attrs) ->
bindOnce $scope, $attrs.tgSprintProgressbar, (sprint) ->
closedPoints = sprint.closed_points
totalPoints = sprint.total_points
percentage = 0
percentage = Math.round(100 * (closedPoints/totalPoints)) if totalPoints != 0
visual_percentage = 0
#Visual hack for .current-progress bar
visual_percentage = Math.round(98 * (closedPoints/totalPoints)) if totalPoints != 0
renderProgress($el, percentage, visual_percentage)
return {link: link}
module.directive("tgSprintProgressbar", SprintProgressBarDirective)
############################################################################# #############################################################################
## Date Selector Directive (using pikaday) ## Date Selector Directive (using pikaday)
############################################################################# #############################################################################