Fixing searches

stable
Alejandro Alonso 2014-08-13 14:06:18 +02:00
parent 445b39b609
commit f4ebad4be4
4 changed files with 32 additions and 18 deletions

View File

@ -26,7 +26,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, tgLoade
$routeProvider.when("/project/:pslug/", {templateUrl: "/partials/project.html"}) $routeProvider.when("/project/:pslug/", {templateUrl: "/partials/project.html"})
$routeProvider.when("/project/:pslug/backlog", {templateUrl: "/partials/backlog.html"}) $routeProvider.when("/project/:pslug/backlog", {templateUrl: "/partials/backlog.html"})
$routeProvider.when("/project/:pslug/taskboard/:id", {templateUrl: "/partials/taskboard.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"}) $routeProvider.when("/project/:pslug/kanban", {templateUrl: "/partials/kanban.html"})
# User stories # User stories

View File

@ -142,7 +142,7 @@ module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation",
## Search Directive ## Search Directive
############################################################################# #############################################################################
SearchDirective = ($log, $compile, $templatecache, $routeparams) -> SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
# linkFilters = ($scope, $el, $attrs, $ctrl) -> # linkFilters = ($scope, $el, $attrs, $ctrl) ->
linkTable = ($scope, $el, $attrs, $ctrl) -> linkTable = ($scope, $el, $attrs, $ctrl) ->
tabsDom = $el.find("section.search-filter") tabsDom = $el.find("section.search-filter")
@ -150,7 +150,6 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) ->
getActiveSection = (data) -> getActiveSection = (data) ->
maxVal = 0 maxVal = 0
selectedSectionName = null selectedSectionName = null
selectedSectionData = null selectedSectionData = null
@ -158,9 +157,11 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) ->
continue if name == "count" continue if name == "count"
if value.length > maxVal if value.length > maxVal
maxVal = value.length maxVal = value.length
selectedSectionData = value
selectedSectionName = name selectedSectionName = name
selectedSectionData = value
if maxVal == 0
return {name: "userstories", value: []}
return {name:selectedSectionName, value: selectedSectionData} return {name:selectedSectionName, value: selectedSectionData}
@ -178,6 +179,7 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) ->
issues: $templatecache.get("search-issues") issues: $templatecache.get("search-issues")
tasks: $templatecache.get("search-tasks") tasks: $templatecache.get("search-tasks")
userstories: $templatecache.get("search-userstories") userstories: $templatecache.get("search-userstories")
wikipages: $templatecache.get("search-wikipages")
} }
renderTableContent = (section) -> renderTableContent = (section) ->
@ -197,12 +199,13 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) ->
$scope.$watch "searchResults", (data) -> $scope.$watch "searchResults", (data) ->
lastSeatchResults = data lastSeatchResults = data
activeSection = getActiveSection(data)
renderFilterTabs(data)
renderTableContent(activeSection)
markSectionTabActive(activeSection)
if data $scope.$watch "searchTerm", (searchTerm) ->
activeSection = getActiveSection(data) $location.search("text", searchTerm) if searchTerm?
renderFilterTabs(data)
renderTableContent(activeSection)
markSectionTabActive(activeSection)
$el.on "click", ".search-filter li > a", (event) -> $el.on "click", ".search-filter li > a", (event) ->
event.preventDefault() event.preventDefault()
@ -228,9 +231,9 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams) ->
linkTable($scope, $el, $attrs, $ctrl) linkTable($scope, $el, $attrs, $ctrl)
$scope.$watch "projectId", (projectId) -> $scope.$watch "projectId", (projectId) ->
$scope.searchTerm = $routeparams.text $scope.searchTerm = $routeparams.text if projectId?
return {link:link} return {link:link}
module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", SearchDirective]) module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", "$tgLocation", SearchDirective])

View File

@ -18,13 +18,13 @@ section.search-filter
span.num 0 span.num 0
span.name Task span.name Task
// li.wikipages(data-name="wikipages") li.wikipages(data-name="wikipages")
// a(href="#") a(href="#")
// span.icon.icon-wiki span.icon.icon-wiki
// span.num 0 span.num 0
// span.name Wiki Pages span.name Wiki Pages
// li // li
// a(href="#") // a(href="#")
// span.icon.icon-edit // span.icon.icon-edit
// | 3 Users // | 3 Users

View File

@ -44,3 +44,14 @@ script(type="text/ng-template", id="search-tasks")
tg-bo-bind="task.subject") tg-bo-bind="task.subject")
div.status.width-2(tg-listitem-task-status="task") div.status.width-2(tg-listitem-task-status="task")
div.points.width-1(tg-listitem-assignedto="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")