mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Hide distance matches when there are name matches. Show with a link.
This commit is contained in:
@@ -9,12 +9,14 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, Enterprises, Search, $document,
|
||||
$scope.activeTaxons = []
|
||||
$scope.show_profiles = false
|
||||
$scope.filtersActive = false
|
||||
$scope.distanceMatchesShown = false
|
||||
|
||||
|
||||
$scope.$watch "query", (query)->
|
||||
Enterprises.evaluateQuery query
|
||||
Search.search query
|
||||
$scope.filterEnterprises()
|
||||
$scope.distanceMatchesShown = false
|
||||
|
||||
|
||||
$rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) ->
|
||||
@@ -30,3 +32,7 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, Enterprises, Search, $document,
|
||||
es = showHubProfilesFilter(es)
|
||||
$scope.nameMatches = enterpriseMatchesNameQueryFilter(es, true)
|
||||
$scope.distanceMatches = enterpriseMatchesNameQueryFilter(es, false)
|
||||
|
||||
|
||||
$scope.showDistanceMatches = ->
|
||||
$scope.distanceMatchesShown = true
|
||||
@@ -14,10 +14,14 @@
|
||||
%h2 Did you mean?
|
||||
= render "home/hubs_table", enterprises: "nameMatches"
|
||||
|
||||
%h2
|
||||
Closest to
|
||||
%span{"ng-show" => "nameMatches.length > 0"} {{ nameMatches[0].name }}
|
||||
%span{"ng-hide" => "nameMatches.length > 0"} {{ query }}
|
||||
\...
|
||||
.distance-matches{"ng-show" => "nameMatches.length == 0 || distanceMatchesShown"}
|
||||
%h2
|
||||
Closest to
|
||||
%span{"ng-show" => "nameMatches.length > 0"} {{ nameMatches[0].name }}
|
||||
%span{"ng-hide" => "nameMatches.length > 0"} {{ query }}
|
||||
\...
|
||||
|
||||
= render "home/hubs_table", enterprises: "distanceMatches"
|
||||
= render "home/hubs_table", enterprises: "distanceMatches"
|
||||
|
||||
.show-distance-matches{"ng-show" => "nameMatches.length > 0 && !distanceMatchesShown"}
|
||||
%a{href: "", "ng-click" => "showDistanceMatches()"} Show me shops near {{ nameMatches[0].name }}
|
||||
|
||||
Reference in New Issue
Block a user