Reset ssh key controller properly

This commit is contained in:
Piotr Sarnacki 2014-08-25 15:22:17 +02:00
parent 3b8ecdad41
commit 5c41529d07
2 changed files with 9 additions and 0 deletions

View File

@ -12,6 +12,9 @@ Travis.SshKeyController = Ember.ObjectController.extend Travis.Validations,
validates:
value: ['presence']
reset: ->
@set('isEditing', false)
actions:
add: ->
model = Travis.SshKey.create(id: @get('repo.id'))
@ -38,6 +41,11 @@ Travis.SshKeyController = Ember.ObjectController.extend Travis.Validations,
@set('isDeleting', true)
deletingDone = => @set('isDeleting', false)
# because of the bug in ember model reference is not cleared after
# deleting the record, so I'm doing it manually here
delete @get('model').constructor._referenceCache(parseInt(@get('model.id')))
@get('model').deleteRecord().then(deletingDone, deletingDone).then =>
@set('model', null)

View File

@ -414,6 +414,7 @@ Travis.SshKeyRoute = Travis.Route.extend
@defaultKey = Ember.Object.create(fingerprint: data.fingerprint)
setupController: (controller, model) ->
controller.reset()
@_super.apply this, arguments
if @defaultKey