Skip to content

Commit

Permalink
Hilite error fields
Browse files Browse the repository at this point in the history
  • Loading branch information
exavolt committed Dec 23, 2011
1 parent ed44c54 commit a84ee6d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
21 changes: 21 additions & 0 deletions samples/tests/test-required.json
@@ -0,0 +1,21 @@
{
"type": "object",
"properties": {
"array": {
"description": "Add item",
"type": "array",
"items": {
"type": "object",
"properties": {
"required": { "type": "string", "required": true },
"notRequired": { "type": "string" }
}
}
},
"integer": {
"type": "integer",
"required": true,
"description": "Try 0"
}
}
}
6 changes: 3 additions & 3 deletions src/onde.css
Expand Up @@ -108,8 +108,8 @@
border-bottom: 1px solid #d9d9d9;
background-color: #f3f3f3;
}
.onde-panel label.field-name { color: #333; background-color: #fff;/* border-top-left-radius: 4px; */}
.onde-panel label.field-name.collapser { display: block !important;/* margin-bottom: 2px; */}
.onde-panel label.field-name { color: #333;/* background-color: #fff; border-top-left-radius: 4px; */}
.onde-panel label.field-name.collapser { display: block !important; background-color: #fff;/* margin-bottom: 2px; */}
.onde-panel ul {
list-style: none;
}
Expand Down Expand Up @@ -235,6 +235,6 @@
}

.onde-panel .field.error,
.onde-panel .field.error label {
.onde-panel .field.error > label.field-name.collapser {
background-color: #ffe6df;
}
8 changes: 3 additions & 5 deletions src/onde.js
Expand Up @@ -998,9 +998,6 @@ onde.Onde.prototype._buildProperty = function (propName, propInfo, path, formDat
result.noData = false;
}
} else {
//if (!valData) {
// console.log(fieldName + " " + dataType);
//}
//TODO: Guards
if (valData) {
result.noData = false;
Expand Down Expand Up @@ -1032,7 +1029,8 @@ onde.Onde.prototype._buildProperty = function (propName, propInfo, path, formDat
}
}
}
if (result.errorData) {
if (result.errorCount) {
// This field has one or more error
$('#field-' + this._fieldNameToID(fieldName)).addClass('error');
}
return result;
Expand Down Expand Up @@ -1106,7 +1104,7 @@ onde.Onde.prototype._buildObject = function (schema, path, formData) {
dVal = parseInt(dVal, 10); //TODO: Guard
} else if (dataType == 'boolean') {
//TODO: Guard
dVal = (dVal == 'on' || dVal == 'true' || dVal == 'checked' || dVal !== 0 || dVal === true);
dVal = (dVal === 'on' || dVal === 'true' || dVal === 'checked' || dVal !== 0 || dVal === true);
} else if (dataType == 'string') {
} else {
console.warn("Unsupported type: " + dataType + " (" + fieldName + ")");
Expand Down

0 comments on commit a84ee6d

Please sign in to comment.