diff --git a/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee index 33a4bd33bd..60a383cd6d 100644 --- a/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee @@ -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 \ No newline at end of file diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index 3dbd1c775d..38c393ceff 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -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 }}