If there is only one rol no double popup is required for updating US points
parent
8c12807296
commit
65ea931a71
|
@ -495,7 +495,12 @@ UsRolePointsSelectorDirective = ($rootscope) ->
|
||||||
# Watchers
|
# Watchers
|
||||||
bindOnce $scope, "project", (project) ->
|
bindOnce $scope, "project", (project) ->
|
||||||
roles = _.filter(project.roles, "computable")
|
roles = _.filter(project.roles, "computable")
|
||||||
|
numberOfRoles = _.size(roles)
|
||||||
|
|
||||||
|
if numberOfRoles > 1
|
||||||
$el.append(selectionTemplate({ 'roles': roles }))
|
$el.append(selectionTemplate({ 'roles': roles }))
|
||||||
|
else
|
||||||
|
$el.find(".icon-arrow-bottom").remove()
|
||||||
|
|
||||||
$scope.$on "uspoints:select", (ctx, roleId, roleName) ->
|
$scope.$on "uspoints:select", (ctx, roleId, roleName) ->
|
||||||
$el.find(".popover").hide()
|
$el.find(".popover").hide()
|
||||||
|
@ -562,12 +567,17 @@ UsPointsDirective = ($repo) ->
|
||||||
us = $scope.$eval($attrs.tgUsPoints)
|
us = $scope.$eval($attrs.tgUsPoints)
|
||||||
updatingSelectedRoleId = null
|
updatingSelectedRoleId = null
|
||||||
selectedRoleId = 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) ->
|
updatePoints = (roleId) ->
|
||||||
pointsDom = $el.find("a > span.points-value")
|
pointsDom = $el.find("a > span.points-value")
|
||||||
usTotalPoints = calculateTotalPoints(us)
|
usTotalPoints = calculateTotalPoints(us)
|
||||||
us.total_points = usTotalPoints
|
us.total_points = usTotalPoints
|
||||||
if not roleId?
|
if not roleId? or numberOfRoles == 1
|
||||||
pointsDom.text(us.total_points)
|
pointsDom.text(us.total_points)
|
||||||
else
|
else
|
||||||
pointId = us.points[roleId]
|
pointId = us.points[roleId]
|
||||||
|
|
Loading…
Reference in New Issue