Commit 195fad7a authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_json_form: jsonschema-form-gadget handle "Const", add checkValidity and liveValidate

parent 7acb6c8d
...@@ -35,6 +35,10 @@ function makeUiSchema(schema, uiSchema, visited) { ...@@ -35,6 +35,10 @@ function makeUiSchema(schema, uiSchema, visited) {
delete value.default; delete value.default;
} }
} }
if (value.const !== undefined) {
value.default = value.const;
uiSchema[key]["ui:readonly"] = true;
}
// This is something used in SlapOS schemas // This is something used in SlapOS schemas
if (value.textarea) { if (value.textarea) {
uiSchema[key]["ui:widget"] = "textarea" uiSchema[key]["ui:widget"] = "textarea"
...@@ -73,7 +77,6 @@ function makeUiSchema(schema, uiSchema, visited) { ...@@ -73,7 +77,6 @@ function makeUiSchema(schema, uiSchema, visited) {
.then(function (schema) { .then(function (schema) {
let uiSchema = {}; let uiSchema = {};
makeUiSchema(schema, uiSchema, new Set()) makeUiSchema(schema, uiSchema, new Set())
console.log('after simplification', schema, uiSchema);
const log = (type) => console.log.bind(console, type); const log = (type) => console.log.bind(console, type);
...@@ -94,12 +97,12 @@ function makeUiSchema(schema, uiSchema, visited) { ...@@ -94,12 +97,12 @@ function makeUiSchema(schema, uiSchema, visited) {
}), }),
// onSubmit: log('submitted'), // onSubmit: log('submitted'),
onError: log('errors'), onError: log('errors'),
liveValidate: true,
}), }),
gadget.element gadget.element
); );
}); });
} }
console.log(this.element, modification_dict);
}) })
.declareMethod( .declareMethod(
...@@ -113,7 +116,9 @@ function makeUiSchema(schema, uiSchema, visited) { ...@@ -113,7 +116,9 @@ function makeUiSchema(schema, uiSchema, visited) {
) )
.declareMethod('checkValidity', function () { .declareMethod('checkValidity', function () {
// TODO if (this.state.errors !== undefined) {
return this.state.errors.length === 0;
}
return true; return true;
}); });
})(window, rJS, RSVP, document); })(window, rJS, RSVP, document);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment