Merge branch 'master' of github.com:eaterprises/openfoodweb

This commit is contained in:
alexs
2013-08-09 13:21:24 +10:00
18 changed files with 202 additions and 2 deletions

View File

@@ -9,5 +9,7 @@
//= require store/spree_core
//= require store/spree_auth
//= require store/spree_promo
//= require shared/angular
//= require shared/angular-resource
//= require_tree .

View File

@@ -0,0 +1,18 @@
'use strict'
angular.module('store', ['ngResource']).
controller 'CartCtrl', ($scope, $window, CartFactory) ->
$scope.loadCart = ->
$scope.cart = CartFactory.load(1)
$scope.addVariant = (variant, quantity) ->
.config(['$httpProvider', ($httpProvider) ->
$httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')
])

View File

@@ -0,0 +1,12 @@
'use strict'
angular.module('store').
factory 'CartFactory', ($resource, $window, $http) ->
Cart = $resource '/open_food_web/cart/:cart_id.json', {},
{ 'show': { method: 'GET'} }
load: (id, callback) ->
Cart.show {cart_id: id}, (cart) ->
callback(cart)