summaryrefslogtreecommitdiff
path: root/archaeological_finds/templates/ishtar/forms/qa_find_basket.html
blob: 77fc2abcd1dd4cb63f1f58a84f27b3b8a44210ff (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{% extends "ishtar/forms/qa_base.html" %}
{% load i18n inline_formset table_form %}

{% block main_form %}
    {% if form.non_field_errors %}
    <div class="alert alert-danger" role="alert">
        {{form.non_field_errors}}
    </div>
    {% endif %}

    {% for hidden in form.hidden_fields %}
    {{hidden}}
    {% if hidden.errors %}<div class="invalid-feedback">
        {{ hidden.errors }}
    </div>{% endif %}
    {% endfor %}

    {% if form.basket %}
    <div class="form-row">
        <input type="radio" name="create_or_update" value="create"
               id="create-choice" checked >
        &nbsp;<label for="create-choice">{% trans "New" %}</label>
    </div>
    {% else %}
    <input type="hidden" name="create_or_update" value="create">
    {% endif %}
    <div id="new-basket">
        <div class="form-row">
            {% with form.label as field %}
            {% include "blocks/bs_field_snippet.html" %}
            {% endwith %}
        </div>
    </div>
    {% if form.basket %}
    <div class="form-row">
        <input type="radio" name="create_or_update" value="update"
               id="update-choice">
        &nbsp;<label for="update-choice">{% trans "Add" %}</label>
    </div>
    <div id="update-basket">
        <div class="form-row">
            {% with form.basket as field %}
            {% include "blocks/bs_field_snippet.html" %}
            {% endwith %}
        </div>
    </div>
    {% endif %}
{% endblock %}

{% block js %}
var update_form_display = function(){
    if ($("#update-choice:checked").length){
        $("#new-basket").hide();
        $("#update-basket").show();
    } else {
        $("#update-basket").hide();
        $("#new-basket").show();
    }
}

$(document).ready(function(){
    $("#create-choice").click(update_form_display);
    $("#update-choice").click(update_form_display);
    update_form_display();
});

{% endblock %}