Clean up root check

This commit is contained in:
William Tisäter 2014-05-05 02:58:27 +02:00 committed by William Tisäter
parent e174d1062c
commit a730174f0c
2 changed files with 9 additions and 7 deletions

View file

@ -174,11 +174,8 @@ App.KvEditController = Ember.Controller.extend({
var controller = this; var controller = this;
var dc = controller.get('dc').get('datacenter'); var dc = controller.get('dc').get('datacenter');
var key = controller.get("model"); var key = controller.get("model");
var parent = key.get('parentKey'); var isRoot = controller.get('isRoot');
var parent = isRoot ? controller.get('rootKey') : key.get('parentKey');
if (parent === '/') {
parent = controller.get('rootKey');
}
// Delete the key // Delete the key
Ember.$.ajax({ Ember.$.ajax({

View file

@ -19,7 +19,11 @@ App.BaseRoute = Ember.Route.extend({
grandParentKey = parts.join("/") + "/"; grandParentKey = parts.join("/") + "/";
} }
return {grandParent: grandParentKey, parent: parentKey} return {
parent: parentKey,
grandParent: grandParentKey,
isRoot: parentKey === '/'
}
}, },
removeDuplicateKeys: function(keys, matcher) { removeDuplicateKeys: function(keys, matcher) {
@ -131,7 +135,7 @@ App.KvShowRoute = App.BaseRoute.extend({
controller.set('content', models.keys); controller.set('content', models.keys);
controller.set('parentKey', parentKeys.parent); controller.set('parentKey', parentKeys.parent);
controller.set('grandParentKey', parentKeys.grandParent); controller.set('grandParentKey', parentKeys.grandParent);
controller.set('isRoot', parentKeys.parent === '/'); controller.set('isRoot', parentKeys.isRoot);
controller.set('newKey', App.Key.create()); controller.set('newKey', App.Key.create());
} }
}); });
@ -168,6 +172,7 @@ App.KvEditRoute = App.BaseRoute.extend({
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); controller.set('rootKey', this.rootKey);
controller.set('isRoot', parentKeys.isRoot);
} }
}); });