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
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 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_value not in MARKER:\n
field_value = field_value.strftime("%Y/%m/%d")\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\'][\'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
# form contains selects, pass list of selects\' values and calculate default one?\n
......
......@@ -59,7 +59,7 @@
\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};\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
\n
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts62667459.18</string> </value>
<value> <string>ts63093392.7</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -20,7 +20,10 @@
</item>
<item>
<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
}\n
\n
......@@ -35,8 +38,32 @@
}\n
\n
.center_right {\n
float:right;\n
width: 49%;\n
float: left;\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>
</item>
<item>
......@@ -45,7 +72,7 @@
</item>
<item>
<key> <string>size</string> </key>
<value> <int>189</int> </value>
<value> <int>587</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -37,9 +37,9 @@
<value> <unicode encoding="cdata"><![CDATA[
<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
</table>\n
</div>\n
<div tal:attributes="id string:${field_name}_pager">\n
<!-- Listbox navigation -->\n
</div>\n
......
......@@ -36,12 +36,19 @@
<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
field_name_stipped python: field_name.replace(\'field_\', \'\');\n
form_id request/form_id | options/form_id;">\n
\n
<input type="text"\n
tal:attributes="name field_name"/>\n
<input type="image" 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>
]]></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 @@
\'action_id_list\': action_id_list}">\n
\n
\n
<!-- XXX: use portal_status_message gadget -->\n
<div id="portal_status_message" style="height:20px; display:none;">\n
<p style="color:red; font-weight: bold;"></p>\n
</div>\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
......@@ -79,7 +80,7 @@
tal:define="action_form python: action[\'url\'].split(\'/\')[-1]"\n
tal:attributes="id action_form;\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
i18n:domain="ui"\n
tal:content="action/name">action_name</span>\n
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts62582297.01</string> </value>
<value> <string>ts63100043.51</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -215,38 +215,41 @@ var ERP5Form = ( function () {\n
\n
listbox_dict = field_dict.listbox;\n
listbox_data_url = listbox_dict.listbox_data_url;\n
colModel = [];\n
column_title_list = [];\n
$.each(listbox_dict.columns,\n
function(i, value){\n
var index, title, column;\n
index = value[0];\n
title = value[1];\n
column_title_list.push(title);\n
column = {\'name\': index,\n
\'index\': index,\n
\'width\': 185,\n
\'align\': \'left\'};\n
colModel.push(column);\n
});\n
\n
listbox_table.jqGrid({url:listbox_data_url + \'?form_id=\' + current_form_id + \'&amps;listbox_id=\' + field_id,\n
datatype: "json",\n
colNames: column_title_list,\n
colModel: colModel,\n
rowNum: listbox_dict.lines,\n
pager: \'#\'+navigation_id,\n
sortname: \'id\',\n
viewrecords: true,\n
sortorder: "desc",\n
loadError : function(xhr, textStatus, errorThrown) {\n
// XXX: handle better than just alert.\n
alert("Error occurred during getting data from server.");\n
},\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
$("#" + listbox_id).html(listbox_dict["listbox_html"]);\n
return;\n
// Uncomment below to use jqgrid plugin to render listbox\n
// colModel = [];\n
// column_title_list = [];\n
// $.each(listbox_dict.columns,\n
// function(i, value){\n
// var index, title, column;\n
// index = value[0];\n
// title = value[1];\n
// column_title_list.push(title);\n
// column = {\'name\': index,\n
// \'index\': index,\n
// \'width\': 185,\n
// \'align\': \'left\'};\n
// colModel.push(column);\n
// });\n
// \n
// listbox_table.jqGrid({url:listbox_data_url + \'?form_id=\' + current_form_id + \'&amps;listbox_id=\' + field_id,\n
// datatype: "json",\n
// colNames: column_title_list,\n
// colModel: colModel,\n
// rowNum: listbox_dict.lines,\n
// pager: \'#\'+navigation_id,\n
// sortname: \'id\',\n
// viewrecords: true,\n
// sortorder: "desc",\n
// loadError : function(xhr, textStatus, errorThrown) {\n
// // XXX: handle better than just alert.\n
// alert("Error occurred during getting data from server.");\n
// },\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
update: function(data) {\n
......@@ -353,7 +356,6 @@ var ERP5Form = ( function () {\n
// delete validation messages\n
var element;\n
element = $(this);\n
//element.parent().children("div.input").children("." +ERP5Form.SERIALIZE_ABLE_CLASS_NAME).css("border", "none");\n
element.remove();\n
// XXX: remove all rendered in red input classes\n
$(".validation-failed").each(function () {\n
......@@ -361,12 +363,20 @@ var ERP5Form = ( function () {\n
});\n
});\n
// show a fading portal_status_message\n
$("#portal_status_message").toggle();\n
$("#portal_status_message p").html("Saved");\n
window.setTimeout(\'$("#portal_status_message").toggle();\', 4000);\n
RenderJs.GadgetIndex.getGadgetById(\'portal_status_message\').showMessage("Saved", 1000);\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
openFormInTabbularGadget: function (container_id, form_id) {\n
/*\n
......@@ -382,6 +392,19 @@ var ERP5Form = ( function () {\n
\'Form_asJSON?form_id=\' + form_id);;\n
RenderJs.TabbularGadget.toggleVisibility($(\'#\' + 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
......@@ -396,7 +419,7 @@ var ERP5Form = ( function () {\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>17871</int> </value>
<value> <int>18852</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
2012-03-02 Ivan
* Initial work
\ No newline at end of file
* Initial worka
\ No newline at end of file
17
\ No newline at end of file
18
\ 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