mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Minor refactoring from code review with Rohan
This commit is contained in:
@@ -2,7 +2,7 @@ Darkswarm.factory 'Hubs', ($filter, Enterprises) ->
|
||||
new class Hubs
|
||||
constructor: ->
|
||||
@hubs = @order Enterprises.enterprises.filter (hub)->
|
||||
hub.enterprise_type == "hub"
|
||||
hub.is_distributor
|
||||
|
||||
order: (hubs)->
|
||||
$filter('orderBy')(hubs, ['-active', '+orders_close_at'])
|
||||
|
||||
@@ -7,8 +7,8 @@ Darkswarm.factory "OfnMap", (Enterprises, MapModal)->
|
||||
# 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
|
||||
# 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
|
||||
|
||||
@@ -2,9 +2,10 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)->
|
||||
new class MapModal
|
||||
open: (enterprise)->
|
||||
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
|
||||
if enterprise.enterprise_type == "producer"
|
||||
scope.producer = enterprise
|
||||
$modal.open(templateUrl: "map_modal_producer.html", scope: scope)
|
||||
else
|
||||
|
||||
if enterprise.is_distributor
|
||||
scope.hub = enterprise
|
||||
$modal.open(templateUrl: "map_modal_hub.html", scope: scope)
|
||||
else
|
||||
scope.producer = enterprise
|
||||
$modal.open(templateUrl: "map_modal_producer.html", scope: scope)
|
||||
|
||||
@@ -2,5 +2,5 @@ Darkswarm.factory 'Producers', (Enterprises) ->
|
||||
new class Producers
|
||||
constructor: ->
|
||||
@producers = Enterprises.enterprises.filter (enterprise)->
|
||||
enterprise.enterprise_type == "producer"
|
||||
enterprise.is_primary_producer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user