From e62c84a76f7f1ac9268c588efea754f209a26f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Barrag=C3=A1n=20Merino?= Date: Mon, 2 Feb 2015 21:39:19 +0100 Subject: [PATCH] Fix Issue #2072: I can't add comments after the role points are edited. :sparkles: rolepoints reparo!!! :sparkles: --- app/coffee/modules/common/estimation.coffee | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/coffee/modules/common/estimation.coffee b/app/coffee/modules/common/estimation.coffee index 6965bd24..c3067fd9 100644 --- a/app/coffee/modules/common/estimation.coffee +++ b/app/coffee/modules/common/estimation.coffee @@ -156,7 +156,7 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) -> return $scope.project.my_permissions.indexOf("modify_us") != -1 render = (us) -> - totalPoints = if us.total_points? then us.total_points else "?" + totalPoints = calculateTotalPoints(us.points) or "?" computableRoles = _.filter($scope.project.roles, "computable") roles = _.map computableRoles, (role) -> @@ -204,8 +204,8 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) -> $el.find(".pop-points-open").show() - calculateTotalPoints = (us) -> - values = _.map(us.points, (v, k) -> $scope.pointsById[v]?.value) + calculateTotalPoints = (points) -> + values = _.map(points, (v, k) -> $scope.pointsById[v]?.value) if values.length == 0 return "0" @@ -218,15 +218,12 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) -> save = $qqueue.bindAdd (roleId, pointId) => $el.find(".popover").popover().close() - # Hell starts here - us = angular.copy($model.$modelValue) points = _.clone($model.$modelValue.points, true) points[roleId] = pointId - us.setAttr('points', points) + + us = $model.$modelValue.clone() us.points = points - us.total_points = calculateTotalPoints(us) $model.$setViewValue(us) - # Hell ends here onSuccess = -> $confirm.notify("success") @@ -236,7 +233,7 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) -> us.revert() $model.$setViewValue(us) - $repo.save($model.$modelValue).then(onSuccess, onError) + $repo.save(us).then(onSuccess, onError) $el.on "click", ".total.clickable", (event) -> event.preventDefault() @@ -275,4 +272,5 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) -> require: "ngModel" } -module.directive("tgUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", "$tgTemplate", UsEstimationDirective]) +module.directive("tgUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", "$tgTemplate", + UsEstimationDirective])