ui: properly nest kv resources

This commit is contained in:
Jack Pearkes 2014-04-29 13:34:13 -04:00
parent f8ffdee2bd
commit 2c22cb833c
5 changed files with 34 additions and 19 deletions

View File

@ -65,8 +65,8 @@
<script type="text/x-handlebars" data-template-name="kv/show">
<a {{action 'linkToKey' parent }}>{{parent}}</a>
<div class="row">
<div class="col-md-5">
<div class="row">
{{#each item in model }}
<div {{action 'linkToKey' item.key }} class="panel panel-link panel-short">
@ -91,17 +91,20 @@
<div class="col-md-5">
<div class="row">
<div {{action 'linkToKey' model.key }} class="panel panel-link panel-short">
<div {{bind-attr class=":panel-bar model.isFolder:bg-gray:bg-light-gray" }}></div>
{{#each item in siblings }}
<div {{action 'linkToKey' item.key }} class="panel panel-link panel-short">
<div {{bind-attr class=":panel-bar item.isFolder:bg-gray:bg-light-gray" }}></div>
<div class="panel-heading">
<h3 class="panel-title">
{{model.key}}
{{item.key}}
</h3>
</div>
</div>
</div>
{{/each}}
</div>
</div>
<div class="col-md-5 col-md-offset-1">
{{ input value=model.value class="form-control"}}

View File

@ -87,9 +87,12 @@ App.Key = Ember.Object.extend({
parentKeys: function() {
var parts = this.get('key').split('/')
parts.pop()
console.log(parts)
return parts
console.log(parts)
part = parts.slice(2)
console.log(part)
return '/'
}.property('parentKey')
});

View File

@ -12,9 +12,10 @@ App.Router.map(function() {
this.resource("nodes", { path: "/nodes" }, function() {
this.route("show", { path: "/:name" });
});
this.resource("kv", { path: "/kv" });
this.resource("kv.show", { path: "/kv/:key" });
this.resource("kv.edit", { path: "/kv/:key/edit" });
this.resource("kv", { path: "/kv" }, function(){
this.route("show", { path: "/:key" });
this.route("edit", { path: "/:key/edit" });
})
});
this.route("index", { path: "/" });

View File

@ -91,8 +91,11 @@ App.KvEditRoute = App.BaseRoute.extend({
var key = params.key.replace(/-/g, "/")
return App.Key.create().setProperties(window.fixtures.keys_full[key]);
},
setupController: function(controller, model) {
controller.set('content', model);
controller.set('siblings', this.modelFor('kv.show'));
console.log(this.modelFor('kv.show'))
controller.set('parent', model.get('parentKeys'));
}
});

View File

@ -303,10 +303,15 @@ fixtures.keys_full = {
'key': 'web/foo/bar',
'value': 'baz'
},
"web/foo/baz": {
'key': 'web/foo/baz',
'value': 'test'
},
"web/": [
"web/foo/"
],
"web/foo/": [
"web/foo/bar"
"web/foo/bar",
"web/foo/baz"
]
};