From f873d8ff5561ce8be1e632c55ec82e94557797c7 Mon Sep 17 00:00:00 2001
From: Yusei Tahara <yusei@nexedi.com>
Date: Wed, 2 Mar 2016 18:20:46 +0900
Subject: [PATCH] Submit action must be disabled while solver is being updated.
 End user sometimes click too fast that submit action fails due to lack of
 'my_tested_property_list'.

---
 .../gadget_solve_divergence_dialog.js.xml     | 31 +++++++++++++++++--
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_simulation_fast_input/SkinTemplateItem/portal_skins/erp5_simulation_fast_input/gadget_solve_divergence_dialog.js.xml b/bt5/erp5_simulation_fast_input/SkinTemplateItem/portal_skins/erp5_simulation_fast_input/gadget_solve_divergence_dialog.js.xml
index ffbf708872..63694bcb11 100644
--- a/bt5/erp5_simulation_fast_input/SkinTemplateItem/portal_skins/erp5_simulation_fast_input/gadget_solve_divergence_dialog.js.xml
+++ b/bt5/erp5_simulation_fast_input/SkinTemplateItem/portal_skins/erp5_simulation_fast_input/gadget_solve_divergence_dialog.js.xml
@@ -12,7 +12,7 @@
         </item>
         <item>
             <key> <string>_EtagSupport__etag</string> </key>
-            <value> <string>ts49844688.61</string> </value>
+            <value> <string>ts56910329.62</string> </value>
         </item>
         <item>
             <key> <string>__name__</string> </key>
@@ -91,9 +91,24 @@ function loopEventListener(target, type, useCapture, callback) {\n
     .ready(function (g) {\n
       return g.getElement().push(function (element) {\n
         g.props.element = element;\n
+        g.props.filling_count = 0;\n
       });\n
     })\n
-    .declareService(function (gadget) {\n
+    .declareService(function () {\n
+      var gadget = this;\n
+      return loopEventListener(\n
+          document.querySelector(\'form.main_form\'),\n
+          \'submit\',\n
+          false,\n
+          function (evt) {\n
+            if (gadget.props.filling_count == 0){\n
+              document.querySelector(\'#dialog_submit_button\').click();\n
+            }\n
+          }\n
+        );\n
+    })\n
+    .declareService(function () {\n
+      var gadget = this;\n
       console.log("location",location);\n
       var basedir = location.pathname.split(\'/\').slice(0, -1).join(\'/\') + \'/\',\n
         divergence_choice_list = [],\n
@@ -107,6 +122,10 @@ function loopEventListener(target, type, useCapture, callback) {\n
         console.log("fillDialog, event", event);\n
         console.log("fillDialog, value", event.target.value);\n
         var solver_decision_uid = event.target.name.split("_").pop();\n
+        gadget.props.filling_count += 1;\n
+        var button = document.querySelector(\'#dialog_submit_button\');\n
+        button.disabled = true;\n
+        button.setAttribute(\'style\', \'visibility:hidden\');\n
         return new RSVP.Queue()\n
           .push(function () {\n
             return jIO.util.ajax(\n
@@ -122,6 +141,12 @@ function loopEventListener(target, type, useCapture, callback) {\n
           .push(function (data) {\n
             event.target.parentElement.parentElement.querySelectorAll(\n
               ".listbox-table-data-cell")[2].innerHTML = data.target.response;\n
+            gadget.props.filling_count -= 1;\n
+            if (gadget.props.filling_count === 0) {\n
+              var button = document.querySelector(\'#dialog_submit_button\');\n
+              button.disabled = false;\n
+              button.setAttribute(\'style\', \'visibility:visible\');\n
+            }\n
           });\n
       }\n
 \n
@@ -151,7 +176,7 @@ function loopEventListener(target, type, useCapture, callback) {\n
         </item>
         <item>
             <key> <string>size</string> </key>
-            <value> <int>4102</int> </value>
+            <value> <int>5018</int> </value>
         </item>
         <item>
             <key> <string>title</string> </key>
-- 
GitLab