From 32a12afff1d20ab430635410cb506aa2756340d2 Mon Sep 17 00:00:00 2001
From: Vincent Bechu <vincent.bechu@nexedi.com>
Date: Mon, 6 Nov 2017 13:18:48 +0000
Subject: [PATCH] [erp5_web_renderjs_ui] Router redirect on home page when it
 fail getting parent's document link.

---
 .../web_page_module/rjs_gadget_erp5_router_js.js          | 8 ++++++++
 .../web_page_module/rjs_gadget_erp5_router_js.xml         | 6 +++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.js b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.js
index f4b7a84ce9..8a8110877d 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.js
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.js
@@ -509,6 +509,14 @@
           copyStickyParameterDict(previous_options, options);
           return addNavigationHistoryAndDisplay(gadget, uri.segment(2), options);
         }
+      }, function (error) {
+        if ((error instanceof jIO.util.jIOError) &&
+            (error.status_code === 404)) {
+          var options = {};
+          copyStickyParameterDict(previous_options, options);
+          return gadget.redirect({command: 'display', options: options});
+        }
+        throw error;
       });
   }
 
diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.xml
index 6afed7d450..4a9e08d7c9 100644
--- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.xml
+++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_router_js.xml
@@ -218,7 +218,7 @@
             </item>
             <item>
                 <key> <string>actor</string> </key>
-                <value> <string>zope</string> </value>
+                <value> <string>vincent</string> </value>
             </item>
             <item>
                 <key> <string>comment</string> </key>
@@ -232,7 +232,7 @@
             </item>
             <item>
                 <key> <string>serial</string> </key>
-                <value> <string>961.9337.61584.40226</string> </value>
+                <value> <string>963.17770.52424.63095</string> </value>
             </item>
             <item>
                 <key> <string>state</string> </key>
@@ -250,7 +250,7 @@
                     </tuple>
                     <state>
                       <tuple>
-                        <float>1501689246.43</float>
+                        <float>1509973413.87</float>
                         <string>UTC</string>
                       </tuple>
                     </state>
-- 
2.30.9