mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Perform shops search by proximity instead of plain string match
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
Darkswarm.controller "EnterprisesCtrl", ($scope, Enterprises, Search, $document, $rootScope, HashNavigation, FilterSelectorsService, EnterpriseModal) ->
|
||||
$scope.Enterprises = Enterprises
|
||||
$scope.totalActive = FilterSelectorsService.totalActive
|
||||
$scope.clearAll = FilterSelectorsService.clearAll
|
||||
$scope.filterText = FilterSelectorsService.filterText
|
||||
$scope.FilterSelectorsService = FilterSelectorsService
|
||||
$scope.totalActive = FilterSelectorsService.totalActive
|
||||
$scope.clearAll = FilterSelectorsService.clearAll
|
||||
$scope.filterText = FilterSelectorsService.filterText
|
||||
$scope.FilterSelectorsService = FilterSelectorsService
|
||||
$scope.query = Search.search()
|
||||
$scope.openModal = EnterpriseModal.open
|
||||
$scope.activeTaxons = []
|
||||
$scope.show_profiles = false
|
||||
$scope.filtersActive = false
|
||||
|
||||
|
||||
$scope.$watch "query", (query)->
|
||||
Enterprises.flagMatching query
|
||||
Enterprises.updateDistance query
|
||||
Search.search query
|
||||
|
||||
$rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Taxons, Dereferencer, visibleFilter, Matcher, Geo)->
|
||||
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Taxons, Dereferencer, visibleFilter, Matcher, Geo, $rootScope)->
|
||||
new class Enterprises
|
||||
enterprises_by_id: {}
|
||||
constructor: ->
|
||||
@@ -51,8 +51,9 @@ Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Taxons, Dereferencer,
|
||||
@resetDistance()
|
||||
|
||||
setDistanceFrom: (location) ->
|
||||
for enterprise in @enterprises
|
||||
enterprise.distance = Geo.distanceBetween enterprise, location
|
||||
$rootScope.$apply =>
|
||||
for enterprise in @enterprises
|
||||
enterprise.distance = Geo.distanceBetween enterprise, location
|
||||
|
||||
resetDistance: ->
|
||||
enterprise.distance = null for enterprise in @enterprises
|
||||
|
||||
0
app/assets/javascripts/shared/ng-tags-input.min.js
vendored
Executable file → Normal file
0
app/assets/javascripts/shared/ng-tags-input.min.js
vendored
Executable file → Normal file
@@ -11,7 +11,7 @@
|
||||
.row{bindonce: true}
|
||||
.small-12.columns
|
||||
.active_table
|
||||
%hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredEnterprises = (Enterprises.hubs | visible | searchEnterprises:query | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | orderBy:['-active', '+orders_close_at'])",
|
||||
%hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredEnterprises = (Enterprises.hubs | visible | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | orderBy:['-active', '-matches_name_query', '+distance', '+orders_close_at'])",
|
||||
"ng-class" => "{'is_profile' : hub.category == 'hub_profile', 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}",
|
||||
"ng-controller" => "HubNodeCtrl",
|
||||
id: "{{hub.hash}}"}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
%span.margin-top{"bo-text" => "hub.address.city"}
|
||||
.columns.small-2.medium-1.large-1
|
||||
%span.margin-top{"bo-bind" => "hub.address.state_name | uppercase"}
|
||||
%span.margin-top{"ng-if" => "hub.distance != null"} ({{ hub.distance / 1000 | number:0 }} km)
|
||||
|
||||
.columns.small-4.medium-3.large-3.text-right{"bo-if" => "hub.active"}
|
||||
%a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"}
|
||||
@@ -26,7 +27,7 @@
|
||||
%span.margin-top{ bo: { if: "!current()" } } Orders closed
|
||||
|
||||
.columns.small-2.medium-1.large-1.text-right
|
||||
%span.margin-top
|
||||
%span.margin-top
|
||||
%i{"ng-class" => "{'ofn-i_005-caret-down' : !open(), 'ofn-i_006-caret-up' : open()}"}
|
||||
|
||||
.row.active_table_row{"ng-if" => "!hub.is_distributor", "ng-class" => "closed"}
|
||||
@@ -43,4 +44,3 @@
|
||||
.columns.small-6.medium-3.large-4.text-right
|
||||
%span.margin-top{ bo: { if: "!current()" } }
|
||||
%em Profile only
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
%link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"}
|
||||
|
||||
= yield :scripts
|
||||
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places&sensor=false"}
|
||||
%script{src: "//maps.googleapis.com/maps/api/js?libraries=places,geometry&sensor=false"}
|
||||
= split_stylesheet_link_tag "darkswarm/all"
|
||||
= javascript_include_tag "darkswarm/all"
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
%input{type: :text,
|
||||
"ng-model" => "query",
|
||||
placeholder: t('search_by_name'),
|
||||
"ng-debounce" => "150",
|
||||
"ng-debounce" => "500",
|
||||
"ofn-disable-enter" => true}
|
||||
|
||||
Reference in New Issue
Block a user