Fix a bug in the backlog filters when unselect one in a secction with different type

stable
David Barragán Merino 2014-08-04 11:59:58 +02:00
parent 98f90f91cf
commit 9252ef8a51
1 changed files with 10 additions and 7 deletions

View File

@ -77,11 +77,12 @@ BacklogFiltersDirective = ($log, $location) ->
$ctrl = $el.closest(".wrapper").controller() $ctrl = $el.closest(".wrapper").controller()
selectedFilters = [] selectedFilters = []
showFilters = (title) -> showFilters = (title, type) ->
$el.find(".filters-cats").hide() $el.find(".filters-cats").hide()
$el.find(".filter-list").show() $el.find(".filter-list").show()
$el.find("h2 a.subfilter").removeClass("hidden") $el.find("h2 a.subfilter").removeClass("hidden")
$el.find("h2 a.subfilter span.title").html(title) $el.find("h2 a.subfilter span.title").html(title)
$el.find("h2 a.subfilter span.title").prop("data-type", type)
showCategories = -> showCategories = ->
$el.find(".filters-cats").show() $el.find(".filters-cats").show()
@ -119,7 +120,10 @@ BacklogFiltersDirective = ($log, $location) ->
$ctrl.filterVisibleUserstories() $ctrl.filterVisibleUserstories()
renderSelectedFilters(selectedFilters) renderSelectedFilters(selectedFilters)
renderFilters(_.reject(filters, "selected"))
currentFiltersType = $el.find("h2 a.subfilter span.title").prop('data-type')
if type == currentFiltersType
renderFilters(_.reject(filters, "selected"))
selectSubjectFilter = debounce 400, (value) -> selectSubjectFilter = debounce 400, (value) ->
return if value is undefined return if value is undefined
@ -131,27 +135,26 @@ BacklogFiltersDirective = ($log, $location) ->
$scope.$watch("filtersSubject", selectSubjectFilter) $scope.$watch("filtersSubject", selectSubjectFilter)
# Angular Watchers ## Angular Watchers
$scope.$on "filters:loaded", (ctx, filters) -> $scope.$on "filters:loaded", (ctx, filters) ->
initializeSelectedFilters(filters) initializeSelectedFilters(filters)
# Dom Event Handlers ## Dom Event Handlers
$el.on "click", ".filters-cats > ul > li > a", (event) -> $el.on "click", ".filters-cats > ul > li > a", (event) ->
event.preventDefault() event.preventDefault()
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
tags = $scope.filters[target.data("type")] tags = $scope.filters[target.data("type")]
renderFilters(_.reject(tags, "selected")) renderFilters(_.reject(tags, "selected"))
showFilters(target.attr("title")) showFilters(target.attr("title"), target.data("type"))
$el.on "click", ".filters-inner > h1 > a.title", (event) -> $el.on "click", ".filters-inner > h1 > a.title", (event) ->
event.preventDefault() event.preventDefault()
showCategories($el) showCategories()
$el.on "click", ".filters-applied a", (event) -> $el.on "click", ".filters-applied a", (event) ->
event.preventDefault() event.preventDefault()
target = angular.element(event.currentTarget) target = angular.element(event.currentTarget)
id = target.data("id") id = target.data("id")
type = target.data("type") type = target.data("type")
toggleFilterSelection(type, id) toggleFilterSelection(type, id)