Commit 56681f31 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: add support for LinkField

parent ff829633
......@@ -512,7 +512,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None, k
if meta_type in ("StringField", "FloatField", "EmailField", "TextAreaField",
"LinesField", "ImageField", "FileField", "IntegerField",
"PasswordField", "EditorField", "HyperLinkField"):
"PasswordField", "EditorField", "HyperLinkField", "LinkField"):
if meta_type == "FloatField":
result.update({
"precision": field.get_value("precision"),
......
......@@ -32,6 +32,8 @@
field_url = 'gadget_erp5_field_string.html';
} else if (field_type === 'HyperLinkField') {
field_url = 'gadget_erp5_field_hyperlink.html';
} else if (field_type === 'LinkField') {
field_url = 'gadget_erp5_field_link.html';
} else if (field_type === 'LinesField') {
field_url = 'gadget_erp5_field_lines.html';
} else if (field_type === 'PasswordField') {
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.16240.14459.45960</string> </value>
<value> <string>989.58905.49586.62361</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1602525354.74</float>
<float>1614349412.76</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Link 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>
<!-- custom script -->
<script src="gadget_erp5_field_link.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global window, document, rJS */
/*jslint indent: 2, maxerr: 3 */
(function (window, document, rJS) {
"use strict";
rJS(window)
.setState({
tag: 'a'
})
.declareMethod('render', function (options) {
var field_json = options.field_json || {},
state_dict = {
value: field_json.value || field_json.default || "",
editable: field_json.editable,
required: field_json.required,
id: field_json.key,
name: field_json.key,
error_text: field_json.error_text,
title: field_json.description,
label: field_json.title,
hidden: field_json.hidden,
trim: true,
// Force calling subfield render
// as user may have modified the input value
render_timestamp: new Date().getTime()
};
return this.changeState(state_dict);
})
.onStateChange(function (modification_dict) {
var element = this.element,
gadget = this,
url,
result,
new_div;
if (modification_dict.hasOwnProperty('editable')) {
if (gadget.state.editable) {
url = 'gadget_html5_input.html';
} else {
url = 'gadget_html5_element.html';
}
while (element.firstChild) {
element.removeChild(element.firstChild);
}
new_div = document.createElement('div');
element.appendChild(new_div);
result = this.declareGadget(url, {scope: 'sub', element: new_div});
} else {
result = this.getDeclaredGadget('sub');
}
return result
.push(function (input) {
var state;
if (gadget.state.editable) {
state = gadget.state;
} else {
state = {
tag: 'a',
href: gadget.state.value,
text_content: gadget.state.label
};
}
return input.render(state);
});
})
/** Return content even for non-editable cells - be backward compatible! */
.declareMethod('getContent', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.getContent();
});
}
return {};
}, {mutex: 'changestate'})
.declareMethod('checkValidity', function () {
if (this.state.editable) {
return this.getDeclaredGadget('sub')
.push(function (gadget) {
return gadget.checkValidity();
});
}
return true;
}, {mutex: 'changestate'});
}(window, document, rJS));
\ No newline at end of file
......@@ -43,6 +43,8 @@ url_list = [
'gadget_erp5_field_list.js',
'gadget_erp5_field_lines.html',
'gadget_erp5_field_lines.js',
'gadget_erp5_field_link.html',
'gadget_erp5_field_link.js',
'gadget_erp5_field_listbox.html',
'gadget_erp5_field_listbox.js',
'gadget_erp5_field_matrixbox.html',
......
......@@ -13,7 +13,7 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tal:block tal:define="check_configuration python: {'precache_reference': '../renderjs_runner/WebSection_getPrecacheManifest',
'gadget_count': 70}">
'gadget_count': 71}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUiInterface/macros/run_app_interface_check" />
</tal:block>
......
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