From 65ea931a7187008e46807b99013739cd368b4f2c Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 3 Jul 2014 10:49:52 +0200 Subject: [PATCH] If there is only one rol no double popup is required for updating US points --- app/coffee/modules/backlog/main.coffee | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 33ba7b02..dffd2343 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -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]