Commit 3cc347f7 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: improve code to select a default graphic type

parent 0fb7146d
...@@ -7,6 +7,21 @@ ...@@ -7,6 +7,21 @@
loading_class_list = ['ui-icon-spinner', 'ui-btn-icon-left'], loading_class_list = ['ui-icon-spinner', 'ui-btn-icon-left'],
disabled_class = 'ui-disabled'; disabled_class = 'ui-disabled';
function getDefaultGraphicType(option_list) {
var i,
default_option_list = [
"translated_simulation_state_title",
"translated_validation_state_title"
];
for (i = 0; i < option_list.length; i += 1) {
if (default_option_list.indexOf(option_list[i][0]) !== -1) {
return option_list[i][0];
}
}
return option_list[0][0];
}
function buildFieldGadgetParam(value) { function buildFieldGadgetParam(value) {
var field_gadget_param; var field_gadget_param;
...@@ -582,7 +597,7 @@ ...@@ -582,7 +597,7 @@
// graphic // graphic
enable_graphic: options.enable_graphic, enable_graphic: options.enable_graphic,
graphic_type: graphic_type || option_list[0][0] graphic_type: graphic_type || getDefaultGraphicType(option_list)
}); });
}); });
}); });
...@@ -1215,11 +1230,11 @@ ...@@ -1215,11 +1230,11 @@
gadget.state.graphic_type && gadget.state.graphic_type &&
gadget.state.option_list.length > 0 && gadget.state.option_list.length > 0 &&
gadget.state.graphic_type !== "") { gadget.state.graphic_type !== "") {
gadget.element.querySelector(
'select[name="GraphicSelect"]'
).value = gadget.state.graphic_type;
result_queue result_queue
.push(function () { .push(function () {
gadget.element.querySelector(
'select[name="GraphicSelect"]'
).value = gadget.state.graphic_type;
return gadget.declareGadget('gadget_graphic.html', { return gadget.declareGadget('gadget_graphic.html', {
scope: 'gadget_graphic', scope: 'gadget_graphic',
element: gadget.element.querySelector(".graphic_area") element: gadget.element.querySelector(".graphic_area")
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>997.32335.40434.60296</string> </value> <value> <string>997.32361.48448.8823</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1642121302.43</float> <float>1642122989.73</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