Commit 2bcf3dd6 authored by Ivan Tyagov's avatar Ivan Tyagov

Use HTTP caching rather than client side caching using renderjs.

Implement properly portal status message gadget to be a global one and support showing message from URL.
Implement properly DateTimeField.
parent c91af728
......@@ -89,19 +89,18 @@ for field_id in form.get_field_ids():\n
except:\n
field_dict[\'display_width\'] = None\n
\n
# XXX: DateTime not serialize-able (see Base_viewMetaData)?\n
# in what format to transfer to client renderjs.js ? (seconds since epoch?)\n
if field_meta_type in ["DateTimeField"]:\n
if field_value not in MARKER:\n
field_value = field_value.strftime("%Y/%m/%d")\n
field_dict[\'editable\'] = 0 # XXX: we have not implemented it yet at client side\n
field_value = field_value.millis()\n
field_dict[\'format\'] = context.portal_preferences.getPreferredDateOrder(\'ymd\')\n
\n
# listbox\n
if field_meta_type in ["ListBox"]:\n
field_dict[\'listbox\'] = {}\n
field_dict[\'listbox\'][\'lines\'] = original_field.get_value("lines")\n
field_dict[\'listbox\'][\'columns\'] = [x for x in original_field.get_value("columns")]\n
field_dict[\'listbox\'][\'listbox_data_url\'] = "Listbox_asJSON"\n
# disabled as now we pass entire listbox html\n
#field_dict[\'listbox\'][\'lines\'] = original_field.get_value("lines")\n
#field_dict[\'listbox\'][\'columns\'] = [x for x in original_field.get_value("columns")]\n
#field_dict[\'listbox\'][\'listbox_data_url\'] = "Listbox_asJSON"\n
field_dict[\'listbox\'][\'listbox_html\'] = original_field.render()\n
\n
if field_meta_type in LIST_FIELDS:\n
......@@ -116,11 +115,10 @@ for field_id in form.get_field_ids():\n
for formbox_field_id in formbox_form.get_field_ids():\n
formbox_field_id_field = getattr(formbox_form, formbox_field_id)\n
field_value = formbox_field_id_field.get_value("default") # only last wins ?\n
\n
\n
# add field value\n
field_dict[\'value\'] = field_value\n
\n
\n
return dumps(result)\n
</string> </value>
</item>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -37,7 +41,9 @@
<value> <unicode encoding="cdata"><![CDATA[
<tal:block tal:define="group_list here/Form_getGroupTitleAndId;\n
form_id here/getId;">\n
form_id here/getId;\n
portal here/getPortalObject;\n
portal_url portal/absolute_url">\n
\n
<tal:block tal:repeat="group group_list">\n
\n
......@@ -58,10 +64,8 @@
<div class="input">\n
\n
<!-- render gadget asynchronously -->\n
<div data-gadget-cacheable="1"\n
tal:attributes="data-gadget string:gadgets/form/${field_type}/gadget?field_name=${field_name}&form_id=${form_id};\n
id string:${form_id}_${field_name};\n
data-gadget-cache-id string:${form_id}_${field_name};"></div>\n
<div tal:attributes="data-gadget string:${portal_url}/gadgets/form/${field_type}/gadget?field_name=${field_name}&form_id=${form_id};\n
id string:${form_id}_${field_name};"></div>\n
\n
</div>\n
</div>\n
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -36,12 +40,19 @@
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block tal:define="field_name request/field_name | options/field_name">\n
<textarea\n
tal:attributes="name field_name"/>\n
<tal:block tal:define="field_name request/field_name | options/field_name;\n
field_name_stipped python: field_name.replace(\'field_\', \'\');\n
form_id request/form_id | options/form_id;">\n
\n
<textarea tal:attributes="name field_name"/>\n
\n
<input type="image"\n
name="portal_selections/viewSearchRelatedDocumentDialog0:method"\n
value="update..." src="images/exec16.png">\n
\n
<a tal:attributes="href string:Base_jumpToRelatedDocument?field_id=${field_name_stipped}&amp;form_id=${form_id}">\n
<img alt="jump" src="images/jump.png">\n
</a>\n
\n
</tal:block>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -36,7 +40,7 @@
<key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[
<tal:block tal:define="field_name request/field_name | options/field_name">\n
<tal:block tal:define="field_name request/field_name | options/field_name;">\n
<input type="text"\n
tal:attributes="name field_name"/>\n
</tal:block>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......
......@@ -6,6 +6,10 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -38,12 +42,20 @@
\074head\076\n
\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
\n
\074script type="text/javascript" language="javascript"\076\n
//\074![CDATA[\n
$(document).ready(function() {\n
var portal_status_message,\n
gadget = RenderJs.getSelfGadget();\n
\n
function getURLParameter(name) {\n
return decodeURI(\n
(RegExp(name + \'=\' + \'(.+?)(\046|$)\').exec(location.search)||[,null])[1]\n
);\n
};\n
\n
gadget.showMessage = function (message, timeout) {\n
// show message in UI\n
......@@ -55,6 +67,13 @@
msg_element.html(message);\n
window.setTimeout(\'$("#portal_status_message p").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
}\n
});\n
//]]\076\n
\074/script\076\n
......
......@@ -37,7 +37,8 @@
<value> <unicode encoding="cdata"><![CDATA[
<!-- Content -->\n
<div class="master" id="master"\n
<div class="master"\n
id="master"\n
tal:define="portal here/portal_url/getPortalObject;\n
portal_path portal_path | portal/absolute_url;\n
action_context python: portal.restrictedTraverse(request.get(\'object_path\', \'?\'), here);\n
......@@ -51,14 +52,6 @@
data_gadget_property python: {\'tab_container_id\': \'form_gadget\',\n
\'default_tab_url\': action_id_list[0],\n
\'action_id_list\': action_id_list}">\n
\n
\n
<div data-gadget="gadgets/portal_status_message/gadget"\n
data-gadget-cache-id="portal_status_message"\n
data-gadget-cacheable="1"\n
id="portal_status_message"></div>\n
\n
\n
<div class="document">\n
\n
<div class="actions">\n
......@@ -68,7 +61,6 @@
<span class="description">Save</span>\n
</button>\n
\n
<!-- Test -->\n
<div data-gadget="erp5_tabbular_form_renderer"\n
id="erp5_tabbular_form_renderer"\n
tal:attributes="data-gadget-property python: here.Base_asJSON(data_gadget_property);"> </div>\n
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts63100043.51</string> </value>
<value> <string>ts63188257.39</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -167,11 +167,16 @@ var ERP5Form = ( function () {\n
\n
DateTimeField: function (field_id, field_dict) {\n
/* DateTimeField field */\n
var date, dom;\n
var date, dom, date_format;\n
dom = $("[name=" + this.getFieldId(field_id) + "]");\n
date = field_dict.value;\n
date_format = field_dict[\'format\'];\n
if (date_format==="dmy") {\n
// XXX: support more formats\n
date_format = \'dd/mm/yy\';\n
}\n
date = new Date(date);\n
dom.datepicker({ dateFormat: \'dd/mm/yy\' }); // XXX: get format from server!\n
dom.datepicker({ dateFormat: date_format});\n
dom.datepicker(\'setDate\', date);\n
return dom;\n
},\n
......@@ -187,7 +192,8 @@ var ERP5Form = ( function () {\n
},\n
\n
FormBox: function (field_id, field_dict) {\n
/* Email field */\n
/* FormBox field */\n
// XXX: implement it to read all values and render properly\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
......@@ -195,6 +201,12 @@ var ERP5Form = ( function () {\n
/* Relation field */\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
MultiRelationStringField: function (field_id, field_dict) {\n
/* MultiRelationStringField field */\n
// XXX: support multiple values\n
return this.BaseInputField(field_id, field_dict);\n
},\n
\n
ImageField: function (field_id, field_dict) {\n
/* Image field */\n
......@@ -289,22 +301,29 @@ var ERP5Form = ( function () {\n
type = element.attr("type"),\n
element_class = element.attr("class");\n
\n
if (type==="checkbox") {\n
if (type === "checkbox") {\n
value = element.is(":checked");\n
if (value===true) {\n
if (value === true) {\n
converted_value=1;\n
}\n
if(value===false) {\n
if (value === false) {\n
converted_value=0;\n
}\n
value = converted_value;\n
}\n
// XXX: save DateTimeField values\n
\n
if (element_class.indexOf("hasDatepicker") !== -1) {\n
console.log(name, element_class, value);\n
// backend codes expects that date object is represented by\n
// three separate request parameters so created them here.\n
// XXX: we assume format is dd/mm/YYYY so read it from DateTimeGadget for this field\n
// which means we now must be able get hold of gadget and read it from there where\n
// fist it should be initialized!)\n
form_value_dict["subfield_" + name + "_year"] = value.substr(6,4);\n
form_value_dict["subfield_" + name + "_month"] = value.substr(3,2);\n
form_value_dict["subfield_" + name + "_day"] = value.substr(0,2);\n
}\n
\n
// XXX: how to handle file uploads ?\n
\n
// some values end with :list and we need to collect them all\n
if (/:list$/.test(name)) {\n
if (form_value_dict[name] === undefined) {\n
......@@ -339,7 +358,6 @@ var ERP5Form = ( function () {\n
$.each(field_errors, function(index, value){\n
var dom, field;\n
dom = $("[name=" + ERP5Form.getFieldId(index) + "]");\n
//dom.css("border", "1px solid red"); // XXX: use class / css\n
dom.addClass("validation-failed");\n
field = dom.parent().parent();\n
if (field.children("span.error").length > 0){\n
......@@ -419,7 +437,7 @@ var ERP5Form = ( function () {\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>18852</int> </value>
<value> <int>19948</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -51,22 +51,10 @@
\n
<p class="clear"></p>\n
\n
<tal:block tal:condition="preferred_html_style_acknowledgeable_message | nothing">\n
<div id="acknowledgeable_message_render" class="acknowledgeable_message_render">\n
<div tal:content="structure here/acknowledgeable_message_render"/>\n
</div>\n
</tal:block>\n
<div data-gadget="gadgets/portal_status_message/gadget"\n
id="portal_status_message"></div>\n
\n
<!-- XXX add portal_status_message gadget -->\n
<div tal:content="request/portal_status_message | nothing" id="transition_message"\n
class="transition_message"/>\n
\n
<tal:block tal:condition="request/field_errors | nothing">\n
<div id="information_area" class="information_area" i18n:translate="" i18n:domain="ui">\n
Input data has errors. Please look at the error messages below.\n
</div>\n
<script type="text/javascript">changed = true;</script>\n
</tal:block>\n
</div>
]]></unicode> </value>
......
18
\ No newline at end of file
19
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment