Update history. Fix JSON schema default value styling not working for `false` and `null`, and fixed the styling not updating when clicking a boolean checkbox (See #666)

This commit is contained in:
jos 2019-03-17 15:56:29 +01:00
parent c79bea4eb8
commit 7c398aeef7
3 changed files with 13 additions and 5 deletions

View File

@ -3,8 +3,10 @@
https://github.com/josdejong/jsoneditor https://github.com/josdejong/jsoneditor
## not yet published, version 5.31.2 ## not yet published, version 5.32.0
- Implemented support for reckoning with JSON schema default values: custom
styling can be applied for default and non-default values. Thanks @AdamVig.
- Fixed #667: resolving JSON Schema examples and descriptions did not always - Fixed #667: resolving JSON Schema examples and descriptions did not always
work for referenced schemas. Thanks @AdamVig. work for referenced schemas. Thanks @AdamVig.

View File

@ -16,12 +16,16 @@
height: 500px; height: 500px;
} }
/* custom bold styling for non-default JSON schema values */
.jsoneditor-is-not-default {
font-weight: bold;
}
</style> </style>
</head> </head>
<body> <body>
<h1>JSON schema validation</h1> <h1>JSON schema validation</h1>
<p> <p>
This example demonstrates JSON schema validation. The JSON object in this example must contain properties <code>firstName</code> and <code>lastName</code>, can can optionally have a property <code>age</code> which must be a positive integer. This example demonstrates JSON schema validation. The JSON object in this example must contain properties like <code>firstName</code> and <code>lastName</code>, can can optionally have a property <code>age</code> which must be a positive integer.
</p> </p>
<p> <p>
See <a href="http://json-schema.org/" target="_blank">http://json-schema.org/</a> for more information. See <a href="http://json-schema.org/" target="_blank">http://json-schema.org/</a> for more information.
@ -89,7 +93,8 @@
"examples": [ "examples": [
"Human Resources Coordinator", "Human Resources Coordinator",
"Software Developer" "Software Developer"
] ],
"default": "Software Developer"
}, },
"address": { "address": {
"type": "string" "type": "string"
@ -107,7 +112,7 @@
lastName: 'Doe', lastName: 'Doe',
gender: null, gender: null,
age: "28", age: "28",
availableToHire: 1, availableToHire: true,
job: { job: {
company: 'freelance', company: 'freelance',
role: 'developer', role: 'developer',

View File

@ -1917,7 +1917,7 @@ Node.prototype._getDomField = function(silent) {
*/ */
Node.prototype._updateDomDefault = function () { Node.prototype._updateDomDefault = function () {
// Short-circuit if schema is missing, has no default, or if Node has children // Short-circuit if schema is missing, has no default, or if Node has children
if (!this.schema || !this.schema.default || this._hasChilds()) { if (!this.schema || this.schema.default === undefined || this._hasChilds()) {
return; return;
} }
@ -2891,6 +2891,7 @@ Node.prototype.onEvent = function (event) {
if (type == 'change' && target == dom.checkbox) { if (type == 'change' && target == dom.checkbox) {
this.dom.value.innerHTML = !this.value; this.dom.value.innerHTML = !this.value;
this._getDomValue(); this._getDomValue();
this._updateDomDefault();
} }
// update the value of the node based on the selected option // update the value of the node based on the selected option