Further patches to the damned RABL system, patching everything up to use our new Service structure

This commit is contained in:
Will Marshall
2014-06-18 17:54:13 +10:00
parent 224a70c11f
commit c02c7cf7ca
18 changed files with 40 additions and 37 deletions

View File

@@ -1,11 +1,12 @@
Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) ->
$scope.data = Product.data
$scope.products = Product.products
$scope.loading = Product.loading
$scope.limit = 3
$scope.ordering = {order: "name"}
$scope.order_cycle = OrderCycle.order_cycle
$scope.incrementLimit = ->
if $scope.limit < $scope.data.products.length
if $scope.limit < $scope.products.length
$scope.limit = $scope.limit + 1
$scope.searchKeypress = (e)->

View File

@@ -1,8 +1,8 @@
Darkswarm.factory 'Hubs', ($filter, Enterprises) ->
new class Hubs
constructor: ->
@hubs = @filter Enterprises.enterprises.filter (hub)->
hub.type == "hub"
@hubs = @order Enterprises.enterprises.filter (hub)->
hub.enterprise_type == "hub"
filter: (hubs)->
order: (hubs)->
$filter('orderBy')(hubs, ['-active', '+orders_close_at'])

View File

@@ -1,13 +1,17 @@
Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)->
Darkswarm.factory "OfnMap", (Enterprises, MapModal)->
new class OfnMap
constructor: ->
@enterprises = (@extend(enterprise) for enterprise in enterprisesForMap)
console.log @enterprises
@enterprises = (@extend(enterprise) for enterprise in Enterprises.enterprises)
# Adding methods to each enterprise
extend: (enterprise)->
new class MapMarker
constructor: ->
@[k] = v for k, v of enterprise
# We're whitelisting attributes because Gmaps tries to crawl
# our data, and our data is recursive
latitude: enterprise.latitude
longitude: enterprise.longitude
icon: enterprise.icon
id: enterprise.id
reveal: =>
MapModal.open @
MapModal.open enterprise

View File

@@ -2,7 +2,7 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)->
new class MapModal
open: (enterprise)->
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
if enterprise['is_primary_producer?']
if enterprise.enterprise_type == "producer"
scope.producer = enterprise
$modal.open(templateUrl: "map_modal_producer.html", scope: scope)
else

View File

@@ -2,5 +2,5 @@ Darkswarm.factory 'Producers', (Enterprises) ->
new class Producers
constructor: ->
@producers = Enterprises.enterprises.filter (enterprise)->
enterprise.type == "producer"
enterprise.enterprise_type == "producer"

View File

@@ -5,11 +5,10 @@ Darkswarm.factory 'Product', ($resource) ->
# TODO: don't need to scope this into object
# Already on object as far as controller scope is concerned
data:
products: null
loading: true
products: null
loading: true
update: =>
@data.products = $resource("/shop/products").query =>
@data.loading = false
@data
@products = $resource("/shop/products").query =>
@loading = false
@