From 735d3f6e4907730a92fccf21771218c71d1f566c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 26 Jun 2014 22:29:35 +0200 Subject: [PATCH] Cosmetic fixes on backlog main module. --- app/coffee/modules/backlog/main.coffee | 37 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 8197ae0b..13c56181 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -443,11 +443,13 @@ UsRolePointsSelectorDirective = ($rootscope) -> selectionTemplate = _.template(""" """) + link = ($scope, $el, $attrs) -> bindOnce $scope, "project", (project) -> roles = _.filter(project.roles, "computable") @@ -480,6 +482,7 @@ UsRolePointsSelectorDirective = ($rootscope) -> $el.on "click", ".role", (event) -> event.preventDefault() event.stopPropagation() + target = angular.element(event.currentTarget) rolScope = target.scope() $rootscope.$broadcast("uspoints:select", target.data("role-id"), target.text()) @@ -491,18 +494,23 @@ UsRolePointsSelectorDirective = ($rootscope) -> UsPointsDirective = ($repo) -> selectionTemplate = _.template(""" - + """) + pointsTemplate = _.template(""" - + """) updatePointsValue = (usPoints, usTotalPoints, pointsById, pointsDomNode, selectedRoleId) -> @@ -515,17 +523,20 @@ UsPointsDirective = ($repo) -> pointsDomNode.text("#{selectedPointsValue}/#{usTotalPoints}") calculateTotalPoints = (us, pointsById) -> - return _.reduce(_.map(us.points, (value, key) -> pointsById[value].value), (memo, num) -> memo + num) + values = _.map(us.point, (v, k) -> pointsById[v].value) + return _.reduce(values, (acc, num) -> acc + num) link = ($scope, $el, $attrs) -> $ctrl = $el.controller() us = $scope.$eval($attrs.tgUsPoints) + usPoints = us.points usTotalPoints = us.total_points pointsDom = $el.find("a") selectedRoleId = null updatingSelectedRoleId = null pointsById = $scope.pointsById + updatePointsValue(usPoints, usTotalPoints, pointsById, pointsDom, selectedRoleId) bindOnce $scope, "project", (project) ->