File tree Expand file tree Collapse file tree 2 files changed +13
-25
lines changed Expand file tree Collapse file tree 2 files changed +13
-25
lines changed Original file line number Diff line number Diff line change 1
- var schema = {
2
- "title" : "Example Schema" ,
3
- "type" : "object" ,
4
- "properties" : {
5
- "firstName" : {
6
- "type" : "string"
7
- } ,
8
- "lastName" : {
9
- "type" : "string"
10
- } ,
11
- "age" : {
12
- "description" : "Age in years" ,
13
- "type" : "integer" ,
14
- "minimum" : 0
15
- }
16
- } ,
17
- "required" : [ "firstName" , "lastName" ]
18
- } ;
19
-
20
1
Vue . component ( 'json-textarea' , {
21
2
template : '{{content}}' ,
22
3
created : function ( ) {
@@ -63,18 +44,23 @@ Vue.component('schema-links', {
63
44
var app = new Vue ( {
64
45
el : '#editor' ,
65
46
data : {
66
- schema : schema
47
+ schema : { }
67
48
} ,
68
49
computed : {
69
50
output : {
70
51
$get : function ( ) {
71
52
var self = this ;
72
53
var rv = { } ;
73
- var keys = Object . keys ( self . schema . properties ) ;
74
- keys . forEach ( function ( key ) {
75
- rv [ key ] = self . schema . properties [ key ] . value ;
76
- } ) ;
77
- return JSON . stringify ( rv , null , "\t" ) ;
54
+ var keys = { } ;
55
+ if ( self . schema && self . schema . properties ) {
56
+ keys = Object . keys ( self . schema . properties ) ;
57
+ keys . forEach ( function ( key ) {
58
+ rv [ key ] = self . schema . properties [ key ] . value ;
59
+ } ) ;
60
+ return JSON . stringify ( rv , null , "\t" ) ;
61
+ } else {
62
+ return { } ;
63
+ }
78
64
}
79
65
}
80
66
} ,
Original file line number Diff line number Diff line change 12
12
v-on ="click: setHref "> {{$key}}</ a > </ li >
13
13
</ ul >
14
14
< div id ="input ">
15
+ < div v-if ="!schema.properties "> < em > Pick a schema. Any schema!</ em >
16
+ < br /> < small > Or paste one in the textarea below.</ small > </ div >
15
17
< h1 > {{schema.title}}</ h1 >
16
18
< div v-repeat ="schema.properties ">
17
19
< label for ="{{$key}} "> {{$key}}</ label >
You can’t perform that action at this time.
0 commit comments