Hide distance matches when there are name matches. Show with a link.

This commit is contained in:
Rohan Mitchell
2015-07-02 16:28:13 +10:00
parent 794c9558bb
commit 5b5c56064e
2 changed files with 16 additions and 6 deletions

View File

@@ -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

View File

@@ -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 }}