More workflow
This commit is contained in:
@@ -1,12 +1,28 @@
|
|||||||
lunchControllers = angular.module 'lunchControllers'
|
lunchControllers = angular.module 'lunchControllers'
|
||||||
|
|
||||||
lunchControllers.controller 'CreateOrderCtrl', ['$scope','socket','$routeParams',
|
lunchControllers.controller 'CreateOrderCtrl', ['$scope','socket','$routeParams','$location',
|
||||||
CreateOrderController = ($scope, socket, $routeParams) ->
|
CreateOrderController = ($scope, socket, $routeParams, $location) ->
|
||||||
$scope.show = false
|
$scope.show = false
|
||||||
|
$scope.showMenuUrl = false
|
||||||
|
|
||||||
socket.get '/run/' + $routeParams['id'],
|
socket.get '/run/' + $routeParams['id'],
|
||||||
(response) ->
|
(response) ->
|
||||||
$scope.show = true
|
$scope.show = true
|
||||||
|
$scope.showMenuUrl = response.menuUrl isnt ''
|
||||||
|
|
||||||
|
$scope.run = response
|
||||||
$scope.invitee = _.find response.invitees, (i) -> i.name.toLowerCase() == $routeParams['inviteeName']
|
$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()
|
$scope.$apply()
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,19 +3,18 @@ lunchControllers = angular.module 'lunchControllers'
|
|||||||
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket',
|
lunchControllers.controller 'CreateRunCtrl', ['$scope', '$http', '$location', 'socket',
|
||||||
CreateRunController = ($scope, $http, $location, socket) ->
|
CreateRunController = ($scope, $http, $location, socket) ->
|
||||||
$scope.run =
|
$scope.run =
|
||||||
|
name: 'run name',
|
||||||
creatorName: 'ben ramey'
|
creatorName: 'ben ramey'
|
||||||
creatorEmail: 'ben.ramey@gmail.com'
|
creatorEmail: 'ben.ramey@gmail.com'
|
||||||
invitees: [{email: 'bob@bob.com'}]
|
invitees: [{name: 'bob', email: 'bob@bob.com'}]
|
||||||
restaurant: 'subway'
|
restaurant: 'subway'
|
||||||
|
|
||||||
$scope.addInvitee = () ->
|
$scope.addInvitee = () ->
|
||||||
$scope.run.invitees.push { email: '' }
|
$scope.run.invitees.push {}
|
||||||
|
|
||||||
$scope.create = (run) ->
|
$scope.create = (run) ->
|
||||||
data = angular.copy run
|
data = angular.copy run
|
||||||
socket.post '/run', data, (response) ->
|
socket.post '/run', data, (response) ->
|
||||||
console.log response.id
|
|
||||||
console.log $location
|
|
||||||
$location.path '/run/' + response.id
|
$location.path '/run/' + response.id
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -8,4 +8,9 @@ lunchControllers.controller 'RunCtrl', ['$scope', 'socket', '$routeParams', ($sc
|
|||||||
$scope.show = true
|
$scope.show = true
|
||||||
$scope.run = response
|
$scope.run = response
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
|
|
||||||
|
socket.on 'message', (m) ->
|
||||||
|
if m.verb is 'update' and m.id is $routeParams.id
|
||||||
|
$scope.run = m.data
|
||||||
|
$scope.$apply()
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ lunchServices = angular.module 'lunchServices', []
|
|||||||
lunchServices.factory 'socket', socketFactory = () ->
|
lunchServices.factory 'socket', socketFactory = () ->
|
||||||
s = window.io.connect()
|
s = window.io.connect()
|
||||||
s.on 'connect', () ->
|
s.on 'connect', () ->
|
||||||
|
console.log 'connected with socket!'
|
||||||
s.on 'message', (message) ->
|
s.on 'message', (message) ->
|
||||||
console.log 'New comet message received :: '
|
console.log 'New comet message received :: '
|
||||||
console.log message
|
console.log message
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
div(ng-show='show')
|
div(ng-show='show')
|
||||||
h2 Enter your order
|
h2 Enter your order for {{ run.name }}
|
||||||
|
|
||||||
p {{ invitee.name }}, enter your order here.
|
p {{ invitee.name }}, enter your order here.
|
||||||
|
p You are all going to {{ run.restaurant }}.
|
||||||
|
span(ng-click='showMenuUrl') Here is the
|
||||||
|
a(href='{{ run.menuUrl }}') menu.
|
||||||
|
|
||||||
form(role='form')
|
form(role='form')
|
||||||
div.form-group
|
div.form-group
|
||||||
label(for='order') Your order
|
label(for='order') Your order
|
||||||
textarea#order.form-control(ng-model='invitee.order')
|
textarea#order.form-control(ng-model='invitee.order')
|
||||||
|
|
||||||
button.btn.btn-primary(ng-click='submit()') Submit Order
|
button.btn.btn-primary(ng-click='submit(invitee)') Submit Order
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ div(ng-controller='CreateRunCtrl')
|
|||||||
label(for='creatorEmail') Your email
|
label(for='creatorEmail') Your email
|
||||||
input#creatorEmail.form-control(type='email',ng-model='run.creatorEmail',required)
|
input#creatorEmail.form-control(type='email',ng-model='run.creatorEmail',required)
|
||||||
div.form-group
|
div.form-group
|
||||||
label(for='groupEmails') Group emails
|
label Invitees
|
||||||
span(ng-repeat='i in run.invitees')
|
span(ng-repeat='i in run.invitees')
|
||||||
.form-group
|
.form-group
|
||||||
label Name
|
label Name
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ div(ng-show="show")
|
|||||||
|
|
||||||
div(ng-repeat="i in run.invitees")
|
div(ng-repeat="i in run.invitees")
|
||||||
p {{ i.name }}, {{ i.email }}
|
p {{ i.name }}, {{ i.email }}
|
||||||
|
p {{ i.order }}
|
||||||
|
a(href='#/run/{{ run.id }}/order/{{ i.name }}') Fill in this order
|
||||||
|
|||||||
Reference in New Issue
Block a user