Commit a64d97cb authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] stringfield.render now support being called multiple times

parent e3eb3402
......@@ -20,26 +20,38 @@
})
.declareMethod('render', function (options) {
var element,
text,
field_json = options.field_json || {};
field_json = options.field_json || {},
created = false;
this.props.value = field_json.value || field_json.default || "";
this.props.editable = field_json.editable;
if (field_json.editable) {
element = document.createElement('input');
element.setAttribute("type", "text");
element = this.element.querySelector('input');
if (element === null) {
element = document.createElement('input');
element.setAttribute("type", "text");
created = true;
}
element.setAttribute('value', this.props.value);
element.setAttribute('name', field_json.key);
element.setAttribute('title', field_json.title);
if (field_json.required === 1) {
element.setAttribute('required', 'required');
} else {
element.removeAttribute('required');
}
} else {
element = document.createElement("p");
element.setAttribute("class", "ui-content-non-editable");
text = document.createTextNode(this.props.value);
element.appendChild(text);
element = this.element.querySelector('p');
if (element === null) {
element = document.createElement("p");
element.setAttribute("class", "ui-content-non-editable");
created = true;
}
element.textContent = this.props.value;
}
if (created) {
this.element.innerHTML = '';
this.element.appendChild(element);
}
this.element.appendChild(element);
})
.declareMethod('getContent', function () {
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.22535.16679.23876</string> </value>
<value> <string>953.628.51543.17476</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1456317346.39</float>
<float>1470314253.13</float>
<string>UTC</string>
</tuple>
</state>
......
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