From f4ebad4be4629b45b9d559f3df9282bc3812a8b8 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 13 Aug 2014 14:06:18 +0200 Subject: [PATCH] Fixing searches --- app/coffee/app.coffee | 2 +- app/coffee/modules/search.coffee | 25 +++++++++++-------- app/partials/views/modules/search-filter.jade | 12 ++++----- .../views/modules/search-result-table.jade | 11 ++++++++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 3fe8e9b0..4649cbe2 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -26,7 +26,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade $routeProvider.when("/project/:pslug/", {templateUrl: "/partials/project.html"}) $routeProvider.when("/project/:pslug/backlog", {templateUrl: "/partials/backlog.html"}) $routeProvider.when("/project/:pslug/taskboard/:id", {templateUrl: "/partials/taskboard.html"}) - $routeProvider.when("/project/:pslug/search", {templateUrl: "/partials/search.html"}) + $routeProvider.when("/project/:pslug/search", {templateUrl: "/partials/search.html", reloadOnSearch: false}) $routeProvider.when("/project/:pslug/kanban", {templateUrl: "/partials/kanban.html"}) # User stories diff --git a/app/coffee/modules/search.coffee b/app/coffee/modules/search.coffee index dc89caed..609c037b 100644 --- a/app/coffee/modules/search.coffee +++ b/app/coffee/modules/search.coffee @@ -142,7 +142,7 @@ module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation", ## Search Directive ############################################################################# -SearchDirective = ($log, $compile, $templatecache, $routeparams) -> +SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) -> # linkFilters = ($scope, $el, $attrs, $ctrl) -> linkTable = ($scope, $el, $attrs, $ctrl) -> tabsDom = $el.find("section.search-filter") @@ -150,7 +150,6 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) -> getActiveSection = (data) -> maxVal = 0 - selectedSectionName = null selectedSectionData = null @@ -158,9 +157,11 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) -> continue if name == "count" if value.length > maxVal maxVal = value.length - - selectedSectionData = value selectedSectionName = name + selectedSectionData = value + + if maxVal == 0 + return {name: "userstories", value: []} return {name:selectedSectionName, value: selectedSectionData} @@ -178,6 +179,7 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) -> issues: $templatecache.get("search-issues") tasks: $templatecache.get("search-tasks") userstories: $templatecache.get("search-userstories") + wikipages: $templatecache.get("search-wikipages") } renderTableContent = (section) -> @@ -197,12 +199,13 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) -> $scope.$watch "searchResults", (data) -> lastSeatchResults = data + activeSection = getActiveSection(data) + renderFilterTabs(data) + renderTableContent(activeSection) + markSectionTabActive(activeSection) - if data - activeSection = getActiveSection(data) - renderFilterTabs(data) - renderTableContent(activeSection) - markSectionTabActive(activeSection) + $scope.$watch "searchTerm", (searchTerm) -> + $location.search("text", searchTerm) if searchTerm? $el.on "click", ".search-filter li > a", (event) -> event.preventDefault() @@ -228,9 +231,9 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) -> linkTable($scope, $el, $attrs, $ctrl) $scope.$watch "projectId", (projectId) -> - $scope.searchTerm = $routeparams.text + $scope.searchTerm = $routeparams.text if projectId? return {link:link} -module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", SearchDirective]) +module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", "$tgLocation", SearchDirective]) diff --git a/app/partials/views/modules/search-filter.jade b/app/partials/views/modules/search-filter.jade index 11b96a56..e38ad1cb 100644 --- a/app/partials/views/modules/search-filter.jade +++ b/app/partials/views/modules/search-filter.jade @@ -18,13 +18,13 @@ section.search-filter span.num 0 span.name Task - // li.wikipages(data-name="wikipages") - // a(href="#") - // span.icon.icon-wiki - // span.num 0 - // span.name Wiki Pages + li.wikipages(data-name="wikipages") + a(href="#") + span.icon.icon-wiki + span.num 0 + span.name Wiki Pages // li // a(href="#") // span.icon.icon-edit - // | 3 Users \ No newline at end of file + // | 3 Users diff --git a/app/partials/views/modules/search-result-table.jade b/app/partials/views/modules/search-result-table.jade index 19f897ea..bc986a68 100644 --- a/app/partials/views/modules/search-result-table.jade +++ b/app/partials/views/modules/search-result-table.jade @@ -44,3 +44,14 @@ script(type="text/ng-template", id="search-tasks") tg-bo-bind="task.subject") div.status.width-2(tg-listitem-task-status="task") div.points.width-1(tg-listitem-assignedto="task") + +script(type="text/ng-template", id="search-wikipages") + div.search-result-table-header + div.row.title + div.user-stories.width-4 Wiki page + div.search-result-table-body + div.row.table-main(ng-repeat="wikipage in wikipages track by wikipage.id") + div.user-stories.width-4 + div.user-story-name + a(href="", tg-nav="project-wiki-page:project=project.slug,slug=wikipage.slug", + tg-bo-bind="wikipage.slug")