ui: fix nesting KV
This commit is contained in:
parent
d78b202464
commit
3e1bc7dbad
|
@ -156,6 +156,7 @@ App.Key = Ember.Object.extend(Ember.Validations.Mixin, {
|
||||||
// setter
|
// setter
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
this.set('Value', value);
|
this.set('Value', value);
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// getter
|
// getter
|
||||||
|
|
|
@ -83,30 +83,36 @@ App.KvShowRoute = App.BaseRoute.extend({
|
||||||
var key = params.key.replace(/-/g, "/")
|
var key = params.key.replace(/-/g, "/")
|
||||||
var dc = this.modelFor('dc').dc;
|
var dc = this.modelFor('dc').dc;
|
||||||
|
|
||||||
// Return a promise to retrieve the ?keys for that namespace
|
// Return a promise has with the ?keys for that namespace
|
||||||
return Ember.$.getJSON('/v1/kv/' + key + '?keys&seperator=' + '/&dc=' + dc).then(function(data) {
|
// and the original key requested in params
|
||||||
|
return Ember.RSVP.hash({
|
||||||
|
key: key,
|
||||||
|
keys: Ember.$.getJSON('/v1/kv/' + key + '?keys&seperator=' + '/&dc=' + dc).then(function(data) {
|
||||||
objs = [];
|
objs = [];
|
||||||
data.map(function(obj){
|
data.map(function(obj){
|
||||||
objs.push(App.Key.create({Key: obj}));
|
objs.push(App.Key.create({Key: obj}));
|
||||||
});
|
});
|
||||||
return objs;
|
return objs;
|
||||||
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, models) {
|
||||||
var parentKey = "/";
|
var parentKey = "/";
|
||||||
var grandParentKey = "/";
|
var grandParentKey = "/";
|
||||||
|
var key = models.key;
|
||||||
|
|
||||||
// If we don't have any k/v, we need to set some basic
|
// Loop over the keys
|
||||||
// stuff so we can create them
|
models.keys.forEach(function(item, index) {
|
||||||
if (model.length > 0) {
|
if (item.get('Key') == key) {
|
||||||
var parentKey = model[0].get('parentKey');
|
parentKey = item.get('Key');
|
||||||
var grandParentKey = model[0].get('grandParentKey');
|
grandParentKey = item.get('grandParentKey');
|
||||||
|
// Remove the dupe
|
||||||
|
models.keys.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
console.log(parentKey, grandParentKey)
|
controller.set('content', models.keys);
|
||||||
|
|
||||||
controller.set('content', model);
|
|
||||||
controller.set('parentKey', parentKey);
|
controller.set('parentKey', parentKey);
|
||||||
controller.set('grandParentKey', grandParentKey);
|
controller.set('grandParentKey', grandParentKey);
|
||||||
controller.set('newKey', App.Key.create());
|
controller.set('newKey', App.Key.create());
|
||||||
|
@ -154,13 +160,26 @@ App.KvEditRoute = App.BaseRoute.extend({
|
||||||
setupController: function(controller, models) {
|
setupController: function(controller, models) {
|
||||||
controller.set('content', models.key);
|
controller.set('content', models.key);
|
||||||
|
|
||||||
|
var parentKey = "/";
|
||||||
|
var grandParentKey = "/";
|
||||||
|
|
||||||
|
// Loop over the keys
|
||||||
|
models.keys.forEach(function(item, index) {
|
||||||
|
if (item.get('Key') == models.key.get('parentKey')) {
|
||||||
|
parentKey = item.get('Key');
|
||||||
|
grandParentKey = item.get('grandParentKey');
|
||||||
|
// Remove the dupe
|
||||||
|
models.keys.splice(index, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// If we don't have the cached model from our
|
// If we don't have the cached model from our
|
||||||
// the kv.show controller, we need to go get it,
|
// the kv.show controller, we need to go get it,
|
||||||
// otherwise we just load what we have.
|
// otherwise we just load what we have.
|
||||||
if (this.modelFor('kv.show') == undefined ) {
|
if (this.modelFor('kv.show') == undefined ) {
|
||||||
controller.set('siblings', models.keys);
|
controller.set('siblings', models.keys);
|
||||||
} else {
|
} else {
|
||||||
controller.set('siblings', this.modelFor('kv.show'));
|
controller.set('siblings', this.modelFor('kv.show').keys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue