[damned-lies] Fixed initial setup of action form, even after form error



commit 03619f82d828e96626a6969b6fb74e05a2380404
Author: Claude Paroz <claude 2xlibre net>
Date:   Mon Mar 5 15:32:13 2018 +0100

    Fixed initial setup of action form, even after form error
    
    Fixes bug #794084.

 templates/vertimus/vertimus_detail.html |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/templates/vertimus/vertimus_detail.html b/templates/vertimus/vertimus_detail.html
index b680407..83858e3 100644
--- a/templates/vertimus/vertimus_detail.html
+++ b/templates/vertimus/vertimus_detail.html
@@ -11,21 +11,24 @@ tr.tr_author, tr.tr_sync_master { display: none; }
 </style>
 <script type="text/javascript" src="{{ STATIC_URL }}js/autosize.min.js"></script>
 <script type="text/javascript">
+
+function updateForm() {
+    var actionValue = $("#id_action").val();
+    $("#id_send_to_ml").prop('checked', send_mail_defaults[actionValue]);
+    if (actionValue == 'CI') {
+        $("tr.tr_author, tr.tr_sync_master").css('display', 'table-row');
+        $("tr.tr_file").css('display', 'none');
+    } else {
+        $("tr.tr_author, tr.tr_sync_master").css('display', 'none');
+        $("tr.tr_file").css('display', 'table-row');
+    }
+}
+
 $(document).ready(function() {
     autosize(document.querySelector('#id_comment'));
     if(typeof send_mail_defaults != 'undefined') {
-      $("#id_send_to_ml").prop('checked', send_mail_defaults[$("#id_action").val()]);
-      $("#id_action").change(function () {
-        var value = $(this).val();
-        $("#id_send_to_ml").prop('checked', send_mail_defaults[value]);
-        if (value == 'CI') {
-            $("tr.tr_author, tr.tr_sync_master").css('display', 'table-row');
-            $("tr.tr_file").css('display', 'none');
-        } else {
-            $("tr.tr_author, tr.tr_sync_master").css('display', 'none');
-            $("tr.tr_file").css('display', 'table-row');
-        }
-      });
+        $("#id_action").change(updateForm);
+        updateForm();
     }
 });
 </script>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]