aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/base/config_bundle/steps/define_software.html
blob: 43f3f5d0ce5132bf7877f2573d8166436e4b1bb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{% extends "config_bundle/steps/table_formset.html" %}

{% load bootstrap4 %}

{% block table %}
    <thead>
        <tr>
            <th>Device</th>
            <th>Image</th>
            <th>HeadNode</th>
        </tr>
    </thead>
    <tbody>
{% for form in formset %}
    <tr>
        <td>{% bootstrap_field form.host_name show_label=False %}</td>
        <td>{% bootstrap_field form.image show_label=False %}</td>
        <td class="table_hidden_input_parent">
            <input id="radio_{{forloop.counter}}" class="my_radio" type="radio" name="headnode" value="{{forloop.counter}}">
            {{ form.headnode }}
        </td>
    </tr>
{% endfor %}
{{formset.management_form}}

{% endblock table %}

{% block tablejs %}
<script>
    document.getElementById("radio_{{headnode}}").checked = true;

    function radio_pre_submit(){
        var parents = document.getElementsByClassName("table_hidden_input_parent");
        for(const node of parents){
            const radio = node.getElementsByClassName("my_radio")[0];
            const checkbox = radio.nextElementSibling;
            if(radio.checked){
                checkbox.value = "True";
            }
        }
    }

    form_submission_callbacks.push(radio_pre_submit);
</script>
{% endblock tablejs %}