Commit 08e44d70 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: add first support of multilistfield

parent f37dbece
......@@ -104,7 +104,7 @@ def renderField(field, meta_type=None):\n
\n
if meta_type == "ProxyField":\n
result = renderField(field, meta_type=field.getRecursiveTemplateField().meta_type)\n
elif meta_type in ("ListField", "ParallelListField", "MultiListField"):\n
elif meta_type == "ListField":\n
result = {\n
"type": meta_type,\n
"key": field.generate_field_key(),\n
......@@ -118,6 +118,22 @@ def renderField(field, meta_type=None):\n
# XXX Message can not be converted to json as is\n
"items": field.get_value("items"),\n
}\n
elif meta_type in ("ParallelListField", "MultiListField"):\n
result = {\n
"type": meta_type,\n
"key": field.generate_field_key(),\n
"default": field.get_value("default"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"description": field.get_value("description"),\n
"title": field.get_value("title"),\n
"required": field.get_value("required"),\n
# XXX Message can not be converted to json as is\n
"items": field.get_value("items"),\n
}\n
result["sub_select_key"] = traversed_document.Field_getSubFieldKeyDict(field, \'default:list\', key=result["key"])\n
result["sub_input_key"] = "default_" + traversed_document.Field_getSubFieldKeyDict(field, \'default:list:int\', key=result["key"])\n
elif meta_type in ("StringField", "FloatField", "EmailField", "TextAreaField",\n
"LinesField", "ImageField", "FileField", "IntegerField",\n
"PasswordField", "EditorField"):\n
......
......@@ -145,6 +145,8 @@ gadget_erp5_field_list.html\n
gadget_erp5_field_list.js\n
gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n
gadget_erp5_field_multilist.html\n
gadget_erp5_field_multilist.js\n
gadget_erp5_field_readonly.html\n
gadget_erp5_field_readonly.js\n
gadget_erp5_field_string.html\n
......@@ -327,7 +329,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.56086.25956.64870</string> </value>
<value> <string>940.57527.43918.57497</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -345,7 +347,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1423560460.16</float>
<float>1423645129.22</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -214,9 +214,10 @@
field_element.appendChild(label_element);\n
}\n
if (renderered_field.type === \'ListField\') {\n
// (renderered_field.type === \'ParallelListField\') ||\n
// (renderered_field.type === \'MultiListField\')) {\n
field_url = \'gadget_erp5_field_list.html\';\n
} else if ((renderered_field.type === \'ParallelListField\') ||\n
(renderered_field.type === \'MultiListField\')) {\n
field_url = \'gadget_erp5_field_multilist.html\';\n
} else if (renderered_field.type === \'CheckBoxField\') {\n
field_url = \'gadget_erp5_field_checkbox.html\';\n
} else if (renderered_field.type === \'StringField\') {\n
......@@ -509,7 +510,7 @@
</tuple>
<state>
<tuple>
<float>1423560248.21</float>
<float>1423565705.92</float>
<string>UTC</string>
</tuple>
</state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_field_multilist.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_multilistfield_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
<!DOCTYPE html>\n
<html>\n
<head>\n
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>MultiListfield</title>\n
\n
<!-- renderjs -->\n
<script src="rsvp.js" type="text/javascript"></script>\n
<script src="renderjs.js" type="text/javascript"></script>\n
<script src="handlebars.js" type="text/javascript"></script>\n
<!-- custom script -->\n
<script src="gadget_erp5_field_multilist.js" type="text/javascript"></script>\n
<script id="option-template" type="text/x-handlebars-template">\n
<option value="{{value}}" data-i18n="{{text}}">{{text}}</option>\n
</script>\n
\n
<script id="selected-option-template" type="text/x-handlebars-template">\n
<option selected="selected" data-i18n="{{text}}" value="{{value}}">{{text}}</option>\n
</script>\n
</head>\n
<body>\n
<fieldset class="ui-controlgroup ui-corner-all">\n
<div class="ui-controlgroup-controls">\n
</div>\n
</fieldset>\n
</body>\n
</html>
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 MultiListfield</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1423480819.4</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.57847.24942.44731</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1423579715.15</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1423480756.3</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_field_multilist.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_multilistfield_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*global window, rJS, Handlebars, document, RSVP, loopEventListener*/\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, Handlebars, document, RSVP) {\n
\'use strict\';\n
/////////////////////////////////////////////////////////////////\n
// Handlebars\n
/////////////////////////////////////////////////////////////////\n
// Precompile the templates while loading the first gadget instance\n
var gadget_klass = rJS(window),\n
option_source = gadget_klass.__template_element\n
.getElementById("option-template")\n
.innerHTML,\n
option_template = Handlebars.compile(option_source),\n
selected_option_source = gadget_klass.__template_element\n
.getElementById("selected-option-template")\n
.innerHTML,\n
selected_option_template = Handlebars.compile(selected_option_source);\n
gadget_klass\n
.ready(function (g) {\n
g.props = {};\n
})\n
// Assign the element to a variable\n
.ready(function (g) {\n
return g.getElement()\n
.push(function (element) {\n
g.props.element = element;\n
});\n
})\n
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareMethod(\'render\', function (options) {\n
var gadget = this,\n
selects = [],\n
tmp,\n
template,\n
container,\n
field_json = options.field_json,\n
i,\n
j;\n
gadget.props.field_json = field_json;\n
container = gadget.props.element.querySelector(".ui-controlgroup-controls");\n
field_json.default[field_json.default.length] = "";\n
for (i = 0; i < field_json.default.length; i += 1) {\n
tmp = "";\n
selects[i] = document.createElement("select");\n
container.appendChild(selects[i]);\n
for (j = 0; j < field_json.items.length; j += 1) {\n
if (field_json.items[j][1] === field_json.default[i]) {\n
template = selected_option_template;\n
} else {\n
template = option_template;\n
}\n
tmp += template({\n
value: field_json.items[j][1],\n
text: field_json.items[j][0]\n
});\n
}\n
selects[i].innerHTML = tmp;\n
}\n
return new RSVP.Queue()\n
.push(function () {\n
var list = [];\n
for (i = 0; i < selects.length; i += 1) {\n
list.push(gadget.translateHtml(selects[i].outerHTML));\n
}\n
return RSVP.all(list);\n
})\n
.push(function (translated_htmls) {\n
var select_div,\n
div = document.createElement("div");\n
for (i = 0; i < translated_htmls.length; i += 1) {\n
div.innerHTML = translated_htmls[i];\n
select_div = div.querySelector("select");\n
selects[i].innerHTML = select_div.innerHTML;\n
if (field_json.editable !== 1) {\n
selects[i].setAttribute(\'readonly\', \'readonly\');\n
selects[i].setAttribute(\'data-wrapper-class\', \'ui-state-readonly\');\n
}\n
}\n
});\n
})\n
.declareMethod(\'getContent\', function () {\n
var gadget = this,\n
result = {},\n
selects = this.props.element.querySelectorAll(\'select\'),\n
i;\n
for (i = 0; i < selects.length; i += 1) {\n
result[gadget.props.field_json.sub_select_key + "_" + i] = selects[i].options[selects[i].selectedIndex].value;\n
}\n
result[gadget.props.field_json.sub_input_key] = 0;\n
return result;\n
});\n
}(window, rJS, Handlebars, document, RSVP));
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 MultiListField JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1423480905.87</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>940.58254.30018.38519</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1423644326.02</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>xiaowu</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1423480866.38</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
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