From ffd90388017f5ad199fd62a50d3a6633c1cb14e9 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 14 Oct 2014 13:19:14 +0200 Subject: [PATCH 1/3] Adding message on admin when there is no role that can estimate and disabling edition in backlog when needed --- app/coffee/modules/admin/roles.coffee | 7 ++ app/coffee/modules/backlog/main.coffee | 98 ++++++++++++++------------ app/partials/admin-roles.jade | 2 + 3 files changed, 60 insertions(+), 47 deletions(-) diff --git a/app/coffee/modules/admin/roles.coffee b/app/coffee/modules/admin/roles.coffee index 49bf2913..b3c64464 100644 --- a/app/coffee/modules/admin/roles.coffee +++ b/app/coffee/modules/admin/roles.coffee @@ -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") diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 40a8f2ec..186887b3 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -771,6 +771,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 +808,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 +848,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 diff --git a/app/partials/admin-roles.jade b/app/partials/admin-roles.jade index a93539d3..1949cb25 100644 --- a/app/partials/admin-roles.jade +++ b/app/partials/admin-roles.jade @@ -21,6 +21,8 @@ block content | {{ role.name }} 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 | When enabled, members assigned to this role will be able to estimate the point value for user stories div.check From 2bd95487e9cf06455356e911720a37261466b355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Juli=C3=A1n?= Date: Wed, 15 Oct 2014 12:40:11 +0200 Subject: [PATCH 2/3] Warning Styles for no roles with estimation permission --- app/partials/admin-roles.jade | 2 +- app/styles/modules/admin/admin-roles.scss | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/partials/admin-roles.jade b/app/partials/admin-roles.jade index 1949cb25..900332e5 100644 --- a/app/partials/admin-roles.jade +++ b/app/partials/admin-roles.jade @@ -21,7 +21,7 @@ block content | {{ role.name }} 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.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 diff --git a/app/styles/modules/admin/admin-roles.scss b/app/styles/modules/admin/admin-roles.scss index a5c6753f..1ae92901 100644 --- a/app/styles/modules/admin/admin-roles.scss +++ b/app/styles/modules/admin/admin-roles.scss @@ -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; From bf7c5b497fab93b152088344f4571ef241233f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Juli=C3=A1n?= Date: Wed, 15 Oct 2014 13:43:50 +0200 Subject: [PATCH 3/3] Removed interaction on backlog table --- app/coffee/modules/backlog/main.coffee | 1 + app/styles/modules/backlog/backlog-table.scss | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/coffee/modules/backlog/main.coffee b/app/coffee/modules/backlog/main.coffee index 186887b3..8201b4f8 100644 --- a/app/coffee/modules/backlog/main.coffee +++ b/app/coffee/modules/backlog/main.coffee @@ -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() diff --git a/app/styles/modules/backlog/backlog-table.scss b/app/styles/modules/backlog/backlog-table.scss index e42ef3b7..1ce39c08 100644 --- a/app/styles/modules/backlog/backlog-table.scss +++ b/app/styles/modules/backlog/backlog-table.scss @@ -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);