mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Update distance matches when filter settings change
This commit is contained in:
@@ -19,7 +19,7 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, Enterpris
|
||||
$scope.distanceMatchesShown = false
|
||||
|
||||
$timeout ->
|
||||
Enterprises.calculateDistance query, $scope.nameMatchesFiltered[0]
|
||||
Enterprises.calculateDistance query, $scope.firstNameMatch()
|
||||
$rootScope.$broadcast 'enterprisesChanged'
|
||||
|
||||
|
||||
@@ -28,6 +28,16 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, Enterpris
|
||||
$scope.updateVisibleMatches()
|
||||
|
||||
|
||||
# When filter settings change, this could change which name match is at the top, or even
|
||||
# result in no matches. This affects the reference point that the distance matches are
|
||||
# calculated from, so we need to recalculate distances.
|
||||
$scope.$watch '[activeTaxons, shippingTypes, show_profiles]', ->
|
||||
$timeout ->
|
||||
Enterprises.calculateDistance $scope.query, $scope.firstNameMatch()
|
||||
$rootScope.$broadcast 'enterprisesChanged'
|
||||
, true
|
||||
|
||||
|
||||
$rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) ->
|
||||
if HashNavigation.active "hubs"
|
||||
$document.scrollTo $("#hubs"), 100, 200
|
||||
@@ -49,4 +59,11 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, Enterpris
|
||||
|
||||
$scope.showDistanceMatches = ->
|
||||
$scope.distanceMatchesShown = true
|
||||
$scope.updateVisibleMatches()
|
||||
$scope.updateVisibleMatches()
|
||||
|
||||
|
||||
$scope.firstNameMatch = ->
|
||||
if $scope.nameMatchesFiltered?
|
||||
$scope.nameMatchesFiltered[0]
|
||||
else
|
||||
undefined
|
||||
|
||||
Reference in New Issue
Block a user