Last active
August 29, 2015 13:56
-
-
Save pjmorse/8827845 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
saveNewSubscriber: -> | |
@content.get("subscriber").save().then( | |
(subscriber) => | |
$("#modal-dialog-component").modal("hide") | |
App.Notifications.pushSuccess Em.I18n.t "notifications.added", model : "Subscriber" | |
# if subscriber.company?.order_profile?.warehouse? | |
# TODO: Need to get first the orderProfile, then its warehouse, from the API | |
return subscriber.get("company") | |
, | |
(response) => | |
setErrorMessages response.errors, "subscriber" if response.errors? | |
unless @content.get("subscriber").get("currentState.stateName") is "root.loaded.created.inFlight" | |
@content.get("subscriber").send "becameValid" | |
).then( | |
(company) => | |
console.log "Got company #{company.name}" | |
return company.get("orderProfile") | |
).then( | |
(orderProfile) => | |
console.log "Got the order profile: #{orderProfile.name} with warehouse #{orderProfile.warehouse_id}" | |
return orderProfile.get("warehouse") | |
).then( | |
(warehouse) => | |
console.log "Got warehouse: #{warehouse.get('name')}" | |
@set("warehouseSelected", subscriber.company.order_profile.warehouse) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment