Commit 66fd4670 authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Tomáš Peterka

[renderjs_ui] MultiListField does not crash when only one item is selected

/reviewed-on nexedi/erp5!448
parent f5d76b28
......@@ -3,6 +3,13 @@
(function (window, rJS, document, RSVP) {
'use strict';
/* Make sure that returned object is an Array instance. */
function ensureArray(obj) {
if (!obj) {return []; }
if (Array.isArray(obj)) {return obj; }
return [obj];
}
function appendListField(gadget, value, item_list) {
var div = document.createElement('div');
gadget.element.appendChild(div);
......@@ -32,8 +39,9 @@
var field_json = options.field_json || {},
item_list = field_json.items,
state_dict = {
value_list: JSON.stringify(field_json.value ||
field_json.default || []),
value_list: JSON.stringify(
ensureArray(field_json.value || field_json.default)
),
editable: field_json.editable,
required: field_json.required,
name: field_json.key,
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.51162.4768.35123</string> </value>
<value> <string>962.38785.31645.18483</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1482843497.05</float>
<float>1507301921.45</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