From c3d97de7bdec3f7899340c606f46276836eb2a8b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 9 Jul 2021 19:20:12 +0200 Subject: Preventive file: work on inlines --- .../templates/ishtar/forms/preventive_detail.html | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'archaeological_files/templates') 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 @@
- +
- {{block.super}} + {% for inline in inline_forms %} +

{{inline.form_label}}

+ {% bs_formset inline 0 True %} + {% endfor %} {% 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 %} {# #} -- cgit v1.2.3