prevent location search if the url has the same parameters

stable
Juanfran 2015-02-19 11:29:13 +01:00 committed by David Barragán Merino
parent d5e3d3e73b
commit 6ce8957749
2 changed files with 14 additions and 7 deletions

View File

@ -28,6 +28,10 @@ locationFactory = ($location, $route, $rootscope) ->
un() un()
return $location return $location
$location.isInCurrentRouteParams = (name, value) ->
return $route.current.params[name] == value
return $location return $location

View File

@ -62,7 +62,7 @@ taiga.PageMixin = PageMixin
############################################################################# #############################################################################
## Filters Mixin ## Filters Mixin
############################################################################# #############################################################################
# This mixin requires @location ($tgLocation) and @scope # This mixin requires @location ($tgLocation), and @scope
class FiltersMixin class FiltersMixin
selectFilter: (name, value, load=false) -> selectFilter: (name, value, load=false) ->
@ -73,14 +73,17 @@ class FiltersMixin
existing = _.compact(existing) existing = _.compact(existing)
value = joinStr(",", _.uniq(existing)) value = joinStr(",", _.uniq(existing))
if !@location.isInCurrentRouteParams(name, value)
location = if load then @location else @location.noreload(@scope) location = if load then @location else @location.noreload(@scope)
location.search(name, value) location.search(name, value)
replaceFilter: (name, value, load=false) -> replaceFilter: (name, value, load=false) ->
if !@location.isInCurrentRouteParams(name, value)
location = if load then @location else @location.noreload(@scope) location = if load then @location else @location.noreload(@scope)
location.search(name, value) location.search(name, value)
replaceAllFilters: (filters, load=false) -> replaceAllFilters: (filters, load=false) ->
if !@location.isInCurrentRouteParams(name, value)
location = if load then @location else @location.noreload(@scope) location = if load then @location else @location.noreload(@scope)
location.search(filters) location.search(filters)