summaryrefslogtreecommitdiff
path: root/archaeological_files/templates
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-10-13 06:16:52 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-08 09:58:48 +0200
commit17835353c0c2eb45deeaa32ffabc9c35d7b65349 (patch)
tree9797f7f3b62118e4e52e117f4752310f02d4fb9e /archaeological_files/templates
parent129719164e92ccdb93d2ac9ef9c4a61d8b645526 (diff)
downloadIshtar-17835353c0c2eb45deeaa32ffabc9c35d7b65349.tar.bz2
Ishtar-17835353c0c2eb45deeaa32ffabc9c35d7b65349.zip
Preventive forms: switch to the relevant tab after submit - disable add default button on form change
Diffstat (limited to 'archaeological_files/templates')
-rw-r--r--archaeological_files/templates/ishtar/forms/preventive_detail.html30
1 files changed, 23 insertions, 7 deletions
diff --git a/archaeological_files/templates/ishtar/forms/preventive_detail.html b/archaeological_files/templates/ishtar/forms/preventive_detail.html
index 1d743c615..9ad5c4802 100644
--- a/archaeological_files/templates/ishtar/forms/preventive_detail.html
+++ b/archaeological_files/templates/ishtar/forms/preventive_detail.html
@@ -16,14 +16,16 @@
</label>
</div>
</div>
- <div class="w-100 pb-3 text-center form-group">
+ <div class="w-100 pb-3 text-center form-group" id="add-default-costs-div">
<a class="btn btn-secondary btn-sm form-planned" type="button"
+ id="add-default-costs"
href="{% url 'file-edit-preventive-default-cost' file.pk %}">
{% trans "Add default costs" %}
</a>
</div>
- <div class="w-100 pb-3 text-center form-group">
+ <div class="w-100 pb-3 text-center form-group" id="copy-planned-costs-div">
<a class="btn btn-secondary btn-sm form-worked" type="button"
+ id="copy-planned-costs"
href="{% url 'file-edit-preventive-copy-planned' file.pk %}">
{% trans "Copy planned costs" %}
</a>
@@ -34,18 +36,22 @@
{% endfor %}
</div>
</div>
+<input type="hidden" id="current_tab" name="current_tab" value="{{current_tab}}"/>
{% endblock %}
{# <script type='text/javascript'> #}
{% block end_js %}
{{block.super}}
- var check_planned_value = function() {
+
+ const check_planned_value = function() {
if ($('#planned-toggle-true').is(":checked") === false){
- $(".form-planned").closest("div.form-group").hide()
- $(".form-worked").closest("div.form-group").show()
+ $(".form-planned").closest("div.form-group").hide();
+ $(".form-worked").closest("div.form-group").show();
+ $("#current_tab").val("worked");
} else {
- $(".form-planned").closest("div.form-group").show()
- $(".form-worked").closest("div.form-group").hide()
+ $(".form-planned").closest("div.form-group").show();
+ $(".form-worked").closest("div.form-group").hide();
+ $("#current_tab").val("planned");
}
};
@@ -71,8 +77,18 @@
});
};
$(document).ready(function(){
+ {% if current_tab == "worked" %}$('#planned-toggle-false').click();{% endif %}
$('input[type=radio][name=planned-toggle]').change(check_planned_value);
$(".form-cost").change(update_units);
+ $(":input").change(
+ function(){
+ $("#add-default-costs").addClass("disabled");
+ $("#copy-planned-costs").addClass("disabled");
+ let disabled_msg = "{% trans 'The form has changed. Submit your modifications first.' %}";
+ $("#add-default-costs-div").attr("title", disabled_msg);
+ $("#copy-planned-costs-div").attr("title", disabled_msg);
+ }
+ );
check_planned_value();
update_units();
});