Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Frederic Thoma
erp5
Commits
4ffdaa40
Commit
4ffdaa40
authored
May 26, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_renderjs_ui] Add draft support for editable listbox
parent
84f8caf1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
203 additions
and
74 deletions
+203
-74
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_restricted_style/ERP5Document_getHateoas.xml
...rp5_hal_json_restricted_style/ERP5Document_getHateoas.xml
+2
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
...tal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
+61
-19
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
...hTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
+45
-33
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml
...mplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml
+95
-21
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_restricted_style/ERP5Document_getHateoas.xml
View file @
4ffdaa40
...
@@ -71,13 +71,14 @@ return context.ERP5Document_getHateoas(\n
...
@@ -71,13 +71,14 @@ return context.ERP5Document_getHateoas(\n
relative_url=relative_url,\n
relative_url=relative_url,\n
list_method=list_method,\n
list_method=list_method,\n
default_param_json=default_param_json,\n
default_param_json=default_param_json,\n
form_relative_url=form_relative_url,\n
restricted=1\n
restricted=1\n
)\n
)\n
</string>
</value>
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, list_method=None, default_param_json=None
</string>
</value>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, list_method=None, default_param_json=None
, form_relative_url=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
View file @
4ffdaa40
...
@@ -78,6 +78,7 @@ url_template_dict = {\n
...
@@ -78,6 +78,7 @@ url_template_dict = {\n
"{&query,select_list*,limit*}",\n
"{&query,select_list*,limit*}",\n
"custom_search_template": "%(root_url)s/%(script_id)s?mode=search" + \\\n
"custom_search_template": "%(root_url)s/%(script_id)s?mode=search" + \\\n
"&relative_url=%(relative_url)s" \\\n
"&relative_url=%(relative_url)s" \\\n
"&form_relative_url=%(form_relative_url)s" \\\n
"&list_method=%(list_method)s" \\\n
"&list_method=%(list_method)s" \\\n
"&default_param_json=%(default_param_json)s" \\\n
"&default_param_json=%(default_param_json)s" \\\n
"{&query,select_list*,limit*}",\n
"{&query,select_list*,limit*}",\n
...
@@ -104,16 +105,18 @@ def getFieldDefault(field, key):\n
...
@@ -104,16 +105,18 @@ def getFieldDefault(field, key):\n
# REQUEST.get(field.id, field.get_value("default"))\n
# REQUEST.get(field.id, field.get_value("default"))\n
return traversed_document.Field_getDefaultValue(field, key, REQUEST)\n
return traversed_document.Field_getDefaultValue(field, key, REQUEST)\n
\n
\n
def renderField(field,
meta_type
=None):\n
def renderField(field,
form_relative_url, meta_type=None, key
=None):\n
if meta_type is None:\n
if meta_type is None:\n
meta_type = field.meta_type\n
meta_type = field.meta_type\n
if key is None:\n
key = field.generate_field_key()\n
\n
\n
if meta_type == "ProxyField":\n
if meta_type == "ProxyField":\n
result = renderField(field,
meta_type=field.getRecursiveTemplateField().meta_type
)\n
result = renderField(field,
form_relative_url, meta_type=field.getRecursiveTemplateField().meta_type, key=key
)\n
elif meta_type == "ListField":\n
elif meta_type == "ListField":\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -127,7 +130,7 @@ def renderField(field, meta_type=None):\n
...
@@ -127,7 +130,7 @@ def renderField(field, meta_type=None):\n
elif meta_type in ("ParallelListField", "MultiListField"):\n
elif meta_type in ("ParallelListField", "MultiListField"):\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -145,7 +148,7 @@ def renderField(field, meta_type=None):\n
...
@@ -145,7 +148,7 @@ def renderField(field, meta_type=None):\n
"PasswordField", "EditorField"):\n
"PasswordField", "EditorField"):\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -159,7 +162,7 @@ def renderField(field, meta_type=None):\n
...
@@ -159,7 +162,7 @@ def renderField(field, meta_type=None):\n
elif meta_type == "DateTimeField":\n
elif meta_type == "DateTimeField":\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -196,7 +199,7 @@ def renderField(field, meta_type=None):\n
...
@@ -196,7 +199,7 @@ def renderField(field, meta_type=None):\n
accessor_name = \'get%sValue\' % \\\n
accessor_name = \'get%sValue\' % \\\n
\'\'.join([part.capitalize() for part in base_category.split(\'_\')])\n
\'\'.join([part.capitalize() for part in base_category.split(\'_\')])\n
jump_reference = getattr(traversed_document, accessor_name)(\n
jump_reference = getattr(traversed_document, accessor_name)(\n
portal_type=
map(lambda x:x[0], field.get_value(\'portal_type\'))
,\n
portal_type=
[x[0] for x in field.get_value(\'portal_type\')]
,\n
filter=kw\n
filter=kw\n
)\n
)\n
\n
\n
...
@@ -213,7 +216,7 @@ def renderField(field, meta_type=None):\n
...
@@ -213,7 +216,7 @@ def renderField(field, meta_type=None):\n
# "allow_creation": field.get_value(\'allow_creation\'),\n
# "allow_creation": field.get_value(\'allow_creation\'),\n
"allow_creation": 0,\n
"allow_creation": 0,\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -238,7 +241,7 @@ def renderField(field, meta_type=None):\n
...
@@ -238,7 +241,7 @@ def renderField(field, meta_type=None):\n
elif meta_type == "CheckBoxField":\n
elif meta_type == "CheckBoxField":\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -249,7 +252,7 @@ def renderField(field, meta_type=None):\n
...
@@ -249,7 +252,7 @@ def renderField(field, meta_type=None):\n
elif meta_type == "GadgetField":\n
elif meta_type == "GadgetField":\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"editable": field.get_value("editable"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"hidden": field.get_value("hidden"),\n
...
@@ -261,7 +264,9 @@ def renderField(field, meta_type=None):\n
...
@@ -261,7 +264,9 @@ def renderField(field, meta_type=None):\n
result["default"] = getFieldDefault(field, result["key"])\n
result["default"] = getFieldDefault(field, result["key"])\n
elif meta_type == "ListBox":\n
elif meta_type == "ListBox":\n
# XXX Not implemented\n
# XXX Not implemented\n
columns = field.get_value("columns")\n
column_list = field.get_value("columns")\n
search_column_list = field.get_value(\'search_columns\')\n
editable_column_list = field.get_value(\'editable_columns\')\n
\n
\n
# XXX \n
# XXX \n
# list_method = getattr(traversed_document, traversed_document.Listbox_getListMethodName(field))\n
# list_method = getattr(traversed_document, traversed_document.Listbox_getListMethodName(field))\n
...
@@ -277,7 +282,17 @@ def renderField(field, meta_type=None):\n
...
@@ -277,7 +282,17 @@ def renderField(field, meta_type=None):\n
)\n
)\n
list_method_custom = None\n
list_method_custom = None\n
\n
\n
if (list_method_name == "portal_catalog"):\n
if (editable_column_list):\n
list_method_custom = url_template_dict["custom_search_template"] % {\n
"root_url": site_root.absolute_url(),\n
"script_id": script.id,\n
"relative_url": traversed_document.getRelativeUrl().replace("/", "%2F"),\n
"form_relative_url": "%s/%s" % (form_relative_url, field.id),\n
"list_method": list_method_name,\n
"default_param_json": urlsafe_b64encode(json.dumps(list_method_query_dict))\n
}\n
list_method_query_dict = {}\n
elif (list_method_name == "portal_catalog"):\n
pass\n
pass\n
elif (list_method_name == "searchFolder"):\n
elif (list_method_name == "searchFolder"):\n
list_method_query_dict["parent_uid"] = traversed_document.getUid()\n
list_method_query_dict["parent_uid"] = traversed_document.getUid()\n
...
@@ -313,11 +328,14 @@ def renderField(field, meta_type=None):\n
...
@@ -313,11 +328,14 @@ def renderField(field, meta_type=None):\n
\n
\n
result = {\n
result = {\n
"type": meta_type,\n
"type": meta_type,\n
"editable": field.get_value("editable"),\n
# "column_list": [x[1] for x in columns],\n
# "column_list": [x[1] for x in columns],\n
"column_list": columns,\n
"column_list": column_list,\n
"search_column_list": search_column_list,\n
"editable_column_list": editable_column_list,\n
# "line_list": line_list,\n
# "line_list": line_list,\n
"title": field.get_value("title"),\n
"title": field.get_value("title"),\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
"portal_type": portal_types,\n
"portal_type": portal_types,\n
"lines": lines,\n
"lines": lines,\n
"default_params": default_params,\n
"default_params": default_params,\n
...
@@ -337,7 +355,7 @@ def renderField(field, meta_type=None):\n
...
@@ -337,7 +355,7 @@ def renderField(field, meta_type=None):\n
"type": meta_type,\n
"type": meta_type,\n
"_debug": "Unsupported field type",\n
"_debug": "Unsupported field type",\n
"title": field.get_value("title"),\n
"title": field.get_value("title"),\n
"key":
field.generate_field_key()
,\n
"key":
key
,\n
}\n
}\n
return result\n
return result\n
\n
\n
...
@@ -367,6 +385,7 @@ def renderForm(form, response_dict):\n
...
@@ -367,6 +385,7 @@ def renderForm(form, response_dict):\n
"title": traversed_document.getTitle()\n
"title": traversed_document.getTitle()\n
}\n
}\n
\n
\n
form_relative_url = getFormRelativeUrl(form)\n
response_dict[\'_links\'][\'form_definition\'] = {\n
response_dict[\'_links\'][\'form_definition\'] = {\n
# "href": default_document_uri_template % {\n
# "href": default_document_uri_template % {\n
# "root_url": site_root.absolute_url(),\n
# "root_url": site_root.absolute_url(),\n
...
@@ -374,7 +393,7 @@ def renderForm(form, response_dict):\n
...
@@ -374,7 +393,7 @@ def renderForm(form, response_dict):\n
# "relative_url": getFormRelativeUrl(form)\n
# "relative_url": getFormRelativeUrl(form)\n
# },\n
# },\n
"href": default_document_uri_template % {\n
"href": default_document_uri_template % {\n
"relative_url":
getFormRelativeUrl(form)
\n
"relative_url":
form_relative_url
\n
},\n
},\n
\'name\': form.id\n
\'name\': form.id\n
}\n
}\n
...
@@ -387,7 +406,7 @@ def renderForm(form, response_dict):\n
...
@@ -387,7 +406,7 @@ def renderForm(form, response_dict):\n
# field_list.append((field.id, renderRawField(field)))\n
# field_list.append((field.id, renderRawField(field)))\n
if field.get_value("enabled"):\n
if field.get_value("enabled"):\n
try:\n
try:\n
response_dict[field.id] = renderField(field)\n
response_dict[field.id] = renderField(field
, form_relative_url
)\n
if field_errors.has_key(field.id):\n
if field_errors.has_key(field.id):\n
response_dict[field.id]["error_text"] = field_errors[field.id].error_text\n
response_dict[field.id]["error_text"] = field_errors[field.id].error_text\n
except AttributeError:\n
except AttributeError:\n
...
@@ -830,10 +849,22 @@ elif mode == \'search\':\n
...
@@ -830,10 +849,22 @@ elif mode == \'search\':\n
# else:\n
# else:\n
\n
\n
# Cast to list if only one element is provided\n
# Cast to list if only one element is provided\n
editable_field_dict = {}\n
if select_list is None:\n
if select_list is None:\n
select_list = []\n
select_list = []\n
elif same_type(select_list, ""):\n
elif same_type(select_list, ""):\n
select_list = [select_list]\n
select_list = [select_list]\n
\n
if select_list:\n
if (form_relative_url is not None):\n
listbox_field = portal.restrictedTraverse(form_relative_url)\n
listbox_field_id = listbox_field.id\n
# XXX Proxy field are not correctly handled in traversed_document of web site\n
listbox_form = getattr(traversed_document, listbox_field.aq_parent.id)\n
for select in select_list:\n
# See Listbox.py getEditableField method\n
if listbox_form.has_field("%s_%s" % (listbox_field_id, select), include_disabled=1):\n
editable_field_dict[select] = listbox_form.get_field("%s_%s" % (listbox_field_id, select), include_disabled=1)\n
\n
\n
for sql_document in sql_list:\n
for sql_document in sql_list:\n
try:\n
try:\n
...
@@ -841,6 +872,7 @@ elif mode == \'search\':\n
...
@@ -841,6 +872,7 @@ elif mode == \'search\':\n
except AttributeError:\n
except AttributeError:\n
# XXX ERP5 Site is not an ERP5 document\n
# XXX ERP5 Site is not an ERP5 document\n
document = sql_document\n
document = sql_document\n
document_uid = document.getUid()\n
document_result = {\n
document_result = {\n
# \'_relative_url\': sql_document.path[length:],\n
# \'_relative_url\': sql_document.path[length:],\n
\'_links\': {\n
\'_links\': {\n
...
@@ -854,7 +886,17 @@ elif mode == \'search\':\n
...
@@ -854,7 +886,17 @@ elif mode == \'search\':\n
},\n
},\n
}\n
}\n
}\n
}\n
if editable_field_dict:\n
document_result[\'listbox_uid:list\'] = {\n
\'key\': "%s_uid:list" % listbox_field_id,\n
\'value\': document_uid\n
}\n
for select in select_list:\n
for select in select_list:\n
if editable_field_dict.has_key(select):\n
REQUEST.set(\'cell\', document)\n
property_value = renderField(editable_field_dict[select], form_relative_url, key=\'field_%s_%s\' % (editable_field_dict[select].id, document_uid))\n
REQUEST.other.pop(\'cell\', None)\n
else:\n
property_value = document.getProperty(select, d=None)\n
property_value = document.getProperty(select, d=None)\n
if property_value is not None:\n
if property_value is not None:\n
if same_type(property_value, DateTime()):\n
if same_type(property_value, DateTime()):\n
...
@@ -914,7 +956,7 @@ return json.dumps(result_dict, indent=2)\n
...
@@ -914,7 +956,7 @@ return json.dumps(result_dict, indent=2)\n
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, restricted=0, list_method=None, default_param_json=None
</string>
</value>
<value>
<string>
REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, form=None, relative_url=None, restricted=0, list_method=None, default_param_json=None
, form_relative_url=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_form_js.xml
View file @
4ffdaa40
...
@@ -111,6 +111,39 @@
...
@@ -111,6 +111,39 @@
/////////////////////////////////////////////////////////////////\n
/////////////////////////////////////////////////////////////////\n
// Precompile the templates while loading the first gadget instance\n
// Precompile the templates while loading the first gadget instance\n
var gadget_klass = rJS(window);\n
var gadget_klass = rJS(window);\n
\n
function getFieldTypeGadgetUrl(type) {\n
var field_url = \'gadget_erp5_field_readonly.html\';\n
if (type === \'ListField\') {\n
field_url = \'gadget_erp5_field_list.html\';\n
} else if ((type === \'ParallelListField\') ||\n
(type === \'MultiListField\')) {\n
field_url = \'gadget_erp5_field_multilist.html\';\n
} else if (type === \'CheckBoxField\') {\n
field_url = \'gadget_erp5_field_checkbox.html\';\n
} else if (type === \'StringField\') {\n
field_url = \'gadget_erp5_field_string.html\';\n
} else if (type === \'RelationStringField\') {\n
field_url = \'gadget_erp5_field_relationstring.html\';\n
} else if (type === \'TextAreaField\') {\n
field_url = \'gadget_erp5_field_textarea.html\';\n
} else if (type === \'DateTimeField\') {\n
field_url = \'gadget_erp5_field_datetime.html\';\n
} else if (type === \'FloatField\') {\n
field_url = \'gadget_erp5_field_float.html\';\n
} else if (type === \'IntegerField\') {\n
field_url = \'gadget_erp5_field_integer.html\';\n
} else if (type === \'ListBox\') {\n
field_url = \'gadget_erp5_field_listbox.html\';\n
} else if (type === \'EditorField\') {\n
field_url = \'gadget_erp5_field_textarea.html\';\n
// field_url = \'gadget_codemirror.html\';\n
// sandbox = \'iframe\';\n
} else if (type === \'GadgetField\') {\n
field_url = \'gadget_erp5_field_gadget.html\';\n
}\n
return field_url;\n
}\n
\n
\n
gadget_klass\n
gadget_klass\n
/////////////////////////////////////////////////////////////////\n
/////////////////////////////////////////////////////////////////\n
...
@@ -150,6 +183,11 @@
...
@@ -150,6 +183,11 @@
gadget_element.previousElementSibling.querySelector("span").textContent = "";\n
gadget_element.previousElementSibling.querySelector("span").textContent = "";\n
});\n
});\n
})\n
})\n
\n
.allowPublicAcquisition("getFieldTypeGadgetUrl", function (param_list) {\n
return getFieldTypeGadgetUrl(param_list[0]);\n
})\n
\n
/////////////////////////////////////////////////////////////////\n
/////////////////////////////////////////////////////////////////\n
// declared methods\n
// declared methods\n
/////////////////////////////////////////////////////////////////\n
/////////////////////////////////////////////////////////////////\n
...
@@ -191,7 +229,7 @@
...
@@ -191,7 +229,7 @@
// Field is enabled in this context\n
// Field is enabled in this context\n
var field_queue = new RSVP.Queue(),\n
var field_queue = new RSVP.Queue(),\n
sandbox = "public",\n
sandbox = "public",\n
field_url
= \'gadget_erp5_field_readonly.html\'
,\n
field_url,\n
// Don\'t change the structure without changing notifyValid and notifyInvalid\n
// Don\'t change the structure without changing notifyValid and notifyInvalid\n
field_element = document.createElement("div"),\n
field_element = document.createElement("div"),\n
gadget_element = document.createElement("div"),\n
gadget_element = document.createElement("div"),\n
...
@@ -213,34 +251,8 @@
...
@@ -213,34 +251,8 @@
if (group[0] !== "bottom") {\n
if (group[0] !== "bottom") {\n
field_element.appendChild(label_element);\n
field_element.appendChild(label_element);\n
}\n
}\n
if (renderered_field.type === \'ListField\') {\n
\n
field_url = \'gadget_erp5_field_list.html\';\n
field_url = getFieldTypeGadgetUrl(renderered_field.type);\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
field_url = \'gadget_erp5_field_string.html\';\n
} else if (renderered_field.type === \'RelationStringField\') {\n
field_url = \'gadget_erp5_field_relationstring.html\';\n
} else if (renderered_field.type === \'TextAreaField\') {\n
field_url = \'gadget_erp5_field_textarea.html\';\n
} else if (renderered_field.type === \'DateTimeField\') {\n
field_url = \'gadget_erp5_field_datetime.html\';\n
} else if (renderered_field.type === \'FloatField\') {\n
field_url = \'gadget_erp5_field_float.html\';\n
} else if (renderered_field.type === \'IntegerField\') {\n
field_url = \'gadget_erp5_field_integer.html\';\n
} else if (renderered_field.type === \'ListBox\') {\n
field_url = \'gadget_erp5_field_listbox.html\';\n
} else if (renderered_field.type === \'EditorField\') {\n
field_url = \'gadget_erp5_field_textarea.html\';\n
// field_url = \'gadget_codemirror.html\';\n
// sandbox = \'iframe\';\n
} else if (renderered_field.type === \'GadgetField\') {\n
field_url = \'gadget_erp5_field_gadget.html\';\n
}\n
\n
\n
return field_queue\n
return field_queue\n
.push(function () {\n
.push(function () {\n
...
@@ -480,7 +492,7 @@
...
@@ -480,7 +492,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
xiaowu
</string>
</value>
<value>
<string>
romain
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -494,7 +506,7 @@
...
@@ -494,7 +506,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
94
0.60735.27223.48179
</string>
</value>
<value>
<string>
94
3.18226.40997.54510
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -512,8 +524,8 @@
...
@@ -512,8 +524,8 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
14
23755151.34
</float>
<float>
14
32653451.85
</float>
<string>
UTC
</string>
<string>
GMT
</string>
</tuple>
</tuple>
</state>
</state>
</object>
</object>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_listbox_js.xml
View file @
4ffdaa40
...
@@ -118,7 +118,10 @@
...
@@ -118,7 +118,10 @@
/////////////////////////////////////////////////////////////////\n
/////////////////////////////////////////////////////////////////\n
// Init local properties\n
// Init local properties\n
.ready(function (g) {\n
.ready(function (g) {\n
g.props = {};\n
g.props = {\n
cell_gadget_list: [],\n
listbox_uid_dict: {}\n
};\n
})\n
})\n
\n
\n
// Assign the element to a variable\n
// Assign the element to a variable\n
...
@@ -137,6 +140,7 @@
...
@@ -137,6 +140,7 @@
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareAcquiredMethod("whoWantToDisplayThis", "whoWantToDisplayThis")\n
.declareAcquiredMethod("whoWantToDisplayThis", "whoWantToDisplayThis")\n
.declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n
.declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n
.declareAcquiredMethod("getFieldTypeGadgetUrl", "getFieldTypeGadgetUrl")\n
//////////////////////////////////////////////\n
//////////////////////////////////////////////\n
// initialize the gadget content\n
// initialize the gadget content\n
//////////////////////////////////////////////\n
//////////////////////////////////////////////\n
...
@@ -263,27 +267,60 @@
...
@@ -263,27 +267,60 @@
th,\n
th,\n
a,\n
a,\n
result = result_list[0],\n
result = result_list[0],\n
tmp_url;\n
tmp_url,\n
value,\n
promise_list = [],\n
uid_value,\n
uid_value_dict = {};\n
\n
\n
dataset = result;\n
function renderSubCell(element, sub_field_json) {\n
return gadget.getFieldTypeGadgetUrl(sub_field_json.type)\n
.push(function (gadget_url) {\n
return gadget.declareGadget(gadget_url, {\n
element: element\n
});\n
})\n
.push(function (cell_gadget) {\n
gadget.props.cell_gadget_list.push(cell_gadget);\n
sub_field_json.editable = sub_field_json.editable && field_json.editable; // XXX \n
return cell_gadget.render({field_json: sub_field_json});\n
});\n
}\n
\n
\n
dataset = result;\n
for (i = 0; i < counter; i += 1) {\n
for (i = 0; i < counter; i += 1) {\n
tr = document.createElement("tr");\n
tr = document.createElement("tr");\n
tmp_url = result_list[i + 1];\n
tmp_url = result_list[i + 1];\n
\n
\n
for (j = 0; j < field_json.column_list.length; j += 1) {\n
for (j = 0; j < field_json.column_list.length; j += 1) {\n
th = document.createElement("th");\n
th = document.createElement("th");\n
value = result.data.rows[i].value[field_json.column_list[j][0]] || "";\n
if (value.type === undefined) {\n
a = document.createElement("a");\n
a = document.createElement("a");\n
a.href = tmp_url;\n
a.href = tmp_url;\n
a.className = "ui-link";\n
a.className = "ui-link";\n
a.textContent = (result.data.rows[i]\n
a.textContent = value;\n
.value[field_json.column_list[j][0]] || "");\n
th.appendChild(a);\n
th.appendChild(a);\n
} else {\n
if (gadget.props.listbox_uid_dict.key === undefined) {\n
gadget.props.listbox_uid_dict.key = result.data.rows[i].value["listbox_uid:list"].key;\n
gadget.props.listbox_uid_dict.value = [result.data.rows[i].value["listbox_uid:list"].value];\n
uid_value_dict[result.data.rows[i].value["listbox_uid:list"].value] = null;\n
} else {\n
uid_value = result.data.rows[i].value["listbox_uid:list"].value;\n
if (!uid_value_dict.hasOwnProperty(uid_value)) {\n
uid_value_dict[uid_value] = null;\n
gadget.props.listbox_uid_dict.value.push(uid_value);\n
}\n
}\n
\n
promise_list.push(renderSubCell(th, value));\n
}\n
tr.appendChild(th);\n
tr.appendChild(th);\n
}\n
}\n
tbody.appendChild(tr);\n
tbody.appendChild(tr);\n
}\n
}\n
\n
return RSVP.all(promise_list);
\n
}).push(function () {\n
}).push(function () {\n
var prev_param = {},\n
var prev_param = {},\n
next_param = {};\n
next_param = {};\n
...
@@ -372,19 +409,56 @@
...
@@ -372,19 +409,56 @@
// NOTE: for passing translations, temp must contain a table\n
// NOTE: for passing translations, temp must contain a table\n
temp_table.appendChild(fragment);\n
temp_table.appendChild(fragment);\n
temp.appendChild(temp_table);\n
temp.appendChild(temp_table);\n
return gadget.translateHtml(temp.innerHTML);\n
table.appendChild(temp.querySelector("tbody"));\n
return gadget.translateHtml(temp.querySelector("tfoot").innerHTML);\n
})\n
})\n
.push(function (my_translated_html) {\n
.push(function (my_translated_html) {\n
var new_body,\n
var temp = document.createElement("tfoot");\n
new_foot,\n
temp = document.createElement("div");\n
temp.innerHTML = my_translated_html;\n
temp.innerHTML = my_translated_html;\n
new_body = temp.querySelector("tbody");\n
table.appendChild(temp);\n
new_foot = temp.querySelector("tfoot");\n
table.appendChild(new_body);\n
table.appendChild(new_foot);\n
return gadget;\n
});\n
});\n
})\n
\n
\n
.declareMethod("getContent", function () {\n
var form_gadget = this,\n
k,\n
field_gadget,\n
count = form_gadget.props.cell_gadget_list.length,\n
data = {},\n
queue = new RSVP.Queue();\n
\n
function extendData(field_data) {\n
var key;\n
for (key in field_data) {\n
if (field_data.hasOwnProperty(key)) {\n
data[key] = field_data[key];\n
}\n
}\n
}\n
\n
for (k = 0; k
< count
;
k
+=
1)
{\n
field_gadget =
form_gadget.props.cell_gadget_list[k];\n
//
XXX
Hack
until
better
defined\n
if
(field_gadget.getContent
!==
undefined)
{\n
queue\n
.push(field_gadget.getContent.bind(field_gadget))\n
.push(extendData);\n
}\n
}\n
return
queue\n
.push(function
()
{\n
data[form_gadget.props.listbox_uid_dict.key]
=
form_gadget.props.listbox_uid_dict.value;\n
return
data;\n
});\n
})\n
\n
.allowPublicAcquisition("notifyInvalid",
function
()
{\n
return;\n
})\n
\n
.allowPublicAcquisition("notifyValid",
function
()
{\n
return;\n
});\n
});\n
\n
\n
}(window,
document,
rJS,
URI,
RSVP,
UriTemplate));
}(window,
document,
rJS,
URI,
RSVP,
UriTemplate));
...
@@ -524,7 +598,7 @@
...
@@ -524,7 +598,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
94
1.55789.57588.57941
</string>
</value>
<value>
<string>
94
3.18213.25268.27562
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -542,7 +616,7 @@
...
@@ -542,7 +616,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
14
27276913.09
</float>
<float>
14
32652509.88
</float>
<string>
GMT
</string>
<string>
GMT
</string>
</tuple>
</tuple>
</state>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment