mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
The enterprises have related producers and hubs that need to be dereferenced. Therefore, we need a bigger set of enterprises to be loaded. Injecting all enterprises is simple and doesn't require changes if the set of needed enterprise data is growing in future.
20 lines
714 B
CoffeeScript
20 lines
714 B
CoffeeScript
Darkswarm.factory "OfnMap", (Enterprises, EnterpriseModal, visibleFilter) ->
|
|
new class OfnMap
|
|
constructor: ->
|
|
@enterprises = @enterprise_markers(Enterprises.enterprises)
|
|
|
|
enterprise_markers: (enterprises) ->
|
|
@extend(enterprise) for enterprise in visibleFilter(enterprises)
|
|
|
|
# Adding methods to each enterprise
|
|
extend: (enterprise) ->
|
|
new class MapMarker
|
|
# We're whitelisting attributes because GMaps tries to crawl
|
|
# our data, and our data is recursive, so it breaks
|
|
latitude: enterprise.latitude
|
|
longitude: enterprise.longitude
|
|
icon: enterprise.icon
|
|
id: enterprise.id
|
|
reveal: =>
|
|
EnterpriseModal.open enterprise
|