summaryrefslogtreecommitdiff
path: root/archaeological_files/templates
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_files/templates')
-rw-r--r--archaeological_files/templates/ishtar/forms/preventive_detail.html30
1 files changed, 25 insertions, 5 deletions
diff --git a/archaeological_files/templates/ishtar/forms/preventive_detail.html b/archaeological_files/templates/ishtar/forms/preventive_detail.html
index 20adcccfb..5b6f7f9ed 100644
--- a/archaeological_files/templates/ishtar/forms/preventive_detail.html
+++ b/archaeological_files/templates/ishtar/forms/preventive_detail.html
@@ -17,12 +17,15 @@
</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>
+ <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>
- {{block.super}}
+ {% for inline in inline_forms %}
+ <h4>{{inline.form_label}}</h4>
+ {% bs_formset inline 0 True %}
+ {% endfor %}
</div>
</div>
{% endblock %}
@@ -31,7 +34,7 @@
{% block end_js %}
{{block.super}}
var check_planned_value = function() {
- if (this.value == 'false'){
+ if (this.value === 'false'){
$(".form-planned").parent().hide()
$(".form-worked").parent().show()
} else {
@@ -39,7 +42,24 @@
$(".form-worked").parent().hide()
}
};
- $('input[type=radio][name=planned-toggle]').change(check_planned_value);
- $(document).ready(check_planned_value);
+
+ 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> #}