-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2u-test-editor.html
187 lines (179 loc) · 6.49 KB
/
e2u-test-editor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!--
HTML/Template file: e2u-test-editor.html
purpose: Provide test environment for demo
Copyright(C) 2017 friendlyGIS GmbH,
Gerhard Höger-Hansen, Germany
http://www.friendlygis.com
info@friendlygis.com
https://github.com/GerhardHH
----
Description:
Simply provides schema and value data and uses the
e2u-json-object-editor to show it. Provides a text display
of the resulting object and buttons to update in both directions.
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-demo-helpers/demo-pages-shared-styles.html">
<link rel="import" href="../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../paper-input/paper-textarea.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="./e2u-json-object-editor.html">
<!--
`e2u-test-editor`
Test frame for the `e2u-json-object-editor`, simply providing the test data.
@demo demo/index.html
-->
<dom-module id="e2u-test-editor">
<template>
<style is="custom-style" include="demo-pages-shared-styles">
div.e2u-demo {
background-color: rgb(187, 224, 181);
padding: 5px;
}
</style>
<div class="vertical-section-container centered">
<demo-snippet>
<div class='e2u-demo'>
<e2u-json-object-editor
schema="[[schema]]" value="{{value}}"
label="Energy2use JSON schema object editor">
</e2u-json-object-editor>
</div>
<div class="layout horizontal centered">
<paper-button raised on-tap="_updTapped">Update Editor
<iron-icon icon='arrow-upward'></iron-icon>
</paper-button>
<paper-button raised on-tap="_getTapped">Update Object
<iron-icon icon='arrow-downward'></iron-icon>
</paper-button>
</div>
<paper-textarea label="Resulting object" value="{{strValue}}"></paper-textarea>
</demo-snippet>
</div>
</template>
<script>
Polymer({
is: 'e2u-test-editor',
properties: {
schema: {
type: Object,
notify: true,
value: function() {
return {
"$schema": "http://json-schema.org/schema#",
"title": "Store",
"type": "object",
"properties": {
"company": {
"title": "Firma",
"type": "string"
},
"name": {
"title": "Name",
"type": "object",
"properties": {
"firstName": {
"title": "Vorname",
"type": "string"
},
"lastName": {
"title": "Nachname",
"type": "string",
"minLength": 3
},
}
},
"salary": {
"title": "Gehalt p.M.",
"type": "number",
"minimum": 2000,
"maximum": 20000
},
"birthday": {
"title": "Geburtstag",
"type": "string",
"format": "date"
},
"email": {
"title": "E-Mail",
"type": "string",
"format": "email"
},
"homepage": {
"title": "Homepage",
"type": "string",
"format": "uri"
},
"phoneNumbers": {
"title": "Telefonnummern",
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"title": "Type",
"type": "string"
},
"phoneNumber": {
"title": "Phone Number",
"type": "string",
}
}
}
},
"strings": {
"title": "Teststrings",
"type": "array",
"items": {
"type": "string"
}
},
"comment": {
"title": "Anmerkungen",
"type": "string",
"component": {
"name": "paper-textarea",
"valueProperty": "value"
}
},
}
}
}
},
value: {
type: Object,
notify: true,
value: function() {
return {
"company": "friendlyGIS GmbH",
"name": {
"firstName": "Gerhard",
"lastName": "Höger-Hansen"
},
"email": "info@friendlygis.com",
"comment": "This text uses paper-textarea thus\nallowing us\nmultiline data!"
};
}
},
strValue: {
type: String,
notify: true
}
},
observers: ['_valueChanged(value.*)'],
ready: function() {
//console.log('e2u-test-editor initialized');
},
_valueChanged: function(change) {
// update the string value for the user
this.strValue = JSON.stringify(this.value, null, 3);
},
_updTapped: function() {
this.value = JSON.parse(this.strValue);
},
_getTapped: function() {
this.strValue = JSON.stringify(this.value, null, 3);
}
});
</script>
</dom-module>