From e60f49d224917ef6c893ee1eaca6a32a1a398e91 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Mon, 25 Mar 2013 08:46:23 +0200
Subject: [PATCH] Refactor code and use proper default page templates names so
 no need to rename manually to enable this bt5.

---
 .../ERP5Site_contextBox.xml                   | 45 -------------------
 .../ERP5Site_getContextBoxActionList.xml      | 10 ++++-
 .../ERP5Site_renderBreadcrumb.xml             |  4 +-
 .../ERP5Site_renderPortalStatusMessage.xml    | 10 +++--
 .../{form_view_disable.xml => form_view.xml}  |  2 +-
 .../gadget-style-lib/erp5_ui.js.xml           |  7 +--
 ...able.xml => template_erp5_xhtml_style.xml} |  6 ++-
 .../{view_main_disable.xml => view_main.xml}  |  2 +-
 bt5/erp5_xhtml_gadget_style/bt/change_log     |  2 +-
 bt5/erp5_xhtml_gadget_style/bt/description    |  3 --
 bt5/erp5_xhtml_gadget_style/bt/revision       |  2 +-
 11 files changed, 29 insertions(+), 64 deletions(-)
 rename bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/{form_view_disable.xml => form_view.xml} (97%)
 rename bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/{template_erp5_xhtml_style_disable.xml => template_erp5_xhtml_style.xml} (96%)
 rename bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/{view_main_disable.xml => view_main.xml} (98%)

diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_contextBox.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_contextBox.xml
index a893bf3bf2..267da41f9c 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_contextBox.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_contextBox.xml
@@ -59,51 +59,6 @@
               onChange="submitAction(this.form,\'Base_doAction\')"\076\n
         \074option selected="selected" value=""\n
                 i18n:translate="" i18n:domain="ui"\076Action...\074/option\076\n
