summaryrefslogtreecommitdiff
path: root/archaeological_finds/templates/ishtar/forms/qa_find_basket.html
blob: c9224078a97ef0ffcbe7f213c8e53bc68a0a60d0 (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.qa_bf_basket %}
    <div class="form-row">
        <input type="radio" name="qa_bf_create_or_update" value="create"
               id="qa_bf_create-choice" checked >
        &nbsp;<label for="qa_bf_create-choice">{% trans "New" %}</label>
    </div>
    {% else %}
    <input type="hidden" name="qa_bf_create_or_update" value="create">
    {% endif %}
    <div id="qa_bf_new-basket">
        <div class="form-row">
            {% with form.qa_bf_label as field %}
            {% include "blocks/bs_field_snippet.html" %}
            {% endwith %}
        </div>
    </div>
    {% if form.qa_bf_basket %}
    <div class="form-row">
        <input type="radio" name="qa_bf_create_or_update" value="update"
               id="qa_bf_update-choice">
        &nbsp;<label for="qa_bf_update-choice">{% trans "Add" %}</label>
    </div>
    <div id="qa_bf_update-basket">
        <div class="form-row">
            {% with form.qa_bf_basket as field %}
            {% include "blocks/bs_field_snippet.html" %}
            {% endwith %}
        </div>
    </div>
    {% endif %}
{% endblock %}

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

$(document).ready(function(){
    $("#qa_bf_create-choice").click(qa_bf_update_form_display);
    $("#qa_bf_update-choice").click(qa_bf_update_form_display);
    qa_bf_update_form_display();
});

{% endblock %}