Fixed bug #778: Now stored filters are removed when detect the filter items are deleted

stable
Jesús Espino 2014-08-27 15:06:52 +02:00
parent a0ac2f51af
commit e55899bb91
1 changed files with 17 additions and 0 deletions

View File

@ -123,6 +123,21 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
deferred.resolve(result) deferred.resolve(result)
return deferred.promise return deferred.promise
removeNotExistingFiltersFromUrl: ->
currentSearch = @location.search()
urlfilters = @.getUrlFilters()
for filterName, filterValue of urlfilters
if filterName == "page" or filterName == "orderBy"
continue
splittedValues = (parseInt(val) for val in "#{filterValue}".split(","))
existingValues = _.intersection(splittedValues, _.map(@scope.filters[filterName], "id"))
if splittedValues.length != existingValues.length
@location.search(filterName, existingValues.join())
if currentSearch != @location.search()
@location.replace()
markSelectedFilters: (filters, urlfilters) -> markSelectedFilters: (filters, urlfilters) ->
# Build selected filters (from url) fast lookup data structure # Build selected filters (from url) fast lookup data structure
searchdata = {} searchdata = {}
@ -194,6 +209,8 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
@scope.filters.types = choicesFiltersFormat data.types, "types", @scope.issueTypeById @scope.filters.types = choicesFiltersFormat data.types, "types", @scope.issueTypeById
@scope.filters.tags = tagsFilterFormat data.tags @scope.filters.tags = tagsFilterFormat data.tags
@.removeNotExistingFiltersFromUrl()
@.markSelectedFilters(@scope.filters, urlfilters) @.markSelectedFilters(@scope.filters, urlfilters)
@rootscope.$broadcast("filters:loaded", @scope.filters) @rootscope.$broadcast("filters:loaded", @scope.filters)