ui: handle empty kv index

This commit is contained in:
Jack Pearkes 2014-04-30 17:37:05 -04:00
parent 11acb28c1f
commit 375febc3b0
2 changed files with 14 additions and 3 deletions

View File

@ -73,7 +73,7 @@
<script type="text/x-handlebars" data-template-name="kv/show">
<div class="row">
<h5><a class="subtle" href="" {{action 'linkToKey' topModel.grandParentKey }}>{{topModel.parentKey}}</a></h5>
<h5><a class="subtle" href="" {{action 'linkToKey' grandParentKey }}>{{parentKey}}</a></h5>
</div>
<div class="row">
@ -117,7 +117,7 @@
<div {{ bind-attr class=":form-group newKey.keyValid:valid" }}>
<div class="input-group">
<span class="input-group-addon">{{topModel.parentKey}}</span>
<span class="input-group-addon">{{parentKey}}</span>
{{ input value=newKey.Key class="form-control" required=true }}
</div>
</div>

View File

@ -93,8 +93,19 @@ App.KvShowRoute = App.BaseRoute.extend({
},
setupController: function(controller, model) {
// If we don't have any k/v, we need to set some basic
// stuff so we can create them
if (model.length == 0) {
var parentKey = "/";
var grandParentKey = "/";
} else {
var parentKey = model[0].parentKey;
var grandParentKey = model[0].grandParentKey;
}
controller.set('content', model);
controller.set('topModel', model[0]);
controller.set('parentKey', parentKey);
controller.set('grandParentKey', grandParentKey);
controller.set('newKey', App.Key.create());
}
});