1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function (_super) {
hui.ui.ModelEditor = function(options) {
this.options = options;
_super.call(this, options);
this._build();
};
hui.ui.ModelEditor.prototype = {
_build : function() {
var form = this._form = hui.ui.Form.create();
var group = form.createGroup();
var model = this.options.model;
hui.each(model.properties, function(prop) {
var widget, label;
if (prop.type == 'text') {
widget = hui.ui.TextInput.create({key: prop.name});
label = prop.name;
}
else if (prop.type == 'number') {
widget = hui.ui.NumberInput.create({key: prop.name});
label = prop.name;
}
if (widget) {
group.add(widget, label);
}
});
document.body.appendChild(form.getElement());
},
setValues : function(values) {
this._form.setValues(values);
}
};
hui.extend(hui.ui.ModelEditor, _super);
})(hui.ui.Component);