From 6ad8df10a458276e5117a5c45665dacaaabbfa5e Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 7 Jan 2016 14:18:19 +0000
Subject: [PATCH] [erp5_web_renderjs_ui] Do not rewrite the header when a field
 changes

Rewritting the header means removing the submit button from the DOM, and losing the submit event.

Example:
* modify an input value
* click (with the mouse/touch) the Save button
* browser with submit 'change' event on the input and 'click' event on the button
* if 'change' event is triggered before, it will lead to the header rewrite. The 'click' event on the button will lead to a form 'submit' event, which will not be catched by the gadget, as the form is already outside the DOM
---
 .../web_page_module/rjs_gadget_erp5_header_js.xml   | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_header_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_header_js.xml
index 0577bcd572..d66b8e45e7 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_header_js.xml
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_header_js.xml
@@ -202,7 +202,14 @@
     .declareMethod(\'notifyChange\', function () {\n
       if (!this.stats.modified) {\n
         this.stats.modified = true;\n
-        return this.render(this.stats.options);\n
+        // Directly modify the previous calculated header\n
+        // in order not to remove the submit input\n
+        // and still receive \'submit\' event\n
+        var class_list = this.props.right_link.querySelector(\'button\').classList;\n
+        if (class_list.contains(\'ui-icon-check\')) {\n
+          class_list.remove(\'ui-icon-check\');\n
+          class_list.add(\'ui-icon-warning\');\n
+        }\n
       }\n
     })\n
     .declareMethod(\'notifySubmitting\', function () {\n
@@ -580,7 +587,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>948.17414.26904.28091</string> </value>
+                <value> <string>948.20235.19332.48128</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -598,7 +605,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1452006752.82</float>
+                        <float>1452175785.28</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
-- 
2.30.9