Last active
February 6, 2016 00:39
-
-
Save christopherthielen/9ce238841d28e4be395c to your computer and use it in GitHub Desktop.
This file contains 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
// contact is a RevertableModel which is injected from the state's resolve data. | |
export class EditContactController{ | |
constructor($state, dialogService, Contacts, contact) { | |
this.$state = $state; | |
this.dialogService = dialogService; | |
this.Contacts = Contacts; | |
this.contact = contact.editableModel; | |
this.clearDirty = () => contact.clearDirty(); | |
} | |
/** Ask for confirmation, then delete the contact, then go to the grandparent state ('contacts') */ | |
remove(contact) { | |
this.dialogService.confirm(`Delete contact: ${contact.name.first} ${contact.name.last}`) | |
.then(() => this.Contacts.remove(contact)) | |
.then(this.clearDirty) | |
.then(() => this.$state.go("^.^")); | |
} | |
/** Save the contact, then go to the grandparent state ('contacts') */ | |
save(contact) { | |
this.Contacts.save(contact) | |
.then(this.clearDirty) | |
.then(() => this.$state.go("^", null, { reload: true })); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment