Merge pull request #603 from taigaio/issue/3136/search-filter-reset

fix issue #3136
stable
Alejandro 2015-09-03 07:51:49 +02:00
commit bdc75f54c5
2 changed files with 23 additions and 13 deletions

View File

@ -77,13 +77,6 @@ Loader = ($rootscope) ->
lastResponseDate = 0
autoClose = () ->
maxAuto = 5000
timeoutAuto = setTimeout (() ->
pageLoaded()
clearInterval(intervalAuto)
), maxAuto
intervalAuto = setInterval (() ->
if lastResponseDate && requestCount == 0
pageLoaded()

View File

@ -164,13 +164,22 @@ module.directive("tgSearchBox", SearchBoxDirective)
SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
linkTable = ($scope, $el, $attrs, $ctrl) ->
applyAutoTab = true
activeSectionName = "userstories"
tabsDom = $el.find("section.search-filter")
lastSeatchResults = null
getActiveSection = (data) ->
maxVal = 0
selectedSectionName = null
selectedSectionData = null
selectedSection = {}
selectedSection.name = "userstories"
selectedSection.value = []
if !applyAutoTab
selectedSection.name = activeSectionName
selectedSection.value = data[activeSectionName]
return selectedSection
if data
for name in ["userstories", "issues", "tasks", "wikipages"]
@ -178,14 +187,14 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
if value.length > maxVal
maxVal = value.length
selectedSectionName = name
selectedSectionData = value
selectedSection.name = name
selectedSection.value = value
break;
if maxVal == 0
return {name: "userstories", value: []}
return selectedSection
return {name:selectedSectionName, value: selectedSectionData}
return selectedSection
renderFilterTabs = (data) ->
for name, value of data
@ -197,6 +206,9 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
tabsDom.find("a.active").removeClass("active")
tabsDom.find("li.#{section.name} a").addClass("active")
applyAutoTab = false
activeSectionName = section.name
templates = {
issues: $templatecache.get("search-issues")
tasks: $templatecache.get("search-tasks")
@ -221,8 +233,13 @@ SearchDirective = ($log, $compile, $templatecache, $routeparams, $location) ->
$scope.$watch "searchResults", (data) ->
lastSeatchResults = data
return if !lastSeatchResults
activeSection = getActiveSection(data)
renderFilterTabs(data)
renderTableContent(activeSection)
markSectionTabActive(activeSection)