Redirect to correct root path when deleting keys

This commit is contained in:
William Tisäter 2014-05-05 02:51:34 +02:00 committed by William Tisäter
parent d40b3ae6a6
commit 17e3756200
2 changed files with 9 additions and 3 deletions

View File

@ -171,9 +171,14 @@ App.KvEditController = Ember.Controller.extend({
deleteKey: function() { deleteKey: function() {
this.set('isLoading', true); this.set('isLoading', true);
var dc = this.get('dc').get('datacenter');
var key = this.get("model");
var controller = this; var controller = this;
var dc = controller.get('dc').get('datacenter');
var key = controller.get("model");
var parent = key.get('parentKey');
if (parent === '/') {
parent = controller.get('rootKey');
}
// Delete the key // Delete the key
Ember.$.ajax({ Ember.$.ajax({
@ -181,7 +186,7 @@ App.KvEditController = Ember.Controller.extend({
type: 'DELETE' type: 'DELETE'
}).then(function(response) { }).then(function(response) {
// Tranisiton back up a level // Tranisiton back up a level
controller.transitionToRoute('kv.show', key.get('parentKey')); controller.transitionToRoute('kv.show', parent);
controller.set('isLoading', false); controller.set('isLoading', false);
}).fail(function(response) { }).fail(function(response) {
// Render the error message on the form if the request failed // Render the error message on the form if the request failed

View File

@ -167,6 +167,7 @@ App.KvEditRoute = App.BaseRoute.extend({
controller.set('parentKey', parentKeys.parent); controller.set('parentKey', parentKeys.parent);
controller.set('grandParentKey', parentKeys.grandParent); controller.set('grandParentKey', parentKeys.grandParent);
controller.set('siblings', models.keys); controller.set('siblings', models.keys);
controller.set('rootKey', this.rootKey);
} }
}); });