From 9973113dd727f3ea6f9ebad636c9280b1780ae89 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 9 Apr 2014 17:58:55 +0200
Subject: [PATCH] CRM: add a preview button to response dialog

---
 .../erp5_crm/Event_updateCreateResponse.xml   | 93 +++++++++++++++++++
 .../Event_viewCreateResponseDialog.xml        |  2 +-
 bt5/erp5_crm/bt/revision                      |  2 +-
 3 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_updateCreateResponse.xml

diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_updateCreateResponse.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_updateCreateResponse.xml
new file mode 100644
index 0000000000..0bd67ef356
--- /dev/null
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_updateCreateResponse.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>Script_magic</string> </key>
+            <value> <int>3</int> </value>
+        </item>
+        <item>
+            <key> <string>_bind_names</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+                </klass>
+                <tuple/>
+                <state>
+                  <dictionary>
+                    <item>
+                        <key> <string>_asgns</string> </key>
+                        <value>
+                          <dictionary>
+                            <item>
+                                <key> <string>name_container</string> </key>
+                                <value> <string>container</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_context</string> </key>
+                                <value> <string>context</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_m_self</string> </key>
+                                <value> <string>script</string> </value>
+                            </item>
+                            <item>
+                                <key> <string>name_subpath</string> </key>
+                                <value> <string>traverse_subpath</string> </value>
+                            </item>
+                          </dictionary>
+                        </value>
+                    </item>
+                  </dictionary>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>_body</string> </key>
+            <value> <string>"""Preview the response from notification message for event create response dialog.\n
+"""\n
+if response_event_notification_message:\n
+  temp_event = context.getPortalObject().event_module.newContent(\n
+    portal_type=response_event_portal_type,\n
+    source=default_destination or context.getDestination(),\n
+    destination=context.getSource(),\n
+    causality_value=context,\n
+    follow_up_list=context.getFollowUpList(),\n
+    resource=response_event_resource,\n
+    language=context.getLanguage(),\n
+    content_type=response_event_content_type or context.getContentType())\n
+\n
+  temp_event.Event_setTextContentFromNotificationMessage(\n
+     reference=response_event_notification_message,\n
+     substitution_method_parameter_dict=dict(reply_body=context.getReplyBody(),\n
+                                             reply_subject=context.getReplySubject()))\n
+                                             \n
+  # XXX this relies on formulator internals, we force the variables in request and\n
+  # re-render the form.\n
+  request = container.REQUEST\n
+  request.set(\'your_response_event_notification_message\', \'\')\n
+  request.set(\'your_response_event_title\', temp_event.getTitle())\n
+  request.set(\'your_response_event_text_content\', temp_event.getTextContent())\n
+  request.set(\'your_response_event_resource\', temp_event.getResource())\n
+  \n
+return context.Event_viewCreateResponseDialog()\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>response_event_portal_type, response_event_notification_message, response_event_resource, response_event_text_content, response_event_content_type, default_destination, **kw</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Event_updateCreateResponse</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewCreateResponseDialog.xml b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewCreateResponseDialog.xml
index ef01e6aa3a..fc94d39c82 100644
--- a/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewCreateResponseDialog.xml
+++ b/bt5/erp5_crm/SkinTemplateItem/portal_skins/erp5_crm/Event_viewCreateResponseDialog.xml
@@ -137,7 +137,7 @@
         </item>
         <item>
             <key> <string>update_action</string> </key>
-            <value> <string></string> </value>
+            <value> <string>Event_updateCreateResponse</string> </value>
         </item>
         <item>
             <key> <string>update_action_title</string> </key>
diff --git a/bt5/erp5_crm/bt/revision b/bt5/erp5_crm/bt/revision
index 0e46c90894..b775c5e152 100644
--- a/bt5/erp5_crm/bt/revision
+++ b/bt5/erp5_crm/bt/revision
@@ -1 +1 @@
-698
\ No newline at end of file
+699
\ No newline at end of file
-- 
2.30.9