Merge pull request #104 from taigaio/point-selection-when-no-roles-allowed

Point selection when no roles allowed
stable
David Barragán Merino 2014-10-16 09:29:05 +02:00
commit 7ebe46203f
5 changed files with 75 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.project = {}
@scope.anyComputableRole = true
promise = @.loadInitialData()
@ -67,6 +68,8 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
return @rs.projects.get(@scope.projectId).then (project) =>
@scope.project = project
@scope.$emit('project:loaded', project)
@scope.anyComputableRole = _.some(_.map(project.roles, (point) -> point.computable))
return project
loadRoles: ->
@ -104,6 +107,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
return @confirm.askChoice(title, subtitle, choices).then (response) =>
promise = @repo.remove(@scope.role, {moveTo: response.selected})
promise.then =>
@.loadProject()
@.loadRoles().finally ->
response.finish()
promise.then null, =>
@ -112,6 +116,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
setComputable: debounce 2000, ->
onSuccess = =>
@confirm.notify("success")
@.loadProject()
onError = =>
@confirm.notify("error")
@ -168,6 +173,7 @@ NewRoleDirective = ($tgrepo, $confirm) ->
$scope.roles.push(role)
$ctrl.setRole(role)
$el.find(".add-button").show()
$ctrl.loadProject()
onError = ->
$confirm.notify("error")
@ -326,6 +332,7 @@ RolePermissionsDirective = ($rootscope, $repo, $confirm) ->
renderResume(target.parents(".category-config"), categories[categoryId])
$rootscope.$broadcast("projects:reload")
$confirm.notify("success")
$ctrl.loadProject()
onError = ->
$confirm.notify("error")

View File

@ -688,6 +688,7 @@ UsRolePointsSelectorDirective = ($rootscope) ->
$el.append(selectionTemplate({"roles":roles}))
else
$el.find(".icon-arrow-bottom").remove()
$el.find(".header-points").addClass("not-clickable")
$scope.$on "uspoints:select", (ctx, roleId, roleName) ->
$el.find(".popover").popover().close()
@ -771,6 +772,20 @@ UsPointsDirective = ($repo) ->
if numberOfRoles == 1
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) ->
# Prepare data for rendering
points = _.map $scope.project.points, (point) ->
@ -794,17 +809,6 @@ UsPointsDirective = ($repo) ->
$el.find(".pop-points-open").popover().open()
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})
# Render into DOM and show the new created element
@ -845,56 +849,57 @@ UsPointsDirective = ($repo) ->
renderPoints(us, null)
selectedRoleId = null
$el.on "click", "a.us-points span", (event) ->
event.preventDefault()
event.stopPropagation()
if roles.length > 0
$el.on "click", "a.us-points span", (event) ->
event.preventDefault()
event.stopPropagation()
us = $scope.$eval($attrs.tgBacklogUsPoints)
updatingSelectedRoleId = selectedRoleId
us = $scope.$eval($attrs.tgBacklogUsPoints)
updatingSelectedRoleId = selectedRoleId
if selectedRoleId?
renderPointsSelector(us, selectedRoleId)
else
renderRolesSelector(us)
if selectedRoleId?
renderPointsSelector(us, selectedRoleId)
else
renderRolesSelector(us)
$el.on "click", ".role", (event) ->
event.preventDefault()
event.stopPropagation()
target = angular.element(event.currentTarget)
$el.on "click", ".role", (event) ->
event.preventDefault()
event.stopPropagation()
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.find("a").removeClass("active")
popRolesDom.find("a[data-role-id='#{updatingSelectedRoleId}']").addClass("active")
popRolesDom = $el.find(".pop-role")
popRolesDom.find("a").removeClass("active")
popRolesDom.find("a[data-role-id='#{updatingSelectedRoleId}']").addClass("active")
renderPointsSelector(us, updatingSelectedRoleId)
renderPointsSelector(us, updatingSelectedRoleId)
$el.on "click", ".point", (event) ->
event.preventDefault()
event.stopPropagation()
$el.on "click", ".point", (event) ->
event.preventDefault()
event.stopPropagation()
target = angular.element(event.currentTarget)
$el.find(".pop-points-open").hide()
$el.find(".pop-role").hide()
target = angular.element(event.currentTarget)
$el.find(".pop-points-open").hide()
$el.find(".pop-role").hide()
us = $scope.$eval($attrs.tgBacklogUsPoints)
us = $scope.$eval($attrs.tgBacklogUsPoints)
points = _.clone(us.points, true)
points[updatingSelectedRoleId] = target.data("point-id")
points = _.clone(us.points, true)
points[updatingSelectedRoleId] = target.data("point-id")
$scope.$apply ->
us.points = points
us.total_points = calculateTotalPoints(us)
$scope.$apply ->
us.points = points
us.total_points = calculateTotalPoints(us)
renderPoints(us, selectedRoleId)
renderPoints(us, selectedRoleId)
$repo.save(us).then ->
# Little Hack for refresh.
$repo.refresh(us).then ->
$ctrl.loadProjectStats()
$repo.save(us).then ->
# Little Hack for refresh.
$repo.refresh(us).then ->
$ctrl.loadProjectStats()
bindOnce $scope, "project", (project) ->
# If the user has not enough permissions the click events are unbinded

View File

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

View File

@ -11,6 +11,12 @@
padding-left: .5rem;
}
}
.any-computable-role {
background: $red;
color: $white;
margin-bottom: .5rem;
padding: .5rem;
}
.general-category {
align-items: center;
display: flex;

View File

@ -134,6 +134,14 @@
background: lighten($green-taiga, 60%);
box-shadow: 1px 1px 10px rgba($black, .1);
}
.points {
.not-clickable {
&:hover {
color: $black;
cursor: text;
}
}
}
}
.row-selected {
@include transition (background .2s ease-in);