Fix Issue #2072: I can't add comments after the role points are edited. ✨ rolepoints reparo!!! ✨
parent
366f8950b3
commit
e62c84a76f
|
@ -156,7 +156,7 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) ->
|
||||||
return $scope.project.my_permissions.indexOf("modify_us") != -1
|
return $scope.project.my_permissions.indexOf("modify_us") != -1
|
||||||
|
|
||||||
render = (us) ->
|
render = (us) ->
|
||||||
totalPoints = if us.total_points? then us.total_points else "?"
|
totalPoints = calculateTotalPoints(us.points) or "?"
|
||||||
computableRoles = _.filter($scope.project.roles, "computable")
|
computableRoles = _.filter($scope.project.roles, "computable")
|
||||||
|
|
||||||
roles = _.map computableRoles, (role) ->
|
roles = _.map computableRoles, (role) ->
|
||||||
|
@ -204,8 +204,8 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) ->
|
||||||
|
|
||||||
$el.find(".pop-points-open").show()
|
$el.find(".pop-points-open").show()
|
||||||
|
|
||||||
calculateTotalPoints = (us) ->
|
calculateTotalPoints = (points) ->
|
||||||
values = _.map(us.points, (v, k) -> $scope.pointsById[v]?.value)
|
values = _.map(points, (v, k) -> $scope.pointsById[v]?.value)
|
||||||
if values.length == 0
|
if values.length == 0
|
||||||
return "0"
|
return "0"
|
||||||
|
|
||||||
|
@ -218,15 +218,12 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) ->
|
||||||
save = $qqueue.bindAdd (roleId, pointId) =>
|
save = $qqueue.bindAdd (roleId, pointId) =>
|
||||||
$el.find(".popover").popover().close()
|
$el.find(".popover").popover().close()
|
||||||
|
|
||||||
# Hell starts here
|
|
||||||
us = angular.copy($model.$modelValue)
|
|
||||||
points = _.clone($model.$modelValue.points, true)
|
points = _.clone($model.$modelValue.points, true)
|
||||||
points[roleId] = pointId
|
points[roleId] = pointId
|
||||||
us.setAttr('points', points)
|
|
||||||
|
us = $model.$modelValue.clone()
|
||||||
us.points = points
|
us.points = points
|
||||||
us.total_points = calculateTotalPoints(us)
|
|
||||||
$model.$setViewValue(us)
|
$model.$setViewValue(us)
|
||||||
# Hell ends here
|
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$confirm.notify("success")
|
$confirm.notify("success")
|
||||||
|
@ -236,7 +233,7 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) ->
|
||||||
us.revert()
|
us.revert()
|
||||||
$model.$setViewValue(us)
|
$model.$setViewValue(us)
|
||||||
|
|
||||||
$repo.save($model.$modelValue).then(onSuccess, onError)
|
$repo.save(us).then(onSuccess, onError)
|
||||||
|
|
||||||
$el.on "click", ".total.clickable", (event) ->
|
$el.on "click", ".total.clickable", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
@ -275,4 +272,5 @@ UsEstimationDirective = ($rootScope, $repo, $confirm, $qqueue, $template) ->
|
||||||
require: "ngModel"
|
require: "ngModel"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", "$tgTemplate", UsEstimationDirective])
|
module.directive("tgUsEstimation", ["$rootScope", "$tgRepo", "$tgConfirm", "$tgQqueue", "$tgTemplate",
|
||||||
|
UsEstimationDirective])
|
||||||
|
|
Loading…
Reference in New Issue