Commit c741f04f authored by Ivan Tyagov's avatar Ivan Tyagov

Add generic portal_status_message gadget.

Return listbox's as rendered at server side (until we can render it client side with all features).
When tab changes preserve URL arguments in browser location bar and change only hash part.
Make basics of RelationStringField.
Improve rendering of ERP5 form's left and right fieldsets.
parent 89e086cf
...@@ -90,7 +90,7 @@ for field_id in form.get_field_ids():\n ...@@ -90,7 +90,7 @@ for field_id in form.get_field_ids():\n
field_dict[\'display_width\'] = None\n field_dict[\'display_width\'] = None\n
\n \n
# XXX: DateTime not serialize-able (see Base_viewMetaData)?\n # XXX: DateTime not serialize-able (see Base_viewMetaData)?\n
# in what format to transfer to client renderjs.js ? (seconds sinc eepoch?)\n # in what format to transfer to client renderjs.js ? (seconds since epoch?)\n
if field_meta_type in ["DateTimeField"]:\n if field_meta_type in ["DateTimeField"]:\n
if field_value not in MARKER:\n if field_value not in MARKER:\n
field_value = field_value.strftime("%Y/%m/%d")\n field_value = field_value.strftime("%Y/%m/%d")\n
...@@ -102,6 +102,7 @@ for field_id in form.get_field_ids():\n ...@@ -102,6 +102,7 @@ for field_id in form.get_field_ids():\n
field_dict[\'listbox\'][\'lines\'] = original_field.get_value("lines")\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\'][\'columns\'] = [x for x in original_field.get_value("columns")]\n
field_dict[\'listbox\'][\'listbox_data_url\'] = "Listbox_asJSON"\n field_dict[\'listbox\'][\'listbox_data_url\'] = "Listbox_asJSON"\n
field_dict[\'listbox\'][\'listbox_html\'] = original_field.render()\n
\n \n
if field_meta_type in LIST_FIELDS:\n if field_meta_type in LIST_FIELDS:\n
# form contains selects, pass list of selects\' values and calculate default one?\n # form contains selects, pass list of selects\' values and calculate default one?\n
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
\n \n
<!-- render gadget asynchronously -->\n <!-- render gadget asynchronously -->\n
<div data-gadget-cacheable="1"\n <div data-gadget-cacheable="1"\n
tal:attributes="data-gadget string:gadgets/form/${field_type}/gadget?field_name=${field_name};\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 id string:${form_id}_${field_name};\n
data-gadget-cache-id string:${form_id}_${field_name};"></div>\n data-gadget-cache-id string:${form_id}_${field_name};"></div>\n
\n \n
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts62667459.18</string> </value> <value> <string>ts63093392.7</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
</item> </item>
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <string>.required-field label{\n <value> <string>.document .content{\n
min-height:100px;\n
}\n
.required-field label{\n
font-weight: bold;\n font-weight: bold;\n
}\n }\n
\n \n
...@@ -35,8 +38,32 @@ ...@@ -35,8 +38,32 @@
}\n }\n
\n \n
.center_right {\n .center_right {\n
float:right;\n float: left;\n
width: 49%;\n margin-left: 0.5%;\n
width: 47.5%;\n
}\n
\n
fieldset.left {\n
margin-right:0px;\n
}\n
\n
fieldset.right {\n
width:47.5%;\n
margin-left:0.5%;\n
}\n
.center_left,\n
.center_right{\n
border: 1px solid #97B0D1;\n
padding-left: 5px;\n
padding-right: 5px;\n
padding-top: 5px;\n
margin-bottom: 5px;\n
}\n
\n
//portal_status_gadget CSS\n
#portal_status_message p {\n
display:none;\n
color:red;\n
}</string> </value> }</string> </value>
</item> </item>
<item> <item>
...@@ -45,7 +72,7 @@ ...@@ -45,7 +72,7 @@
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>189</int> </value> <value> <int>587</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
<value> <unicode encoding="cdata"><![CDATA[ <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
<table tal:attributes="id field_name">\n <div tal:attributes="id field_name">\n
<!-- Listbox content -->\n <!-- Listbox content -->\n
</table>\n </div>\n
<div tal:attributes="id string:${field_name}_pager">\n <div tal:attributes="id string:${field_name}_pager">\n
<!-- Listbox navigation -->\n <!-- Listbox navigation -->\n
</div>\n </div>\n
......
...@@ -36,12 +36,19 @@ ...@@ -36,12 +36,19 @@
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <unicode encoding="cdata"><![CDATA[ <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
field_name_stipped python: field_name.replace(\'field_\', \'\');\n
form_id request/form_id | options/form_id;">\n
\n \n
<input type="text"\n <input type="text"\n
tal:attributes="name field_name"/>\n tal:attributes="name field_name"/>\n
<input type="image" name="portal_selections/viewSearchRelatedDocumentDialog0:method"\n <input type="image" name="portal_selections/viewSearchRelatedDocumentDialog0:method"\n
value="update..." src="images/exec16.png">\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> </tal:block>
]]></unicode> </value> ]]></unicode> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>portal_status_message</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <unicode>\074html\076\n
\074head\076\n
\074/head\076\n
\074body\076\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
gadget = RenderJs.getSelfGadget();\n
\n
gadget.showMessage = function (message, timeout) {\n
// show message in UI\n
var msg_element = $("#portal_status_message p");\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
};\n
});\n
//]]\076\n
\074/script\076\n
\074/body\076\n
\074/html\076</unicode> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>iso-8859-15</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -53,10 +53,11 @@ ...@@ -53,10 +53,11 @@
\'action_id_list\': action_id_list}">\n \'action_id_list\': action_id_list}">\n
\n \n
\n \n
<!-- XXX: use portal_status_message gadget -->\n <div data-gadget="gadgets/portal_status_message/gadget"\n
<div id="portal_status_message" style="height:20px; display:none;">\n data-gadget-cache-id="portal_status_message"\n
<p style="color:red; font-weight: bold;"></p>\n data-gadget-cacheable="1"\n
</div>\n id="portal_status_message"></div>\n
\n
\n \n
<div class="document">\n <div class="document">\n
\n \n
...@@ -79,7 +80,7 @@ ...@@ -79,7 +80,7 @@
tal:define="action_form python: action[\'url\'].split(\'/\')[-1]"\n tal:define="action_form python: action[\'url\'].split(\'/\')[-1]"\n
tal:attributes="id action_form;\n tal:attributes="id action_form;\n
class python: action == current_action and \'selected\' or \'not_selected\'">\n class python: action == current_action and \'selected\' or \'not_selected\'">\n
<a tal:attributes="href python: \'view#/%s/\' %action_form">\n <a tal:attributes="onclick python: \'\'\'javascript: return ERP5Form.onTabClickHandler(\'%s\')\'\'\' %action_form">\n
<span i18n:translate=""\n <span i18n:translate=""\n
i18n:domain="ui"\n i18n:domain="ui"\n
tal:content="action/name">action_name</span>\n tal:content="action/name">action_name</span>\n
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts62582297.01</string> </value> <value> <string>ts63100043.51</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -215,38 +215,41 @@ var ERP5Form = ( function () {\n ...@@ -215,38 +215,41 @@ var ERP5Form = ( function () {\n
\n \n
listbox_dict = field_dict.listbox;\n listbox_dict = field_dict.listbox;\n
listbox_data_url = listbox_dict.listbox_data_url;\n listbox_data_url = listbox_dict.listbox_data_url;\n
colModel = [];\n $("#" + listbox_id).html(listbox_dict["listbox_html"]);\n
column_title_list = [];\n return;\n
$.each(listbox_dict.columns,\n // Uncomment below to use jqgrid plugin to render listbox\n
function(i, value){\n // colModel = [];\n
var index, title, column;\n // column_title_list = [];\n
index = value[0];\n // $.each(listbox_dict.columns,\n
title = value[1];\n // function(i, value){\n
column_title_list.push(title);\n // var index, title, column;\n
column = {\'name\': index,\n // index = value[0];\n
\'index\': index,\n // title = value[1];\n
\'width\': 185,\n // column_title_list.push(title);\n
\'align\': \'left\'};\n // column = {\'name\': index,\n
colModel.push(column);\n // \'index\': index,\n
});\n // \'width\': 185,\n
\n // \'align\': \'left\'};\n
listbox_table.jqGrid({url:listbox_data_url + \'?form_id=\' + current_form_id + \'&amps;listbox_id=\' + field_id,\n // colModel.push(column);\n
datatype: "json",\n // });\n
colNames: column_title_list,\n // \n
colModel: colModel,\n // listbox_table.jqGrid({url:listbox_data_url + \'?form_id=\' + current_form_id + \'&amps;listbox_id=\' + field_id,\n
rowNum: listbox_dict.lines,\n // datatype: "json",\n
pager: \'#\'+navigation_id,\n // colNames: column_title_list,\n
sortname: \'id\',\n // colModel: colModel,\n
viewrecords: true,\n // rowNum: listbox_dict.lines,\n
sortorder: "desc",\n // pager: \'#\'+navigation_id,\n
loadError : function(xhr, textStatus, errorThrown) {\n // sortname: \'id\',\n
// XXX: handle better than just alert.\n // viewrecords: true,\n
alert("Error occurred during getting data from server.");\n // sortorder: "desc",\n
},\n // loadError : function(xhr, textStatus, errorThrown) {\n
cmTemplate: {sortable:false}, // XXX: until we get list of sortable columns from server\n // // XXX: handle better than just alert.\n
caption: field_dict.title});\n // alert("Error occurred during getting data from server.");\n
listbox_table.jqGrid(\'navGrid\', \'#\'+navigation_id, {edit:false,add:false,del:false});\n // },\n
return listbox_table;\n // cmTemplate: {sortable:false}, // XXX: until we get list of sortable columns from server\n
// caption: field_dict.title});\n
// listbox_table.jqGrid(\'navGrid\', \'#\'+navigation_id, {edit:false,add:false,del:false});\n
// return listbox_table;\n
},\n },\n
\n \n
update: function(data) {\n update: function(data) {\n
...@@ -353,7 +356,6 @@ var ERP5Form = ( function () {\n ...@@ -353,7 +356,6 @@ var ERP5Form = ( function () {\n
// delete validation messages\n // delete validation messages\n
var element;\n var element;\n
element = $(this);\n element = $(this);\n
//element.parent().children("div.input").children("." +ERP5Form.SERIALIZE_ABLE_CLASS_NAME).css("border", "none");\n
element.remove();\n element.remove();\n
// XXX: remove all rendered in red input classes\n // XXX: remove all rendered in red input classes\n
$(".validation-failed").each(function () {\n $(".validation-failed").each(function () {\n
...@@ -361,12 +363,20 @@ var ERP5Form = ( function () {\n ...@@ -361,12 +363,20 @@ var ERP5Form = ( function () {\n
});\n });\n
});\n });\n
// show a fading portal_status_message\n // show a fading portal_status_message\n
$("#portal_status_message").toggle();\n RenderJs.GadgetIndex.getGadgetById(\'portal_status_message\').showMessage("Saved", 1000);\n
$("#portal_status_message p").html("Saved");\n
window.setTimeout(\'$("#portal_status_message").toggle();\', 4000);\n
}\n }\n
}});\n }});\n
},\n },\n
\n
onTabClickHandler: function (form_id) {\n
/*\n
* When a tab gets clicked change url (part after \'#\') so router can detect\n
change and load proper gadget.\n
This function preserves all URL arguments.\n
*/\n
window.location = window.location.toString().split(\'#\')[0] + \'#/\'+form_id + \'/\';\n
return false;\n
},\n
\n \n
openFormInTabbularGadget: function (container_id, form_id) {\n openFormInTabbularGadget: function (container_id, form_id) {\n
/*\n /*\n
...@@ -382,6 +392,19 @@ var ERP5Form = ( function () {\n ...@@ -382,6 +392,19 @@ var ERP5Form = ( function () {\n
\'Form_asJSON?form_id=\' + form_id);;\n \'Form_asJSON?form_id=\' + form_id);;\n
RenderJs.TabbularGadget.toggleVisibility($(\'#\' + form_id));\n RenderJs.TabbularGadget.toggleVisibility($(\'#\' + form_id));\n
ERP5Form.setCurrentFormId(form_id);\n ERP5Form.setCurrentFormId(form_id);\n
// when all gadgets are loaded adjust left and right side of forms to have same height\n
RenderJs.bindReady(function () {\n
setTimeout(function() {\n
var left_height = $(\'fieldset.left\').height(),\n
right_height = $(\'fieldset.right\').height();\n
if (right_height <= left_height) {\n
$(\'fieldset.right\').height(left_height);\n
}\n
else {\n
$(\'fieldset.left\').height(right_height);\n
}\n
}, 500);\n
});\n
}\n }\n
}\n }\n
\n \n
...@@ -396,7 +419,7 @@ var ERP5Form = ( function () {\n ...@@ -396,7 +419,7 @@ var ERP5Form = ( function () {\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>17871</int> </value> <value> <int>18852</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
2012-03-02 Ivan 2012-03-02 Ivan
* Initial work * Initial worka
\ No newline at end of file \ No newline at end of file
17 18
\ No newline at end of file \ 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