From 0ce2a779942d389b20077c1da069ec67f2a182d8 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 6 Oct 2016 09:05:18 +0000
Subject: [PATCH] [erp5_web_renderjs_ui] Allow the page relation search to be
 rendered multiple time

---
 ...gadget_erp5_page_relation_search_html.html |  1 -
 ..._gadget_erp5_page_relation_search_html.xml |  4 +--
 ...rjs_gadget_erp5_page_relation_search_js.js | 36 ++++++++-----------
 ...js_gadget_erp5_page_relation_search_js.xml |  4 +--
 4 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.html b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.html
index 02b5b0739e..14ff32f4c2 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.html
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.html
@@ -12,7 +12,6 @@
     <script src="renderjs.js" type="text/javascript"></script>
 
     <!-- custom script -->
-    <script src="gadget_global.js" type="text/javascript"></script>
     <script src="gadget_erp5_page_relation_search.js" type="text/javascript"></script>
 
 
diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.xml
index 703853913d..15fe38480d 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.xml
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_html.xml
@@ -234,7 +234,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>950.53250.43607.26129</string> </value>
+                <value> <string>952.64761.25287.18397</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -252,7 +252,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1461848814.52</float>
+                        <float>1475744547.02</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.js b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.js
index 1eda0f8a56..c1991216c6 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.js
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.js
@@ -1,7 +1,6 @@
-/*global window, rJS */
 /*jslint nomen: true, indent: 2, maxerr: 3 */
-/*global window, rJS, RSVP, Handlebars, loopEventListener*/
-(function (window, rJS, RSVP, Handlebars, loopEventListener) {
+/*global window, rJS, RSVP, Handlebars*/
+(function (window, rJS, RSVP, Handlebars) {
   "use strict";
 
   /////////////////////////////////////////////////////////////////
@@ -130,25 +129,18 @@
           return gadget.triggerSubmit.apply(gadget, argument_list);
         });
     })
-    .declareService(function () {
-      var gadget = this,
-        select = gadget.props.element.querySelector("select");
-      if (select) {
-        return loopEventListener(
-          select,
-          'change',
-          false,
-          function (event) {
-            var target = event.target,
-              value = target.options[target.selectedIndex].value;
-            return gadget.redirect({
-              command: 'change',
-              options: {
-                select_template: value
-              }
-            });
+    .onEvent('change', function (evt) {
+      var target = evt.target,
+        value;
+      if (target.nodeName === 'SELECT') {
+        value = target.options[target.selectedIndex].value;
+        return this.redirect({
+          command: 'change',
+          options: {
+            select_template: value
           }
-        );
+        });
       }
     });
-}(window, rJS, RSVP, Handlebars, loopEventListener));
\ No newline at end of file
+
+}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.xml
index 65458deff4..20cf540ee1 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.xml
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_relation_search_js.xml
@@ -234,7 +234,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>951.48046.6494.25736</string> </value>
+                <value> <string>954.27036.35871.42001</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -252,7 +252,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1466092941.35</float>
+                        <float>1475744573.87</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
-- 
2.30.9