If there is only one rol no double popup is required for updating US points

stable
Alejandro Alonso 2014-07-03 10:49:52 +02:00
parent 8c12807296
commit 65ea931a71
1 changed files with 12 additions and 2 deletions

View File

@ -495,7 +495,12 @@ UsRolePointsSelectorDirective = ($rootscope) ->
# Watchers
bindOnce $scope, "project", (project) ->
roles = _.filter(project.roles, "computable")
$el.append(selectionTemplate({ 'roles': roles }))
numberOfRoles = _.size(roles)
if numberOfRoles > 1
$el.append(selectionTemplate({ 'roles': roles }))
else
$el.find(".icon-arrow-bottom").remove()
$scope.$on "uspoints:select", (ctx, roleId, roleName) ->
$el.find(".popover").hide()
@ -562,12 +567,17 @@ UsPointsDirective = ($repo) ->
us = $scope.$eval($attrs.tgUsPoints)
updatingSelectedRoleId = null
selectedRoleId = null
numberOfRoles = _.size(us.points)
# Preselect the rol if we have only one
if numberOfRoles == 1
selectedRoleId = _.keys(us.points)[0]
updatePoints = (roleId) ->
pointsDom = $el.find("a > span.points-value")
usTotalPoints = calculateTotalPoints(us)
us.total_points = usTotalPoints
if not roleId?
if not roleId? or numberOfRoles == 1
pointsDom.text(us.total_points)
else
pointId = us.points[roleId]