Commit e70ca940 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Do not crash if no option is selected

parent 486c5025
...@@ -99,15 +99,19 @@ ...@@ -99,15 +99,19 @@
.declareMethod('getContent', function getContent() { .declareMethod('getContent', function getContent() {
var result = {}, var result = {},
select = this.element.querySelector('select'); select = this.element.querySelector('select'),
selected_option;
if (this.state.editable) { if (this.state.editable) {
result[select.getAttribute('name')] = selected_option = select.options[select.selectedIndex];
select.options[select.selectedIndex].value; if (selected_option !== undefined) {
// Change the value state in place result[select.getAttribute('name')] =
// This will prevent the gadget to be changed if selected_option.value;
// its parent call render with the same value // Change the value state in place
// (as ERP5 does in case of formulator error) // This will prevent the gadget to be changed if
this.state.value = result[select.getAttribute('name')]; // its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = result[select.getAttribute('name')];
}
} }
return result; return result;
}) })
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>977.38881.34981.23125</string> </value> <value> <string>978.42847.9438.64699</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1569336908.59</float> <float>1569589427.71</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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