Commit db75d68f authored by Jérome Perrin's avatar Jérome Perrin

GUI: support integer data type

parent af8d7e2b
......@@ -56,6 +56,9 @@
if (property_definition.type === "number") {
return gadget.declareGadget("../number_field/index.html");
}
if (property_definition.type === "integer") {
return gadget.declareGadget("../integer_field/index.html");
}
if (property_definition.enum) {
return gadget.declareGadget("../list_field/index.html");
}
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Number field</title>
<!-- renderjs -->
<script src="../<%= copy.rsvp.relative_dest %>"></script>
<script src="../<%= copy.renderjs.relative_dest %>"></script>
<!-- custom script -->
<script src="integerfield.js" type="text/javascript"></script>
</head>
<body>
<input type='number' step="1" data-mini="true" />
</body>
</html>
/*global window, rJS */
(function (window, rJS) {
"use strict";
rJS(window)
.ready(function (gadget) {
return gadget.getElement()
.push(function (element) {
gadget.element = element;
});
})
.declareMethod('render', function (options) {
var input = this.element.querySelector('input');
input.setAttribute('value', options.value);
input.setAttribute('name', options.key);
input.setAttribute('title',
options.property_definition.description);
})
.declareMethod('getContent', function () {
var input = this.element.querySelector('input'),
result = {};
if (input.value !== "") {
result[input.getAttribute('name')] = parseFloat(input.value);
} else {
result[input.getAttribute('name')] = null;
}
return result;
});
}(window, rJS));
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