Use JSON schema title as name for the root object if defined (see #635)
This commit is contained in:
parent
4813cd79a1
commit
10daf40b56
|
@ -8,6 +8,7 @@ https://github.com/josdejong/jsoneditor
|
||||||
- Breaking change: upgraded dependency `ajv@6.10.0`, supporting JSON schema
|
- Breaking change: upgraded dependency `ajv@6.10.0`, supporting JSON schema
|
||||||
draft-07 alongside draft-06 and draft-04.
|
draft-07 alongside draft-06 and draft-04.
|
||||||
- Upgraded dependency `vanilla-picker@2.8.1`.
|
- Upgraded dependency `vanilla-picker@2.8.1`.
|
||||||
|
- Use JSON schema title as name for the root object if defined (see #635).
|
||||||
|
|
||||||
|
|
||||||
## 2019-06-08, version 5.34.0
|
## 2019-06-08, version 5.34.0
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var schema = {
|
var schema = {
|
||||||
"title": "Example Schema",
|
"title": "Employee",
|
||||||
|
"description": "Object containing employee details",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"firstName": {
|
"firstName": {
|
||||||
|
|
|
@ -2483,7 +2483,7 @@ Node.prototype.updateField = function (field) {
|
||||||
* indexes of the node will be updated too. False by
|
* indexes of the node will be updated too. False by
|
||||||
* default.
|
* default.
|
||||||
*/
|
*/
|
||||||
Node.prototype.updateDom = function (options) {
|
Node.prototype.updateDom = function(options) {
|
||||||
// update level indentation
|
// update level indentation
|
||||||
var domTree = this.dom.tree;
|
var domTree = this.dom.tree;
|
||||||
if (domTree) {
|
if (domTree) {
|
||||||
|
@ -2512,11 +2512,18 @@ Node.prototype.updateDom = function (options) {
|
||||||
else if (this.field != undefined) {
|
else if (this.field != undefined) {
|
||||||
fieldText = this.field;
|
fieldText = this.field;
|
||||||
}
|
}
|
||||||
else if (this._hasChilds()) {
|
|
||||||
fieldText = this.type;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
fieldText = '';
|
var schema = Node._findSchema(this.editor.options.schema,this.editor.options.schemaRefs || {}, this.getPath());
|
||||||
|
|
||||||
|
if (schema && schema.title) {
|
||||||
|
fieldText = schema.title;
|
||||||
|
}
|
||||||
|
else if (this._hasChilds()) {
|
||||||
|
fieldText = this.type;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fieldText = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
domField.innerHTML = this._escapeHTML(fieldText);
|
domField.innerHTML = this._escapeHTML(fieldText);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
var container = document.getElementById('jsoneditor');
|
var container = document.getElementById('jsoneditor');
|
||||||
|
|
||||||
var schema = {
|
var schema = {
|
||||||
"title": "Example Schema",
|
"title": "User",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"firstName": {
|
"firstName": {
|
||||||
|
|
Loading…
Reference in New Issue