mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-25 01:23:23 +00:00
Refactoring the RABL injection and the Hubs/Producers/Enterprises services
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
Darkswarm.factory 'Enterprises', (enterprises)->
|
||||
new class Enterprises
|
||||
enterprises_by_id: {} # id/object pairs for lookup
|
||||
constructor: ->
|
||||
@enterprises = enterprises
|
||||
@dereference()
|
||||
for enterprise in enterprises
|
||||
@enterprises_by_id[enterprise.id] = enterprise
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
Darkswarm.factory 'Hubs', (hubs, $filter) ->
|
||||
Darkswarm.factory 'Hubs', ($filter, Enterprises) ->
|
||||
new class Hubs
|
||||
constructor: ->
|
||||
@hubs = $filter('orderBy')(hubs, ['-active', '+orders_close_at'])
|
||||
@hubs = @filter Enterprises.enterprises.filter (hub)->
|
||||
hub.type == "hub"
|
||||
|
||||
|
||||
filter: (hubs)->
|
||||
$filter('orderBy')(hubs, ['-active', '+orders_close_at'])
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Darkswarm.factory 'Producers', (producers) ->
|
||||
Darkswarm.factory 'Producers', (Enterprises) ->
|
||||
new class Producers
|
||||
constructor: ->
|
||||
@producers = producers
|
||||
@producers = Enterprises.enterprises.filter (enterprise)->
|
||||
enterprise.type == "producer"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user