From 6442f8b0400e5557869acfdcf25bc7d7b9a267a7 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 11 Jul 2014 00:20:46 +0200 Subject: [PATCH] Finishing basic visualization for user story --- app/coffee/modules/backlog/lightboxes.coffee | 2 +- app/coffee/modules/resources/tasks.coffee | 3 +- app/coffee/modules/userstories/detail.coffee | 77 +++++++++++++++++++- app/partials/issues-detail.jade | 5 -- app/partials/us-detail.jade | 18 ++--- 5 files changed, 81 insertions(+), 24 deletions(-) diff --git a/app/coffee/modules/backlog/lightboxes.coffee b/app/coffee/modules/backlog/lightboxes.coffee index 03e0a43a..3a2e41a5 100644 --- a/app/coffee/modules/backlog/lightboxes.coffee +++ b/app/coffee/modules/backlog/lightboxes.coffee @@ -58,7 +58,7 @@ CreateEditUserstoryDirective = ($repo, $model, $rs, $rootScope) -> $el.find("label.blocked").addClass("selected") if us.team_requirement $el.find("label.team-requirement").addClass("selected") - if us.is_blocked + if us.client_requirement $el.find("label.client-requirement").addClass("selected") $scope.$on "$destroy", -> diff --git a/app/coffee/modules/resources/tasks.coffee b/app/coffee/modules/resources/tasks.coffee index ca124fd5..b1fb1345 100644 --- a/app/coffee/modules/resources/tasks.coffee +++ b/app/coffee/modules/resources/tasks.coffee @@ -25,9 +25,10 @@ taiga = @.taiga resourceProvider = ($repo, $http, $urls) -> service = {} - service.list = (projectId, sprintId=null) -> + service.list = (projectId, sprintId=null, userStoryId=null) -> params = {project: projectId} params.milestone = sprintId if sprintId + params.user_story = userStoryId if userStoryId return $repo.queryMany("tasks", params) service.bulkCreate = (projectId, usId, data) -> diff --git a/app/coffee/modules/userstories/detail.coffee b/app/coffee/modules/userstories/detail.coffee index 47875458..2629df74 100644 --- a/app/coffee/modules/userstories/detail.coffee +++ b/app/coffee/modules/userstories/detail.coffee @@ -55,11 +55,10 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.project = project @scope.statusList = project.issue_statuses @scope.statusById = groupBy(project.us_statuses, (x) -> x.id) - @scope.severityList = project.severities - @scope.severityById = groupBy(project.severities, (x) -> x.id) - @scope.priorityList = project.priorities - @scope.priorityById = groupBy(project.priorities, (x) -> x.id) + @scope.taskStatusById = groupBy(project.task_statuses, (x) -> x.id) @scope.membersById = groupBy(project.memberships, (x) -> x.user) + @scope.pointsList = _.sortBy(project.points, "order") + @scope.pointsById = groupBy(@scope.pointsList, (e) -> e.id) return project loadUs: -> @@ -69,6 +68,15 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.previousUrl = "/project/#{@scope.project.slug}/us/#{@scope.us.neighbors.previous.ref}" if @scope.us.neighbors.previous.id? @scope.nextUrl = "/project/#{@scope.project.slug}/us/#{@scope.us.neighbors.next.ref}" if @scope.us.neighbors.next.id? + loadTasks: -> + # http://localhost:8000/api/v1/tasks?user_story=6 + return @rs.tasks.list(@scope.projectId, null, @scope.usId).then (tasks) => + @scope.tasks = tasks + @scope.totalTasks = tasks.length + closedTasks = _.filter(tasks, (task) => @scope.taskStatusById[task.status].is_closed) + @scope.totalClosedTasks = closedTasks.length + @scope.usProgress = 100 * @scope.totalClosedTasks / @scope.totalTasks + loadHistory: -> return @rs.userstories.history(@scope.usId).then (history) => _.each history.results, (historyResult) -> @@ -95,6 +103,7 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin) return promise.then(=> @.loadProject()) .then(=> @.loadUsersAndRoles()) .then(=> @.loadUs()) + .then(=> @.loadTasks()) .then(=> @.loadHistory()) getUserFullName: (userId) -> @@ -222,3 +231,63 @@ UsStatusDetailDirective = () -> return {link:link, require:"ngModel"} module.directive("tgUsStatusDetail", UsStatusDetailDirective) + + + + + + + + + + + + +############################################################################# +## User story points detail directive +############################################################################# + +USPointsDetailDirective = () -> + #TODO: i18n + template = _.template(""" + + """) + + link = ($scope, $el, $attrs, $model) -> + editable = $attrs.editable? + + renderUsPointsDetail = (us) -> + + rolePoints = _.clone(_.filter($scope.project.roles, "computable"), true) + _.map rolePoints, (v, k) -> + val = $scope.pointsById[us.points[v.id]].value + val = "?" if not val? + v.points = val + + html = template({ + editable: editable + totalPoints: us.total_points + rolePoints: rolePoints + }) + $el.html(html) + + $scope.$watch $attrs.ngModel, (us) -> + if us? + renderUsPointsDetail(us) + + if editable + console.log "TODO" + + return {link:link, require:"ngModel"} + +module.directive("tgUsPointsDetail", USPointsDetailDirective) diff --git a/app/partials/issues-detail.jade b/app/partials/issues-detail.jade index c8f6ec61..088046f8 100644 --- a/app/partials/issues-detail.jade +++ b/app/partials/issues-detail.jade @@ -50,10 +50,5 @@ block content section.us-assigned-to(tg-assigned-to, ng-model="issue") section.watchers(tg-watchers, ng-model="issue.watchers") - section.us-detail-settings - //TODO: remove commented from issues-detail when copied to user-story-detail - //span.button.button-gray Client requirement - //span.button.button-gray Team requirement - div.lightbox.lightbox_block.hidden include views/modules/lightbox_block diff --git a/app/partials/us-detail.jade b/app/partials/us-detail.jade index 94de9d1f..a15197f3 100644 --- a/app/partials/us-detail.jade +++ b/app/partials/us-detail.jade @@ -48,24 +48,16 @@ block content section.us-status(tg-us-status-detail, ng-model="us") div.us-detail-progress-bar - div.current-progress - span.tasks-completed 6/7 tasks completed - ul.points-per-role - li.total - span.points 10 - span.role total - - for(var x=0; x<5; x++) - li.total - span.points 10 - span.role UX + div.current-progress(style="width:{{ usProgress }}%") + span.tasks-completed {{ totalClosedTasks }}/{{ totalTasks}} tasks completed + ul.points-per-role(tg-us-points-detail, ng-model="us") section.us-assigned-to(tg-assigned-to, ng-model="us") section.watchers(tg-watchers, ng-model="us.watchers") section.us-detail-settings - span.button.button-gray(href="", title="Client requirement") Client requirement - span.button.button-gray(href="", title="Team requirement") Team requirement - span.button.button-red(href="", title="Block") Block + span.button.button-gray(href="", title="Client requirement", ng-class="us.client_requirement ? 'active' : ''") Client requirement + span.button.button-gray(href="", title="Team requirement", ng-class="us.team_requirement ? 'active' : ''") Team requirement div.lightbox.lightbox_block.hidden include views/modules/lightbox_block