ui: handle "folders", directory browsing with parents
This commit is contained in:
parent
3e1bc7dbad
commit
23dc417055
|
@ -114,7 +114,6 @@
|
|||
|
||||
<div class="panel-body">
|
||||
<form class="form">
|
||||
|
||||
<div {{ bind-attr class=":form-group newKey.keyValid:valid" }}>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{{parentKey}}</span>
|
||||
|
@ -122,9 +121,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div {{ bind-attr class=":form-group newKey.valueValid:valid" }}>
|
||||
{{#if newKey.isFolder }}
|
||||
<p>No value needed for nested keys.</p>
|
||||
{{else}}
|
||||
<div class="form-group">
|
||||
{{ textarea value=newKey.Value class="form-control"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<button {{ action "createKey"}} {{bind-attr disabled=newKey.isInvalid }} {{ bind-attr class=":btn newKey.isValid:btn-success:btn-default" }}>Create</button>
|
||||
</form>
|
||||
|
@ -137,7 +140,7 @@
|
|||
|
||||
<script type="text/x-handlebars" data-template-name="kv/edit">
|
||||
<div class="row">
|
||||
<h5><a class="subtle" href="" {{action 'linkToKey' model.grandParentKey }}>{{model.parentKey}}</a></h5>
|
||||
<h5><a class="subtle" href="" {{action 'linkToKey' grandParentKey }}>{{parentKey}}</a></h5>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
|
|
@ -80,12 +80,11 @@ App.KvShowController.reopen({
|
|||
var grandParentKey = this.get('grandParentKey');
|
||||
var controller = this;
|
||||
var dc = this.get('dc').get('datacenter');
|
||||
console.log(dc)
|
||||
|
||||
// If we don't have a previous model to base
|
||||
// on our parent, or we're not at the root level,
|
||||
// strip the leading slash.
|
||||
if (parentKey != undefined || parentKey != "/") {
|
||||
if (parentKey != undefined && parentKey != "/") {
|
||||
newKey.set('Key', (parentKey + newKey.get('Key')));
|
||||
}
|
||||
|
||||
|
@ -96,8 +95,13 @@ App.KvShowController.reopen({
|
|||
data: newKey.get('Value')
|
||||
}).then(function(response) {
|
||||
controller.set('isLoading', false)
|
||||
// Transition to edit the key
|
||||
// transition to the right place
|
||||
console.log(newKey.get('Key'));
|
||||
if (newKey.get('isFolder') == true) {
|
||||
controller.transitionToRoute('kv.show', newKey.get('urlSafeKey'));
|
||||
} else {
|
||||
controller.transitionToRoute('kv.edit', newKey.get('urlSafeKey'));
|
||||
}
|
||||
// Reload the keys in the left column
|
||||
controller.get('keys').reload()
|
||||
}).fail(function(response) {
|
||||
|
|
|
@ -103,8 +103,7 @@ App.Node = Ember.Object.extend({
|
|||
App.Key = Ember.Object.extend(Ember.Validations.Mixin, {
|
||||
// Validates using the Ember.Valdiations library
|
||||
validations: {
|
||||
Key: { presence: true },
|
||||
Value: { presence: true }
|
||||
Key: { presence: true }
|
||||
},
|
||||
|
||||
// Boolean if the key is valid
|
||||
|
@ -122,6 +121,9 @@ App.Key = Ember.Object.extend(Ember.Validations.Mixin, {
|
|||
// Boolean if the key is a "folder" or not, i.e is a nested key
|
||||
// that feels like a folder. Used for UI
|
||||
isFolder: function() {
|
||||
if (this.get('Key') === undefined) {
|
||||
return false;
|
||||
};
|
||||
return (this.get('Key').slice(-1) == "/")
|
||||
}.property('Key'),
|
||||
|
||||
|
|
|
@ -105,8 +105,9 @@ App.KvShowRoute = App.BaseRoute.extend({
|
|||
// Loop over the keys
|
||||
models.keys.forEach(function(item, index) {
|
||||
if (item.get('Key') == key) {
|
||||
// Handle having only one key as a sub-parent
|
||||
parentKey = item.get('Key');
|
||||
grandParentKey = item.get('grandParentKey');
|
||||
grandParentKey = item.get('parentKey');
|
||||
// Remove the dupe
|
||||
models.keys.splice(index, 1);
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ App.KvEditRoute = App.BaseRoute.extend({
|
|||
models.keys.forEach(function(item, index) {
|
||||
if (item.get('Key') == models.key.get('parentKey')) {
|
||||
parentKey = item.get('Key');
|
||||
grandParentKey = item.get('grandParentKey');
|
||||
grandParentKey = item.get('parentKey');
|
||||
// Remove the dupe
|
||||
models.keys.splice(index, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue