Skip to content

Instantly share code, notes, and snippets.

@jtomasrl
Last active December 27, 2015 23:19
Show Gist options
  • Save jtomasrl/7405186 to your computer and use it in GitHub Desktop.
Save jtomasrl/7405186 to your computer and use it in GitHub Desktop.
App.ApplicationRoute = Ember.Route.extend(
setupController: (controller, data) ->
store = @get 'store'
socket = io.connect "http://localhost:4000/orders"
socket.on "new_order", (order) ->
store.load(App.Order, order)
socket.on "new_billing", (bill) ->
store.load(App.Bill, bill)
socket.on "connected", ->
console.log "Ready"
model: ->
return { title: "Ordenes" }
actions:
markAsDone: (type, type_id) ->
# Send value to backend
socket.emit "confirm_" + type,
id: type_id
# Find record by id
if type == "order"
record = App.Order.find(type_id)
transition = "orders"
else if type == "bill"
record = App.Bill.find(type_id)
transition = "bills"
# Delete from store
record.then( (r) ->
r.deleteRecord()
)
# Display list of record type
@transitionTo(transition)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment