blob: 5b6f7f9ed7b9a45409939e7229db07b2de86420a (
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
|
{% extends "ishtar/forms/base_form.html" %}
{% load i18n table_form %}
{% block bs_form_inlines %}
<div class="card">
<div class="card-body">
<div class="w-100 pb-3 text-center">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-lg btn-secondary active">
<input value="true" type="radio" name="planned-toggle" id="planned-toggle-true" autocomplete="off" checked>
{% trans "Planned" %}
</label>
<label class="btn btn-lg btn-secondary">
<input value="false" type="radio" name="planned-toggle" id="planned-toggle-false" autocomplete="off">
{% trans "Worked" %}
</label>
</div>
</div>
<div class="w-100 pb-3 text-center">
<button class="btn btn-secondary btn-sm form-planned" type="button">{% trans "Add default costs" %}</button>
</div>
<div class="w-100 pb-3 text-center">
<button class="btn btn-secondary btn-sm form-worked" type="button">{% trans "Copy planned costs" %}</button>
</div>
{% for inline in inline_forms %}
<h4>{{inline.form_label}}</h4>
{% bs_formset inline 0 True %}
{% endfor %}
</div>
</div>
{% endblock %}
{# <script type='text/javascript'> #}
{% block end_js %}
{{block.super}}
var check_planned_value = function() {
if (this.value === 'false'){
$(".form-planned").parent().hide()
$(".form-worked").parent().show()
} else {
$(".form-planned").parent().show()
$(".form-worked").parent().hide()
}
};
const cost_units = {{% for unit_pk, value in form_unities %}{% if forloop.counter0 %},{% endif %}
{{unit_pk}}: "{{value}}"{% endfor %}
};
var update_units = function() {
$(".form-cost").each(function(){
var unit = cost_units[$(this).val()];
if (!unit){
unit = "...";
}
$(this).parent().parent().find(".unit-label").html(unit);
});
};
$(document).ready(function(){
$('input[type=radio][name=planned-toggle]').change(check_planned_value);
$(".form-cost").change(update_units);
check_planned_value();
update_units();
});
{% endblock %}
{# </script> #}
|