diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_createNewEmailThread.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_createNewEmailThread.xml index aed3d96abfa21f3698d65b3ba5b1bd263feab47a..22a3f89e56a1ec55ae8bc0059fd2e0e7c3d9c9bf 100644 --- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_createNewEmailThread.xml +++ b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_createNewEmailThread.xml @@ -61,7 +61,12 @@ if person and person.getEmail():\n sender_email = person.getEmailText()\n \n email_thread_module = context.email_thread_module\n -email = email_thread_module.newContent(portal_type="Email Thread")\n +event_id = form.get("event_id")\n +if event_id:\n + email = context.portal_catalog.getResultValue(portal_type="Email Thread", id=event_id)\n +else:\n + email = email_thread_module.newContent(portal_type="Email Thread")\n +\n email.setStartDate(DateTime())\n email.setSender(sender_email)\n email.setRecipient(form.get("to"))\n @@ -71,6 +76,8 @@ email.setTitle(form.get("subject"))\n email.setTextContent(form.get("text-content"))\n if form.get("action") == "send-mail":\n context.portal_workflow.doActionFor(email, \'post_action\')\n +\n +return email.getId()\n </string> </value> </item> <item> diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_loadEmailThreadData.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_loadEmailThreadData.xml new file mode 100644 index 0000000000000000000000000000000000000000..e8a50d379adca0a68205e9f62113aa49f2eeb2c4 --- /dev/null +++ b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ERP5Site_loadEmailThreadData.xml @@ -0,0 +1,95 @@ +<?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>from Products.ERP5Type.JSONEncoder import encodeInJson as dumps\n +\n +portal = context.getPortalObject()\n +form = context.REQUEST.form\n +\n +data_dict = {}\n +\n +email_thread_uid = form.get("email_thread_uid")\n +\n +email = portal.portal_catalog.getResultValue(portal_type="Email Thread",\n + uid=email_thread_uid)\n +\n +data_dict["subject"] = email.getTitle()\n +data_dict["to"] = email.getRecipient()\n +data_dict["cc"] = email.getCcRecipient()\n +data_dict["bcc"] = email.getBccRecipient()\n +data_dict["text_content"] = email.getTextContent()\n +data_dict["state"] = email.getValidationState()\n +data_dict["id"] = email.getId()\n +\n +return dumps(data_dict)\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>_proxy_roles</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>ERP5Site_loadEmailThreadData</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_css/ung_theme.css.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_css/ung_theme.css.xml index 324a2bd723fad9532fc7c9a8d72265b0c1ce9257..c609099fbd59b632f3f43e5343c2ffa83de3b035 100644 --- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_css/ung_theme.css.xml +++ b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_css/ung_theme.css.xml @@ -216,7 +216,6 @@ div.main-right div.main-status a {\n }\n \n .listbox th {\n - border-left: 1px solid #bbccff;\n border-right: 1px solid #bbccff;\n }\n \n diff --git a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung_mail.js.xml b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung_mail.js.xml index 2c04b05bdbf444c820346432866439f3daf299ea..4fde1e6b402dee3b38245be74058c666f0fbb4a7 100644 --- a/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung_mail.js.xml +++ b/bt5/erp5_web_ung_theme/SkinTemplateItem/portal_skins/erp5_web_ung_theme/ung_js/ung_mail.js.xml @@ -28,24 +28,46 @@ </item> <item> <key> <string>raw</string> </key> - <value> <string>function saveEmailThread(event){\n + <value> <string>function loadEmailFormActions(){\n + $("button#discard-mail").click(function(){\n + window.location.reload();\n + });\n + $("span#add-cc-field").click(function(){\n + $(this).hide();\n + $("tr#cc").show();\n + });\n + $("span#add-bcc-field").click(function(){\n + $(this).hide();\n + $("tr#bcc").show();\n + });\n +}\n +\n +function saveEmailThread(event){\n event.preventDefault();\n var formData = new Array();\n $("div.compose-mail-page textarea, div.compose-mail-page input").each(function(){\n formData.push({name: $(this).attr("id"), value: $(this).attr("value")});\n });\n formData.push({name: "action", value: event.currentTarget.id});\n + var divMail = $("div.compose-mail-page");\n + var eventId = divMail.data("event_uid") != undefined ? divMail.data("event_uid") : "";\n + formData.push({name: "event_id", value: eventId});\n $.ajax({\n type: "post",\n url: "ERP5Site_createNewEmailThread",\n data: formData,\n mediaType: "json",\n + success: function(data){\n + if (event.currentTarget.id == "send-mail"){\n + $("div.compose-mail-page").removeDate("event_id");\n + var baseUrl = window.location.href.split("?")[0];\n + window.location.href = baseUrl + "?reset:int=1";\n + }\n + if (event.currentTarget.id == "save-mail"){\n + $("div.compose-mail-page").data("event_uid", data);\n + }\n + }\n });\n - if (event.currentTarget.id == "send-mail"){\n - var baseUrl = window.location.href.split("?")[0];\n - window.location.href = baseUrl + "?reset:int=1";\n - }\n - \n }\n \n $().ready(function(){\n @@ -55,19 +77,8 @@ $().ready(function(){\n $("div.main-right fieldset.widget").hide();\n $("div.main-right").css("background-color", "#BBCCFF");\n $("div.main-right").load("EmailThread_formView", {}, function(){\n - $("button#discard-mail").click(function(){\n - window.location.reload();\n - });\n - $("span#add-cc-field").click(function(){\n - $(this).hide();\n - $("tr#cc").show();\n - });\n - $("span#add-bcc-field").click(function(){\n - $(this).hide();\n - $("tr#bcc").show();\n - });\n - $("button#save-mail, button#send-mail").click(saveEmailThread);\n - \n + loadEmailFormActions();\n + $("button#save-mail, button#send-mail").click(saveEmailThread); \n });\n });\n $("img[alt=\'mail_logo_box\']").click(function(){\n @@ -81,6 +92,38 @@ $().ready(function(){\n $("input[name=\'searchable-text\']").keypress(function(event){\n (event.which == 13) ? $("input#submit-search").click() : null;\n });\n + $("div.listbox-body table.listbox td.listbox-table-data-cell a").click(function(event){\n + event.preventDefault();\n + var emailThreadUId = $(this).parent().parent().find("input").attr("value");\n + var emailUid = [{name: "email_thread_uid", value: emailThreadUId}];\n + $.ajax({\n + type: "post",\n + url: "ERP5Site_loadEmailThreadData",\n + data: emailUid,\n + mediaType: "json",\n + success: function(data){\n + var data = jQuery.parseJSON(data);\n + $("div.main-right fieldset.widget").hide();\n + $("div.main-right").css("background-color", "#BBCCFF");\n + $("div.main-right").load("EmailThread_formView", {}, function(){\n + if (data.state != "draft"){\n + $("button#discard-mail").hide();\n + }\n + $("button#save-mail, button#send-mail").click(saveEmailThread);\n + $(this).ready(function(){\n + (data.cc != null) ? $("textarea#cc").attr("value", data.cc) : null;\n + (data.bcc != null) ? $("textarea#bcc").attr("value", data.bcc) : null;\n + (data.to != null) ? $("textarea#to").attr("value", data.to) : null;\n + (data.text_content != null) ? $("textarea#text-content").attr("value", data.text_content) : null;\n + (data.subject != null) ? $("input#subject").attr("value", data.subject) : null;\n + (data.id != null) ? $("div.compose-mail-page").data("event_id", data.id) : null;\n + loadEmailFormActions();\n + });\n + });\n + }\n + });\n + $("div.compose-mail-page").data("event_uid", emailThreadUId);\n + });\n });</string> </value> </item> <item> diff --git a/bt5/erp5_web_ung_theme/bt/change_log b/bt5/erp5_web_ung_theme/bt/change_log index 8814682a47c6a6cc709062df1795fe2758557bf5..b48e7a3f9a2398ae7e922b235acfdac8f08d0bc2 100644 --- a/bt5/erp5_web_ung_theme/bt/change_log +++ b/bt5/erp5_web_ung_theme/bt/change_log @@ -1,3 +1,7 @@ +2011-02-10 gabriel +* Add script ERP5Site_loadEmailThreadData to load the data of selected email. This script is used to open one email in the current page. +* Refactor ERP5Site_createNewEmailThread to do not create a new email if it already exist one Email Thread created. + 2011-02-09 gabriel * Add logo to UNG Mail * Add Form to compose a new email diff --git a/bt5/erp5_web_ung_theme/bt/revision b/bt5/erp5_web_ung_theme/bt/revision index 030d25b2869afffec1b755ad29fb9a35ad53a952..cb16690c5e43d5c3869eeb02969fbc7d01cf4bb2 100644 --- a/bt5/erp5_web_ung_theme/bt/revision +++ b/bt5/erp5_web_ung_theme/bt/revision @@ -1 +1 @@ -248 \ No newline at end of file +249 \ No newline at end of file