Minor refactoring from code review with Rohan

This commit is contained in:
Will Marshall
2014-06-19 11:41:24 +10:00
parent c02c7cf7ca
commit b9561ecf20
18 changed files with 19 additions and 53 deletions

View File

@@ -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'])

View File

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

View File

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

View File

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