blob: 8a6367c7e1d1986969093054a8e728e350dab1a7 (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
{% 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 %}
<h4>{% trans "Finds" %}</h4>
<ul>{% for item in items %}
<li>{{item}}</li>{% endfor %}
</ul>
<h4>{% trans "Packaging" %}</h4>
{% for hidden in form.hidden_fields %}
{{hidden}}
{% if hidden.errors %}<div class="invalid-feedback">
{{ hidden.errors }}
</div>{% endif %}
{% endfor %}
<div class="form-row">
{% with force_large_col=True %}
{% with form.container as field %}
{% include "blocks/bs_field_snippet.html" %}
{% endwith %}
{% with form.container_to_change as field %}
{% include "blocks/bs_field_snippet.html" %}
{% endwith %}
{% endwith %}
</div>
{% comment %}
<div class="form-row">
{{ form.collection }} <label for="{{form.collection.auto_id}}">
{% trans "Associate to the collection of the container" %}
</label>
</div>
{% endcomment %}
<div class="form-row">
{{ form.create_treatment }} <label for="{{form.create_treatment.auto_id}}">
{% trans "Associate a treatment" %}
</label>
</div>
<div id="new-treatment">
<div class="form-row">
{% with force_large_col=false %}{% for field in form %}
{% if field.name != 'container_to_change' and field.name != 'collection' and field.name != 'container' and field.name != 'create_treatment' %}
{% include "blocks/bs_field_snippet.html" %}
{% endif %}
{% endfor %}{% endwith %}
</div>
</div>
{% endblock %}
{% block js %}
var update_form_display = function(){
if ($("#{{form.create_treatment.auto_id}}:checked").length){
$("#new-treatment").show();
} else {
$("#new-treatment").hide();
}
};
var treatment_type_ref_choices = "{{form.treatment_type_ref_choices|safe}}";
var treatment_type_current_choices = "{{form.treatment_type_current_choices|safe}}";
var treatment_type_all_choices = "{{form.treatment_type_all_choices|safe}}";
var update_treatment_type_choices = function(){
var container_to_change = $("#id_qa-packaging-container_to_change").val();
var tt_sel = $("#id_qa-packaging-treatment_type")
tt_sel.empty()
if (container_to_change == 'reference'){
tt_sel.append(treatment_type_ref_choices);
}
if (container_to_change == 'current'){
tt_sel.append(treatment_type_current_choices);
}
if (container_to_change == 'current-and-reference'){
tt_sel.append(treatment_type_all_choices);
}
};
$(document).ready(function(){
$("#{{form.create_treatment.auto_id}}").click(update_form_display);
$("#{{form.container_to_change.auto_id}}").change(update_treatment_type_choices);
update_form_display();
update_treatment_type_choices();
});
{% endblock %}
|