Commit 981f2e61 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: implement support for hyperlink field

parent 41820141
...@@ -512,12 +512,17 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k ...@@ -512,12 +512,17 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k
if meta_type in ("StringField", "FloatField", "EmailField", "TextAreaField", if meta_type in ("StringField", "FloatField", "EmailField", "TextAreaField",
"LinesField", "ImageField", "FileField", "IntegerField", "LinesField", "ImageField", "FileField", "IntegerField",
"PasswordField", "EditorField"): "PasswordField", "EditorField", "HyperLinkField"):
if meta_type == "FloatField": if meta_type == "FloatField":
result.update({ result.update({
"precision": field.get_value("precision"), "precision": field.get_value("precision"),
"input_style": field.get_value("input_style"), "input_style": field.get_value("input_style"),
}) })
if meta_type == "HyperLinkField":
result.update({
"extra": field.get_value("extra"),
"href": field.get_value("href"),
})
if meta_type == "ImageField": if meta_type == "ImageField":
options = { options = {
'display': field.get_value('image_display'), 'display': field.get_value('image_display'),
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Hyperlink field</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_erp5_field.html">
<link rel="http://www.renderjs.org/rel/interface" href="interface_erp5_form_content_provider.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_field_hyperlink.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global window, rJS, domsugar */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, domsugar) {
"use strict";
rJS(window)
.declareMethod('render', function (options) {
var field_json = options.field_json || {};
return this.changeState({
text: field_json.value || field_json.default || "",
extra: field_json.extra || "",
href: field_json.href || ""
});
})
.onStateChange(function () {
// XXX How to support dangerous extra
// XXX Beware, relative links will break the rJS UI
domsugar(this.element, [domsugar('a', {
href: this.state.href,
text: this.state.text
})]);
})
.declareMethod('getContent', function () {
return {};
})
.declareMethod('checkValidity', function () {
return true;
});
}(window, rJS, domsugar));
\ No newline at end of file
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
field_url = 'gadget_erp5_field_multicheckbox.html'; field_url = 'gadget_erp5_field_multicheckbox.html';
} else if (field_type === 'StringField') { } else if (field_type === 'StringField') {
field_url = 'gadget_erp5_field_string.html'; field_url = 'gadget_erp5_field_string.html';
} else if (field_type === 'HyperLinkField') {
field_url = 'gadget_erp5_field_hyperlink.html';
} else if (field_type === 'LinesField') { } else if (field_type === 'LinesField') {
field_url = 'gadget_erp5_field_lines.html'; field_url = 'gadget_erp5_field_lines.html';
} else if (field_type === 'PasswordField') { } else if (field_type === 'PasswordField') {
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>984.13775.40486.16469</string> </value> <value> <string>984.41193.2075.29252</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1590753601.02</float> <float>1596116391.77</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -42,6 +42,8 @@ url_list = [ ...@@ -42,6 +42,8 @@ url_list = [
'gadget_erp5_field_formbox.js', 'gadget_erp5_field_formbox.js',
'gadget_erp5_field_gadget.html', 'gadget_erp5_field_gadget.html',
'gadget_erp5_field_gadget.js', 'gadget_erp5_field_gadget.js',
'gadget_erp5_field_hyperlink.html',
'gadget_erp5_field_hyperlink.js',
'gadget_erp5_field_image.html', 'gadget_erp5_field_image.html',
'gadget_erp5_field_image.js', 'gadget_erp5_field_image.js',
'gadget_erp5_field_integer.html', 'gadget_erp5_field_integer.html',
......
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