Skip to content

Commit ba6129c

Browse files
committed
switching to doc object for output JSON
1 parent daf84f3 commit ba6129c

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

app.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,13 @@ Vue.component('json-schema-property', {
4848
var app = new Vue({
4949
el: '#editor',
5050
data: {
51-
schema: {}
51+
schema: {},
52+
doc: {}
5253
},
5354
computed: {
5455
output: {
5556
$get: function() {
56-
var self = this;
57-
var rv = {};
58-
var keys = {};
59-
if (self.schema && self.schema.properties) {
60-
keys = Object.keys(self.schema.properties);
61-
keys.forEach(function(key) {
62-
rv[key] = self.schema.properties[key].value;
63-
});
64-
return JSON.stringify(rv, null, "\t");
65-
} else {
66-
return {};
67-
}
57+
return JSON.stringify(this.doc, null, "\t");
6858
}
6959
}
7060
},

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<form class="pure-form pure-form-aligned">
1919
<h1 v-if="schema.title">{{schema.title}}</h1>
2020
<div v-if="schema.description"><small>{{schema.description}}</small></div>
21-
<div v-repeat="schema.properties" v-component="json-schema-property"></div>
21+
<div v-repeat="schema.properties" v-component="json-schema-property" v-with="doc: doc"></div>
2222
</form>
2323
</div>
2424
<textarea id="schema"
@@ -33,7 +33,7 @@ <h1 v-if="schema.title">{{schema.title}}</h1>
3333
<script id="json-schema-property" type="text/vue-template+html">
3434
<div class="pure-control-group">
3535
<label for="{{$key}}">{{$key}}</label>
36-
<input name="{{$key}}" v-model="value" type="{{type | input_type}}" />
36+
<input name="{{$key}}" v-model="doc.{{$key}}" type="{{type | input_type}}" />
3737
<p class="pure-help-inline" v-if="description"><small>{{description}}</small></p>
3838
</div>
3939
</script>

0 commit comments

Comments
 (0)