From 4bea40d909c473b744b565af49dfaddc4110f9f8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 2 Jul 2014 17:25:28 +0200 Subject: [PATCH] Implementing searches. --- app/coffee/modules/common/directives.coffee | 21 ++++++++++++++++++- app/coffee/modules/search.coffee | 13 +++++++++--- .../views/modules/search-result-table.jade | 18 +++++++--------- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/app/coffee/modules/common/directives.coffee b/app/coffee/modules/common/directives.coffee index 29ff4192..77c4738f 100644 --- a/app/coffee/modules/common/directives.coffee +++ b/app/coffee/modules/common/directives.coffee @@ -156,6 +156,24 @@ ListItemIssueStatusDirective = -> return {link:link} +ListItemTaskStatusDirective = -> + link = ($scope, $el, $attrs) -> + task = $scope.$eval($attrs.tgListitemTaskStatus) + bindOnce $scope, "taskStatusById", (taskStatusById) -> + $el.html(taskStatusById[task.status].name) + + return {link:link} + + +ListItemUsStatusDirective = -> + link = ($scope, $el, $attrs) -> + us = $scope.$eval($attrs.tgListitemUsStatus) + bindOnce $scope, "usStatusById", (usStatusById) -> + $el.html(usStatusById[us.status].name) + + return {link:link} + + ListItemAssignedtoDirective = -> template = """
@@ -232,4 +250,5 @@ module.directive("tgListitemIssueStatus", ListItemIssueStatusDirective) module.directive("tgListitemAssignedto", ListItemAssignedtoDirective) module.directive("tgListitemPriority", ListItemPriorityDirective) module.directive("tgListitemSeverity", ListItemSeverityDirective) - +module.directive("tgListitemTaskStatus", ListItemTaskStatusDirective) +module.directive("tgListitemUsStatus", ListItemUsStatusDirective) diff --git a/app/coffee/modules/search.coffee b/app/coffee/modules/search.coffee index 3322c414..4586804f 100644 --- a/app/coffee/modules/search.coffee +++ b/app/coffee/modules/search.coffee @@ -34,9 +34,16 @@ module = angular.module("taigaSearch", []) ############################################################################# class SearchController extends mixOf(taiga.Controller, taiga.PageMixin) - @.$inject = ["$scope", "$tgRepo", "$tgResources", "$routeParams", "$q"] + @.$inject = [ + "$scope", + "$tgRepo", + "$tgResources", + "$routeParams", + "$q", + "$location" + ] - constructor: (@scope, @repo, @rs, @params, @q) -> + constructor: (@scope, @repo, @rs, @params, @q, @location) -> @scope.sectionName = "Search" promise = @.loadInitialData() @@ -60,11 +67,11 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin) return @rs.projects.get(@scope.projectId).then (project) => @scope.project = project @scope.issueStatusById = groupBy(project.issue_statuses, (x) -> x.id) + @scope.taskStatusById = groupBy(project.task_statuses, (x) -> x.id) @scope.severityById = groupBy(project.severities, (x) -> x.id) @scope.priorityById = groupBy(project.priorities, (x) -> x.id) @scope.membersById = groupBy(project.memberships, (x) -> x.user) @scope.usStatusById = groupBy(project.us_statuses, (x) -> x.id) - # @scope.usStatusList = _.sortBy(project.us_statuses, "id") return project loadSearchData: (term) -> diff --git a/app/partials/views/modules/search-result-table.jade b/app/partials/views/modules/search-result-table.jade index ba57504c..48cf992a 100644 --- a/app/partials/views/modules/search-result-table.jade +++ b/app/partials/views/modules/search-result-table.jade @@ -11,8 +11,8 @@ script(type="text/ng-template", id="search-issues") div.user-stories.width-6 div.user-story-name a(href="", tg-bo-html="issue.subject") - div.status.width-2(tg-issue-status="issue") - div.points.width-1(tg-issue-assignedto="issue") + div.status.width-2(tg-listitem-issue-status="issue") + div.points.width-1(tg-listitem-assignedto="issue") script(type="text/ng-template", id="search-userstories") div.search-result-table-header @@ -25,21 +25,19 @@ script(type="text/ng-template", id="search-userstories") div.user-stories.width-4 div.user-story-name a(href="", tg-bo-html="us.subject") - div.status.width-2 Status - div.points.width-1 12 + div.status.width-2(tg-listitem-us-status="us") + div.points.width-1(tg-bo-html="us.total_points") script(type="text/ng-template", id="search-tasks") div.search-result-table-header div.row.title - div.user-stories.width-4 Tasks + div.user-stories.width-4 Task div.status.width-2 Status - div.points.width-1 Points - div.points.width-1 Sprints + div.points.width-1 Assigned to div.search-result-table-body div.row.table-main(ng-repeat="task in tasks track by task.id") div.user-stories.width-4 div.user-story-name a(href="", tg-bo-html="task.subject") - div.status.width-2 Status - div.points.width-1 12 - div.points.width-1 54 + div.status.width-2(tg-listitem-task-status="task") + div.points.width-1(tg-listitem-assignedto="task")