add nick
[laas.git] / src / templates / base / config_bundle / steps / define_software.html
1 {% extends "config_bundle/steps/table_formset.html" %}
2
3 {% load bootstrap4 %}
4
5 {% block table %}
6     <thead>
7         <tr>
8             <th>Device</th>
9             <th>Image</th>
10             <th>HeadNode</th>
11         </tr>
12     </thead>
13     <tbody>
14 {% for form in formset %}
15     <tr>
16         <td>{% bootstrap_field form.host_name show_label=False %}</td>
17         <td>{% bootstrap_field form.image show_label=False %}</td>
18         <td class="table_hidden_input_parent">
19             <input id="radio_{{forloop.counter}}" class="my_radio" type="radio" name="headnode" value="{{forloop.counter}}">
20             {{ form.headnode }}
21         </td>
22     </tr>
23 {% endfor %}
24 {{formset.management_form}}
25
26 {% endblock table %}
27
28 {% block tablejs %}
29 <script>
30
31     function radio_pre_submit(){
32         var parents = document.getElementsByClassName("table_hidden_input_parent");
33         for(const node of parents){
34             const radio = node.getElementsByClassName("my_radio")[0];
35             const checkbox = radio.nextElementSibling;
36             if(radio.checked){
37                 checkbox.value = "True";
38             }
39         }
40     }
41
42     form_submission_callbacks.push(radio_pre_submit);
43 </script>
44 {% endblock tablejs %}