Adding message on admin when there is no role that can estimate and disabling edition in backlog when needed

stable
Alejandro Alonso 2014-10-14 13:19:14 +02:00 committed by David Barragán Merino
parent 5d8e429771
commit ffd9038801
3 changed files with 60 additions and 47 deletions

View File

@ -51,6 +51,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
@scope.sectionName = "Permissions" #i18n @scope.sectionName = "Permissions" #i18n
@scope.project = {} @scope.project = {}
@scope.anyComputableRole = true
promise = @.loadInitialData() promise = @.loadInitialData()
@ -67,6 +68,8 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
return @rs.projects.get(@scope.projectId).then (project) => return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project @scope.project = project
@scope.$emit('project:loaded', project) @scope.$emit('project:loaded', project)
@scope.anyComputableRole = _.some(_.map(project.roles, (point) -> point.computable))
return project return project
loadRoles: -> loadRoles: ->
@ -104,6 +107,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
return @confirm.askChoice(title, subtitle, choices).then (response) => return @confirm.askChoice(title, subtitle, choices).then (response) =>
promise = @repo.remove(@scope.role, {moveTo: response.selected}) promise = @repo.remove(@scope.role, {moveTo: response.selected})
promise.then => promise.then =>
@.loadProject()
@.loadRoles().finally -> @.loadRoles().finally ->
response.finish() response.finish()
promise.then null, => promise.then null, =>
@ -112,6 +116,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
setComputable: debounce 2000, -> setComputable: debounce 2000, ->
onSuccess = => onSuccess = =>
@confirm.notify("success") @confirm.notify("success")
@.loadProject()
onError = => onError = =>
@confirm.notify("error") @confirm.notify("error")
@ -168,6 +173,7 @@ NewRoleDirective = ($tgrepo, $confirm) ->
$scope.roles.push(role) $scope.roles.push(role)
$ctrl.setRole(role) $ctrl.setRole(role)
$el.find(".add-button").show() $el.find(".add-button").show()
$ctrl.loadProject()
onError = -> onError = ->
$confirm.notify("error") $confirm.notify("error")
@ -326,6 +332,7 @@ RolePermissionsDirective = ($rootscope, $repo, $confirm) ->
renderResume(target.parents(".category-config"), categories[categoryId]) renderResume(target.parents(".category-config"), categories[categoryId])
$rootscope.$broadcast("projects:reload") $rootscope.$broadcast("projects:reload")
$confirm.notify("success") $confirm.notify("success")
$ctrl.loadProject()
onError = -> onError = ->
$confirm.notify("error") $confirm.notify("error")

View File

@ -771,6 +771,20 @@ UsPointsDirective = ($repo) ->
if numberOfRoles == 1 if numberOfRoles == 1
selectedRoleId = _.keys(us.points)[0] selectedRoleId = _.keys(us.points)[0]
computableRoles = _.filter($scope.project.roles, "computable")
roles = _.map computableRoles, (role) ->
pointId = us.points[role.id]
pointObj = $scope.pointsById[pointId]
role = _.clone(role, true)
role.points = if pointObj.value? then pointObj.value else "?"
return role
if roles.length == 0
$el.find(".icon-arrow-bottom").remove()
$el.find("a.us-points").addClass("not-clickable")
renderPointsSelector = (us, roleId) -> renderPointsSelector = (us, roleId) ->
# Prepare data for rendering # Prepare data for rendering
points = _.map $scope.project.points, (point) -> points = _.map $scope.project.points, (point) ->
@ -794,17 +808,6 @@ UsPointsDirective = ($repo) ->
$el.find(".pop-points-open").popover().open() $el.find(".pop-points-open").popover().open()
renderRolesSelector = (us) -> renderRolesSelector = (us) ->
# Prepare data for rendering
computableRoles = _.filter($scope.project.roles, "computable")
roles = _.map computableRoles, (role) ->
pointId = us.points[role.id]
pointObj = $scope.pointsById[pointId]
role = _.clone(role, true)
role.points = if pointObj.value? then pointObj.value else "?"
return role
html = rolesTemplate({"roles": roles}) html = rolesTemplate({"roles": roles})
# Render into DOM and show the new created element # Render into DOM and show the new created element
@ -845,56 +848,57 @@ UsPointsDirective = ($repo) ->
renderPoints(us, null) renderPoints(us, null)
selectedRoleId = null selectedRoleId = null
$el.on "click", "a.us-points span", (event) -> if roles.length > 0
event.preventDefault() $el.on "click", "a.us-points span", (event) ->
event.stopPropagation() event.preventDefault()
event.stopPropagation()
us = $scope.$eval($attrs.tgBacklogUsPoints) us = $scope.$eval($attrs.tgBacklogUsPoints)
updatingSelectedRoleId = selectedRoleId updatingSelectedRoleId = selectedRoleId
if selectedRoleId? if selectedRoleId?
renderPointsSelector(us, selectedRoleId) renderPointsSelector(us, selectedRoleId)
else else
renderRolesSelector(us) renderRolesSelector(us)
$el.on "click", ".role", (event) -> $el.on "click", ".role", (event) ->
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
us = $scope.$eval($attrs.tgBacklogUsPoints) us = $scope.$eval($attrs.tgBacklogUsPoints)
updatingSelectedRoleId = target.data("role-id") updatingSelectedRoleId = target.data("role-id")
popRolesDom = $el.find(".pop-role") popRolesDom = $el.find(".pop-role")
popRolesDom.find("a").removeClass("active") popRolesDom.find("a").removeClass("active")
popRolesDom.find("a[data-role-id='#{updatingSelectedRoleId}']").addClass("active") popRolesDom.find("a[data-role-id='#{updatingSelectedRoleId}']").addClass("active")
renderPointsSelector(us, updatingSelectedRoleId) renderPointsSelector(us, updatingSelectedRoleId)
$el.on "click", ".point", (event) -> $el.on "click", ".point", (event) ->
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
$el.find(".pop-points-open").hide() $el.find(".pop-points-open").hide()
$el.find(".pop-role").hide() $el.find(".pop-role").hide()
us = $scope.$eval($attrs.tgBacklogUsPoints) us = $scope.$eval($attrs.tgBacklogUsPoints)
points = _.clone(us.points, true) points = _.clone(us.points, true)
points[updatingSelectedRoleId] = target.data("point-id") points[updatingSelectedRoleId] = target.data("point-id")
$scope.$apply -> $scope.$apply ->
us.points = points us.points = points
us.total_points = calculateTotalPoints(us) us.total_points = calculateTotalPoints(us)
renderPoints(us, selectedRoleId) renderPoints(us, selectedRoleId)
$repo.save(us).then -> $repo.save(us).then ->
# Little Hack for refresh. # Little Hack for refresh.
$repo.refresh(us).then -> $repo.refresh(us).then ->
$ctrl.loadProjectStats() $ctrl.loadProjectStats()
bindOnce $scope, "project", (project) -> bindOnce $scope, "project", (project) ->
# If the user has not enough permissions the click events are unbinded # If the user has not enough permissions the click events are unbinded

View File

@ -21,6 +21,8 @@ block content
| {{ role.name }} | {{ role.name }}
span ({{ role.members_count }} members with this role) span ({{ role.members_count }} members with this role)
div(ng-hide="anyComputableRole") Be careful, no role in your project have can affect the user story estimation points.
div.general-category div.general-category
| When enabled, members assigned to this role will be able to estimate the point value for user stories | When enabled, members assigned to this role will be able to estimate the point value for user stories
div.check div.check