From 1ab34e1c692400ef5e7b51b72a0a1d637d6d5f33 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 22 Jul 2021 18:22:54 +0200 Subject: Preventive file: work on inlines - 2 --- .../templates/ishtar/forms/preventive_detail.html | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 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 5b6f7f9ed..cc27e26f3 100644 --- a/archaeological_files/templates/ishtar/forms/preventive_detail.html +++ b/archaeological_files/templates/ishtar/forms/preventive_detail.html @@ -16,10 +16,10 @@ -
+
-
+
{% for inline in inline_forms %} @@ -34,18 +34,21 @@ {% block end_js %} {{block.super}} var check_planned_value = function() { - if (this.value === 'false'){ - $(".form-planned").parent().hide() - $(".form-worked").parent().show() + if ($('#planned-toggle-true').is(":checked") === false){ + $(".form-planned").closest("div.form-group").hide() + $(".form-worked").closest("div.form-group").show() } else { - $(".form-planned").parent().show() - $(".form-worked").parent().hide() + $(".form-planned").closest("div.form-group").show() + $(".form-worked").closest("div.form-group").hide() } }; const cost_units = {{% for unit_pk, value in form_unities %}{% if forloop.counter0 %},{% endif %} {{unit_pk}}: "{{value}}"{% endfor %} }; + const flat_rates = [{% for pk in form_flat_rates %}{% if forloop.counter0 %},{% endif %} + "{{pk}}"{% endfor %} + ]; var update_units = function() { $(".form-cost").each(function(){ var unit = cost_units[$(this).val()]; @@ -53,6 +56,12 @@ unit = "..."; } $(this).parent().parent().find(".unit-label").html(unit); + if (flat_rates.indexOf($(this).val()) != -1){ + $(this).parent().parent().find(".unit-form").prop("disabled", true); + } else { + $(this).parent().parent().find(".unit-form").prop("disabled", false); + } + check_planned_value(); }); }; $(document).ready(function(){ -- cgit v1.2.3