More workflow
This commit is contained in:
@@ -1,12 +1,28 @@
|
||||
lunchControllers = angular.module 'lunchControllers'
|
||||
|
||||
lunchControllers.controller 'CreateOrderCtrl', ['$scope','socket','$routeParams',
|
||||
CreateOrderController = ($scope, socket, $routeParams) ->
|
||||
lunchControllers.controller 'CreateOrderCtrl', ['$scope','socket','$routeParams','$location',
|
||||
CreateOrderController = ($scope, socket, $routeParams, $location) ->
|
||||
$scope.show = false
|
||||
$scope.showMenuUrl = false
|
||||
|
||||
socket.get '/run/' + $routeParams['id'],
|
||||
(response) ->
|
||||
$scope.show = true
|
||||
$scope.showMenuUrl = response.menuUrl isnt ''
|
||||
|
||||
$scope.run = response
|
||||
$scope.invitee = _.find response.invitees, (i) -> i.name.toLowerCase() == $routeParams['inviteeName']
|
||||
$scope.invitees = response.invitees
|
||||
|
||||
$scope.$apply()
|
||||
|
||||
$scope.submit = (invitee) ->
|
||||
invitees = _.map $scope.invitees, (i) ->
|
||||
if i.name is invitee.name
|
||||
return invitee
|
||||
return i
|
||||
|
||||
socket.put '/run/' + $routeParams['id'], { invitees: invitees }, (response) ->
|
||||
$location.path '/run/' + response.id
|
||||
$scope.$apply()
|
||||
]
|
||||
|
||||
@@ -3,19 +3,18 @@ lunchControllers = angular.module 'lunchControllers'
|
||||
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket',
|
||||
CreateRunController = ($scope, $http, $location, socket) ->
|
||||
$scope.run =
|
||||
name: 'run name',
|
||||
creatorName: 'ben ramey'
|
||||
creatorEmail: 'ben.ramey@gmail.com'
|
||||
invitees: [{email: 'bob@bob.com'}]
|
||||
invitees: [{name: 'bob', email: 'bob@bob.com'}]
|
||||
restaurant: 'subway'
|
||||
|
||||
$scope.addInvitee = () ->
|
||||
$scope.run.invitees.push { email: '' }
|
||||
$scope.run.invitees.push {}
|
||||
|
||||
$scope.create = (run) ->
|
||||
data = angular.copy run
|
||||
socket.post '/run', data, (response) ->
|
||||
console.log response.id
|
||||
console.log $location
|
||||
$location.path '/run/' + response.id
|
||||
$scope.$apply()
|
||||
]
|
||||
|
||||
@@ -8,4 +8,9 @@ lunchControllers.controller 'RunCtrl', ['$scope', 'socket', '$routeParams', ($sc
|
||||
$scope.show = true
|
||||
$scope.run = response
|
||||
$scope.$apply()
|
||||
|
||||
socket.on 'message', (m) ->
|
||||
if m.verb is 'update' and m.id is $routeParams.id
|
||||
$scope.run = m.data
|
||||
$scope.$apply()
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user