-\074!--        \074tal:block tal:repeat="content_id here/getVisibleAllowedContentTypeList | nothing"\076\n
-          \074option tal:attributes="value string:add $content_id"\n
-                  i18n:translate="" i18n:domain="ui"\076Add \074tal:block tal:content="content_id"\n
-                           i18n:name="portal_type" i18n:translate="" i18n:domain="ui" /\076\074/option\076\n
-        \074/tal:block\076\n
-        \074tal:block tal:define="document_template_list here/getDocumentTemplateList | nothing"\n
-                   tal:condition="document_template_list"\076\n
-          \074option disabled="disabled"\076-- \074tal:block i18n:translate="" i18n:domain="ui"\076Templates\074/tal:block\076 --\074/option\076\n
-          \074tal:block tal:repeat="document_template document_template_list"\076\n
-            \074option tal:attributes="value string:template ${document_template/getRelativeUrl}"\n
-                    i18n:translate="" i18n:domain="ui"\076Add \074tal:block tal:content="document_template/getTitle"\n
-                             i18n:name="document_template" /\076\074/option\076\n
-          \074/tal:block\076\n
-        \074/tal:block\076\n
-\n
-        \074option disabled="disabled"\076-- \074tal:block i18n:translate="" i18n:domain="ui"\076Workflows\074/tal:block\076 --\074/option\076\n
-        \074tal:block tal:repeat="action actions/workflow"\076\n
-          \074option tal:content="action/name"\n
-                  tal:attributes="value string:workflow ${action/url}"\n
-                  i18n:translate="" i18n:domain="ui" /\076\n
-        \074/tal:block\076\n
-        \074option disabled="disabled"\076-- \074tal:block i18n:translate="" i18n:domain="ui"\076Object\074/tal:block\076 --\074/option\076\n
-        \074tal:block tal:repeat="action actions/object_action | nothing"\076\n
-          \074option tal:content="action/name"\n
-                  tal:attributes="value string:object ${action/url}"\n
-                  i18n:translate="" i18n:domain="ui" /\076\n
-        \074/tal:block\076\n
-        \074tal:block tal:define="object_view_list actions/object_view|nothing;\n
-                   module_view_list python:[i for i in object_view_list if i[\'id\']==\'module_view\']"\n
-                   tal:condition="module_view_list"\076\n
-          \074tal:block tal:repeat="action module_view_list"\076\n
-            \074option tal:content="action/name"\n
-                    tal:attributes="value string:object ${action/url}"\n
-                    i18n:translate="" i18n:domain="ui" /\076\n
-          \074/tal:block\076\n
-        \074/tal:block\076--\076\n
-        \074tal:block tal:replace=\'nothing\'\076\n
-          \074!-- XXX folder actions is inherited from CMF, but not used in ERP5 (for now) --\076\n
-\074!--          \074option disabled="disabled"\076-- \074tal:block i18n:translate="" i18n:domain="ui"\076Folder\074/tal:block\076 --\074/option\076\n
-          \074tal:block tal:repeat="action actions/folder"\076\n
-            \074option tal:content="action/name"\n
-                    tal:attributes="value string:folder ${action/url}"\n
-                    i18n:translate="" i18n:domain="ui" /\076\n
-          \074/tal:block\076--\076\n
-        \074/tal:block\076\n
       \074/select\076\n
       \074button type="submit" name="Base_doAction:method" title="Action"\n
               i18n:attributes="title" i18n:domain="ui"\076\n
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_getContextBoxActionList.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_getContextBoxActionList.xml
index 5679df7b5b..d9d90e2a92 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_getContextBoxActionList.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_getContextBoxActionList.xml
@@ -87,6 +87,13 @@ def unLazyActionList(action_list):\n
   return fixed_action_list\n
 \n
 result = {}\n
+result[\'type_info_list\'] = []\n
+result[\'workflow_list\'] = []\n
+result[\'document_template_list\'] = []\n
+result[\'object_workflow_action_list\'] = []\n
+result[\'object_action_list\'] = []\n
+result[\'object_view_list\'] = []\n
+result[\'folder_action_list\'] = []\n
 result[\'object_jump_list\'] = unLazyActionList(actions[\'object_jump\'])\n
 \n
 # add links to edit current portal type\n
@@ -103,7 +110,6 @@ if preferred_html_style_developper_mode:\n
 # add links for workflows\n
 if portal.portal_workflow.Base_getSourceVisibility():\n
   workflow_list = portal.portal_workflow.getWorkflowsFor(context)\n
-  result[\'workflow_list\'] = []\n
   if workflow_list:\n
     result[\'workflow_list\'] = [{"title": "-- %s --" %translate("Workflows"),\n
                                 "url": ""}]\n
@@ -114,7 +120,6 @@ visible_allowed_content_type_list = context.getVisibleAllowedContentTypeList()\n
 result[\'visible_allowed_content_type_list\'] = [{"title": "Add %s" %x,\n
                                                 "url": "add %s" %x} for x in visible_allowed_content_type_list]\n
 \n
-result[\'document_template_list\'] = []\n
 document_template_list = context.getDocumentTemplateList()\n
 if document_template_list:\n
   result[\'document_template_list\'] = [{"title": "-- %s --" %translate("Templates"),\n
@@ -152,6 +157,7 @@ if folder_action_list:\n
                                    "url": ""}]\n
   result[\'folder_action_list\'].extend([{"title": "%s" %x[\'title\'],\n
                                         "url": "folder %s" %x[\'url\']} for x in object_action_list])\n
+# XXX: buttons\n
 \n
 return dumps(result)\n
 
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderBreadcrumb.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderBreadcrumb.xml
index a02935f188..7f303291d1 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderBreadcrumb.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderBreadcrumb.xml
@@ -36,7 +36,8 @@
             <key> <string>_text</string> </key>
             <value> <unicode encoding="cdata"><![CDATA[
 
-<div tal:define="portal here/getPortalObject">\n
+<div tal:define="portal here/getPortalObject;\n
+                 portal_url portal/absolute_url;">\n
 \n
   <div id="breadcrumb" class="breadcrumb">\n
     <tal:block metal:use-macro="here/breadcrumb_render/macros/breadcrumb" />\n
@@ -52,6 +53,7 @@
   <p class="clear"></p>\n
 \n
   <div data-gadget="ERP5Site_renderPortalStatusMessage"\n
+       tal:attributes="data-gadget string:${portal_url}/ERP5Site_renderPortalStatusMessage"\n
        id="portal_status_message"></div>\n
 \n
 \n
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderPortalStatusMessage.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderPortalStatusMessage.xml
index a136051e6a..9ad68c0512 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderPortalStatusMessage.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/ERP5Site_renderPortalStatusMessage.xml
@@ -43,7 +43,9 @@
   \074/head\076\n
   \074body\076\n
 \n
-    \074p class="portal-status-message" style="display:none; color:red;font-weight:bold;"\076\074/p\076\n
+    \074div class="transition_message" \n
+         id="transition_message"\n
+         style="display:none; color:red;font-weight:bold;"\076\074/div\076\n
 \n
     \074script type="text/javascript" language="javascript"\076\n
       //\074![CDATA[\n
@@ -59,20 +61,20 @@
 \n
             gadget.showMessage = function (message, timeout) {\n
               // show message in UI\n
-              var msg_element = $("#portal_status_message p");\n
+              var msg_element = $("#transition_message");\n
               if (timeout===undefined) {\n
                 timeout = 4000;\n
               }\n
               msg_element.toggle();\n
               msg_element.html(message);\n
-              window.setTimeout(\'$("#portal_status_message p").toggle();\', timeout);\n
+              window.setTimeout(\'$("#transition_message").toggle();\', timeout);\n
             };\n
 \n
             // in some cases a message can be inside current URL as well\n
             // so show it.\n
             portal_status_message = getURLParameter("portal_status_message");\n
             if (portal_status_message!==undefined \046\046 portal_status_message!==null \046\046 portal_status_message!==\'null\') {\n
-              gadget.showMessage(portal_status_message, 10000);\n
+              gadget.showMessage(portal_status_message, 5000);\n
             }\n
         });\n
       //]]\076\n
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/form_view_disable.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/form_view.xml
similarity index 97%
rename from bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/form_view_disable.xml
rename to bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/form_view.xml
index 1a97cacb4a..5376974b51 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/form_view_disable.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/form_view.xml
@@ -62,7 +62,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>form_view_disable</string> </value>
+            <value> <string>form_view</string> </value>
         </item>
         <item>
             <key> <string>output_encoding</string> </key>
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/gadget-style-lib/erp5_ui.js.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/gadget-style-lib/erp5_ui.js.xml
index 978bcb8c89..573e0bbb2e 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/gadget-style-lib/erp5_ui.js.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/gadget-style-lib/erp5_ui.js.xml
@@ -8,7 +8,7 @@
       <dictionary>
         <item>
             <key> <string>_EtagSupport__etag</string> </key>
-            <value> <string>ts63864401.96</string> </value>
+            <value> <string>ts63878317.05</string> </value>
         </item>
         <item>
             <key> <string>__name__</string> </key>
@@ -71,9 +71,9 @@ var ERP5UI = ( function () {\n
               url: "ERP5Site_getContextBoxActionList",\n
               dataType: "json",\n
               success: function (data) {\n
-                        console.log(data.object_jump);\n
                         var jump_dom = $(\'select[name="select_jump"]\'),\n
                             action_dom = $(\'select[name="select_action"]\');\n
+                            console.log(data);\n
                         addOptionTagDict(jump_dom, data.object_jump_list);\n
                         addOptionTagDict(jump_dom, data.type_info_list);\n
                         addOptionTagDict(jump_dom, data.workflow_list);\n
@@ -82,6 +82,7 @@ var ERP5UI = ( function () {\n
                         addOptionTagDict(action_dom, data.object_workflow_action_list);\n
                         addOptionTagDict(action_dom, data.object_action_list);\n
                         addOptionTagDict(action_dom, data.object_view_list);\n
+                        addOptionTagDict(action_dom, data.folder_action_list);\n
                      }\n
           });\n
     }\n
@@ -100,7 +101,7 @@ var ERP5UI = ( function () {\n
         </item>
         <item>
             <key> <string>size</string> </key>
-            <value> <int>2922</int> </value>
+            <value> <int>2993</int> </value>
         </item>
         <item>
             <key> <string>title</string> </key>
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/template_erp5_xhtml_style_disable.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/template_erp5_xhtml_style.xml
similarity index 96%
rename from bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/template_erp5_xhtml_style_disable.xml
rename to bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/template_erp5_xhtml_style.xml
index 9ea5042af1..9c0e31b7b2 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/template_erp5_xhtml_style_disable.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/template_erp5_xhtml_style.xml
@@ -47,6 +47,8 @@ IDEAS:\n
   </tal:block>\n
   <tal:block metal:define-macro="master">\n
     <tal:block tal:define="global_definitions_macros here/global_definitions/macros;\n
+                           portal here/getPortalObject;\n
+                           portal_url portal/absolute_url;\n
                            subject_list subject_list | python:here.getProperty(\'subject_list\', []) or []">\n
       <tal:block metal:use-macro="global_definitions_macros/header_definitions" />\n
       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n
@@ -117,7 +119,7 @@ IDEAS:\n
               <div id="bars" class="bars">\n
 \n
                 <div id="main_bar"\n
-                     data-gadget="ERP5Site_renderNavigationBox"></div>\n
+                     tal:attributes="data-gadget string:${portal_url}/ERP5Site_renderNavigationBox"></div>\n
 \n
                 <div id="context_bar" class="context_bar">\n
                   <tal:block metal:define-slot="context_bar" />\n
@@ -153,7 +155,7 @@ IDEAS:\n
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>template_erp5_xhtml_style_disable</string> </value>
+            <value> <string>template_erp5_xhtml_style</string> </value>
         </item>
         <item>
             <key> <string>output_encoding</string> </key>
diff --git a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/view_main_disable.xml b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/view_main.xml
similarity index 98%
rename from bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/view_main_disable.xml
rename to bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/view_main.xml
index 3138e10017..16c497bb0e 100644
--- a/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/view_main_disable.xml
+++ b/bt5/erp5_xhtml_gadget_style/SkinTemplateItem/portal_skins/erp5_xhtml_gadget_style/view_main.xml
@@ -81,7 +81,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>view_main_disable</string> </value>
+            <value> <string>view_main</string> </value>
         </item>
         <item>
             <key> <string>output_encoding</string> </key>
diff --git a/bt5/erp5_xhtml_gadget_style/bt/change_log b/bt5/erp5_xhtml_gadget_style/bt/change_log
index e18586ec00..e3b18775e9 100644
--- a/bt5/erp5_xhtml_gadget_style/bt/change_log
+++ b/bt5/erp5_xhtml_gadget_style/bt/change_log
@@ -1,2 +1,2 @@
 2012-03-02 Ivan
-* Initial worka
\ No newline at end of file
+* Initial work
\ No newline at end of file
diff --git a/bt5/erp5_xhtml_gadget_style/bt/description b/bt5/erp5_xhtml_gadget_style/bt/description
index dcbf48ebbd..f1f8d9e194 100644
--- a/bt5/erp5_xhtml_gadget_style/bt/description
+++ b/bt5/erp5_xhtml_gadget_style/bt/description
@@ -1,5 +1,2 @@
 Ajax-zation of ERP5 user interface.
-
-Note: To enable this bt5 after install remove "_disable" from ids of "form_view_disable" , "view_main_disable" and "template_erp5_xhtml_style"
-
 This is still considered a work in progress.
diff --git a/bt5/erp5_xhtml_gadget_style/bt/revision b/bt5/erp5_xhtml_gadget_style/bt/revision
index b393560759..cabf43b5dd 100644
--- a/bt5/erp5_xhtml_gadget_style/bt/revision
+++ b/bt5/erp5_xhtml_gadget_style/bt/revision
@@ -1 +1 @@
-23
\ No newline at end of file
+24
\ No newline at end of file
-- 
2.30.9