Commit 8bbd5529 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Thomas Gambier

slapos_jio: Select the lowest index as default on parameter editor

This fix up the default selected when no software type is pre-defined.
parent 2ed8fcaf
...@@ -248,7 +248,8 @@ ...@@ -248,7 +248,8 @@
default_dict[default_value], default_dict[default_value],
default_div, default_div,
path + "/" + default_value, path + "/" + default_value,
restricted); restricted
);
div.appendChild(default_div); div.appendChild(default_div);
} }
} }
...@@ -748,13 +749,27 @@ ...@@ -748,13 +749,27 @@
parameter_shared = gadget.element.querySelector('input.parameter_shared'), parameter_shared = gadget.element.querySelector('input.parameter_shared'),
parameter_schema_url = gadget.element.querySelector('input.parameter_schema_url'), parameter_schema_url = gadget.element.querySelector('input.parameter_schema_url'),
s_input = gadget.element.querySelector('input.slapos-serialisation-type'), s_input = gadget.element.querySelector('input.slapos-serialisation-type'),
selection_option_list = []; selection_option_list = [],
lowest_index = 999,
lowest_option_index;
if (input.children.length === 0) {
if (option_selected === undefined) { if (option_selected === undefined) {
option_selected = options.value.parameter.softwaretype; // search by the lowest index
for (option_index in json['software-type']) {
if (json['software-type'].hasOwnProperty(option_index)) {
if (json['software-type'][option_index].index === undefined) {
json['software-type'][option_index].index = 999;
}
if (json['software-type'][option_index].index < lowest_index) {
lowest_index = json['software-type'][option_index].index;
lowest_option_index = option_index;
}
}
}
} }
if (input.children.length === 0) {
for (option_index in json['software-type']) { for (option_index in json['software-type']) {
if (json['software-type'].hasOwnProperty(option_index)) { if (json['software-type'].hasOwnProperty(option_index)) {
option = document.createElement("option"); option = document.createElement("option");
...@@ -771,23 +786,22 @@ ...@@ -771,23 +786,22 @@
option.textContent = json['software-type'][option_index].title; option.textContent = json['software-type'][option_index].title;
if (json['software-type'][option_index].index) { if (json['software-type'][option_index].index) {
option['data-index'] = json['software-type'][option_index].index; option['data-index'] = json['software-type'][option_index].index;
} } else {
if (options.value.parameter.shared === undefined) { option['data-index'] = 999;
options.value.parameter.shared = false;
} }
if (option_selected === undefined) { if (option_index === lowest_option_index) {
option_selected = option.value; option_selected = option.value;
option.selected = "selected";
option_selected_index = option_index; option_selected_index = option_index;
if (json['software-type'][option_index].shared === true) { if (json['software-type'][option_index].shared === true) {
parameter_shared.value = true; parameter_shared.value = true;
} else { } else {
parameter_shared.value = false; parameter_shared.value = false;
} }
if (options.value.parameter.shared === undefined) {
options.value.parameter.shared = parameter_shared.value;
} }
if (softwaretype === undefined) {
softwaretype = option_selected;
} }
if (json['software-type'][option_index].shared === undefined) { if (json['software-type'][option_index].shared === undefined) {
......
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>982.28162.53454.25088</string> </value> <value> <string>984.8983.16389.42973</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -293,7 +293,7 @@ ...@@ -293,7 +293,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1583838932.3</float> <float>1590470140.21</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