Commit 5e2cf409 authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: float field: handle all ERP5 input types

parent 9fdaa99a
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>A form with only only a float field</string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_float_field</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>5.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Float Field</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Foo_viewFloatField</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_first_failure</string>
<string>my_delivery_ratio</string>
<string>my_delivery_ratio_read_only</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>my_quantity</string>
<string>my_quantity_read_only</string>
<string>my_quantity_read_only_percent</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Foo_viewFloatField</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Foo_viewFloatField</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Float Fields</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_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="FloatField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_delivery_ratio</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>not_float</string> </key>
<value> <string>You did not enter a floating point number.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string>-12.3%</string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>text</string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Delivery Ratio</string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="FloatField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_quantity</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>not_float</string> </key>
<value> <string>You did not enter a floating point number.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>input_style</string> </key>
<value> <string>-1.234,5</string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>text</string> </value>
</item>
<item>
<key> <string>precision</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Quantity</string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -41,6 +41,7 @@ Foo | view_crash_on_save ...@@ -41,6 +41,7 @@ Foo | view_crash_on_save
Foo | view_dialog_with_only_update Foo | view_dialog_with_only_update
Foo | view_dialog_with_validation_error Foo | view_dialog_with_validation_error
Foo | view_duration_field Foo | view_duration_field
Foo | view_float_field
Foo | view_formbox Foo | view_formbox
Foo | view_formbox_dialog Foo | view_formbox_dialog
Foo | view_formbox_fooline Foo | view_formbox_fooline
......
/*global window, rJS, Math */ /*global window, rJS, Math, parseFloat, isNaN */
/*jslint indent: 2, maxerr: 3 */ /*jslint indent: 2, maxerr: 3 */
(function (window, rJS, Math) { (function (window, rJS, Math, parseFloat, isNaN) {
"use strict"; "use strict";
var separator_re = /\d([\., \-_])?\d\d\d/, var HTML5_INPUT_STYLE = "-1234.5",
input_format_re = /(-?)(\d+)(\.\d+)?/; SPACE_INPUT_STYLE = "-1 234.5",
SPACE_COMMA_INPUT_STYLE = "-1 234,5",
DOT_COMMA_INPUT_STYLE = "-1.234,5",
COMMA_DOT_INPUT_STYLE = "-1,234.5",
PERCENT_INPUT_STYLE = "-12.3%";
/** Slice any slice-able parameter into triplets **/ function setCharAt(str, index, chr) {
function toTriplets(sliceable) { return str.substring(0, index) + chr + str.substring(index + 1);
var parts = [], }
i = sliceable.length;
for (i = sliceable.length; i > 3; i -= 3) { function getSeparatorDict(input_style) {
parts.unshift(sliceable.slice(i - 3, i)); if (input_style === SPACE_INPUT_STYLE) {
return {thousand: ' ', decimal: '.'};
}
if (input_style === SPACE_COMMA_INPUT_STYLE) {
return {thousand: ' ', decimal: ','};
}
if (input_style === DOT_COMMA_INPUT_STYLE) {
return {thousand: '.', decimal: ','};
}
if (input_style === COMMA_DOT_INPUT_STYLE) {
return {thousand: ',', decimal: '.'};
}
throw new Error('No supported input style: ' + input_style);
}
function convertFloatToHTML5Input(precision, input_style, float) {
// ERP5 always devides the value by 100 if it is set to percentages
// thus we have to mitigate that in javascript here
if (input_style === PERCENT_INPUT_STYLE) {
float *= 100.0;
}
if (!isNaN(precision)) {
float = float.toFixed(precision);
}
return float.toString();
}
function convertERP5InputToHTML5Input(input_style, text) {
// Convert ERP5 input style to html5 float text
if (input_style === HTML5_INPUT_STYLE) {
return text;
}
if (input_style === PERCENT_INPUT_STYLE) {
if (text[text.length - 1] !== '%') {
throw new Error('Can not parse: ' + text);
}
return text.substring(0, text.length - 1);
}
var separator_dict = getSeparatorDict(input_style),
decimal_index = text.indexOf(separator_dict.decimal),
original_text = text,
i;
if (decimal_index !== -1) {
text = setCharAt(text, decimal_index, '.');
i = decimal_index;
} else {
i = text.length;
}
i = i - 4;
// Remove thousand separator
while (i > 0) {
if (text[i] !== separator_dict.thousand) {
throw new Error('Can not parse: ' + original_text);
}
text = text.substring(0, i) + text.substring(i + 1);
i -= 4;
}
return text;
}
function convertHTML5InputToERP5Input(input_style, text) {
if (input_style === HTML5_INPUT_STYLE) {
return text;
}
if (input_style === PERCENT_INPUT_STYLE) {
return text + '%';
}
var separator_dict = getSeparatorDict(input_style),
decimal_index = text.indexOf('.'),
i;
if (decimal_index !== -1) {
text = setCharAt(text, decimal_index, separator_dict.decimal);
i = decimal_index;
} else {
i = text.length;
}
i = i - 3;
// Add thousand separator
while (i > 0) {
text = text.substring(0, i) + separator_dict.thousand + text.substring(i);
i -= 3;
} }
parts.unshift(sliceable.slice(0, i)); return text;
return parts;
} }
rJS(window) rJS(window)
...@@ -24,9 +114,10 @@ ...@@ -24,9 +114,10 @@
}) })
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var field_json = options.field_json || {}, var field_json = options.field_json || {},
input_style = (field_json.input_style || ""), input_style = (field_json.input_style || HTML5_INPUT_STYLE),
percentage = input_style.endsWith("%"), value = field_json.default,
thousand_sep = separator_re.test(input_style) ? (separator_re.exec(input_style)[1] || "") : "", text_content,
precision = parseFloat(field_json.precision),
state_dict = { state_dict = {
editable: field_json.editable, editable: field_json.editable,
required: field_json.required, required: field_json.required,
...@@ -34,11 +125,8 @@ ...@@ -34,11 +125,8 @@
id: field_json.key, id: field_json.key,
name: field_json.key, name: field_json.key,
title: field_json.description, title: field_json.description,
precision: window.parseFloat(field_json.precision), // precision: window.parseFloat(field_json.precision),
error_text: field_json.error_text, error_text: field_json.error_text,
// erp5 always put value into "default" (never "value")
value: window.parseFloat(field_json.default),
text_content: '',
// `step` is used for browser-level validation thus a mandatory value // `step` is used for browser-level validation thus a mandatory value
// if unspecified we can use "any" value // if unspecified we can use "any" value
step: "any", step: "any",
...@@ -47,31 +135,32 @@ ...@@ -47,31 +135,32 @@
// Force calling subfield render // Force calling subfield render
// as user may have modified the input value // as user may have modified the input value
render_timestamp: new Date().getTime() render_timestamp: new Date().getTime()
}, };
tmp;
if (typeof value === 'number') {
if (percentage) { value = convertFloatToHTML5Input(precision, input_style, value);
// ERP5 always devides the value by 100 if it is set to percentages text_content = convertHTML5InputToERP5Input(input_style, value);
// thus we have to mitigate that in javascript here } else if (value === null) {
// (field_json.default type is number, only when it is initially loaded) text_content = '';
if (typeof(field_json.default) == 'number') { value = undefined;
state_dict.value *= 100.0; } else {
} text_content = value;
state_dict.append = "%"; value = convertERP5InputToHTML5Input(input_style, value);
} }
if (!window.isNaN(state_dict.precision)) {
state_dict.step = Math.pow(10, -state_dict.precision).toFixed(state_dict.precision); state_dict.value = value;
state_dict.value = state_dict.value.toFixed(state_dict.precision); state_dict.text_content = text_content;
state_dict.input_style = input_style;
if ((input_style === PERCENT_INPUT_STYLE) && state_dict.editable) {
// Display the % next to the input field
state_dict.append = "%";
} }
if (!window.isNaN(state_dict.value)) { if (!isNaN(precision)) {
state_dict.text_content = state_dict.value.toString(); state_dict.step = Math.pow(10, -precision)
if (state_dict.text_content !== "" && thousand_sep !== "") { .toFixed(precision);
tmp = input_format_re.exec(state_dict.text_content);
// tmp == [full-number, sign, integer-part, .decimal-part (can be undefined because of permissive regexp), ...]
state_dict.text_content = tmp[1] + toTriplets(tmp[2]).join(thousand_sep) + (tmp[3] || "");
tmp = undefined;
}
} }
return this.changeState(state_dict); return this.changeState(state_dict);
}) })
...@@ -106,10 +195,19 @@ ...@@ -106,10 +195,19 @@
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
var gadget = this;
if (this.state.editable) { if (this.state.editable) {
return this.getDeclaredGadget('sub') return this.getDeclaredGadget('sub')
.push(function (gadget) { .push(function (sub_gadget) {
return gadget.getContent(); return sub_gadget.getContent();
})
.push(function (result) {
result[gadget.state.name] =
convertHTML5InputToERP5Input(
gadget.state.input_style,
result[gadget.state.name]
);
return result;
}); });
} }
return {}; return {};
...@@ -125,4 +223,4 @@ ...@@ -125,4 +223,4 @@
return true; return true;
}, {mutex: 'changestate'}); }, {mutex: 'changestate'});
}(window, rJS, Math)); }(window, rJS, Math, parseFloat, isNaN));
\ No newline at end of file \ No newline at end of file
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>kazuhiko</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>986.52682.33152.28245</string> </value> <value> <string>989.39131.12225.13038</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>1610995697.98</float> <float>1611676581.15</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<?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>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>testFloatFieldPercentType</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Float Value with Float Fields</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test thousand and decimal separators</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<!-- Shortcut for full renderjs url -->
<tr><td>store</td>
<td>${base_url}/web_site_module/renderjs_runner</td>
<td>renderjs_url</td></tr>
<tr><td>open</td>
<td>${renderjs_url}/#/foo_module/1?editable=1</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Views'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Float Field'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td colspan="3"><p></p></td>
</tr>
<tr>
<td colspan="3"><b>Check default 1 value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_delivery_ratio</td>
<td>100.0</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_delivery_ratio_read_only' and text()='1,0000']</td>
<td></td></tr>
<tr><td>type</td>
<td>field_my_delivery_ratio</td>
<td>99.9</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td colspan="3"><b>Check 1 value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_delivery_ratio</td>
<td>99.9</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_delivery_ratio_read_only' and text()='0,9990']</td>
<td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td colspan="3"><b>Check value is not modified by save only</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_delivery_ratio</td>
<td>99.9</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_delivery_ratio_read_only' and text()='0,9990']</td>
<td></td></tr>
<tr><td>type</td>
<td>field_my_delivery_ratio</td>
<td>0.1</td></tr>
<tr><td>type</td>
<td>field_your_first_failure</td>
<td>3</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_save" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="notification_configuration python: {'class': 'error',
'text': 'Input data has errors.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td colspan="3"><b>Check validator string value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_delivery_ratio</td>
<td>0.1</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_delivery_ratio_read_only' and text()='0,9990']</td>
<td></td></tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?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>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>testFloatFieldSeparator</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Float Value with Float Fields</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test thousand and decimal separators</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<!-- Shortcut for full renderjs url -->
<tr><td>store</td>
<td>${base_url}/web_site_module/renderjs_runner</td>
<td>renderjs_url</td></tr>
<tr><td>open</td>
<td>${renderjs_url}/#/foo_module/1?editable=1</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Views'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Float Field'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td colspan="3"><p></p></td>
</tr>
<tr>
<td colspan="3"><b>Check default 0 value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_quantity</td>
<td>0.00</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only' and text()='0,000']</td>
<td></td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only_percent' and text()='0.00%']</td>
<td></td></tr>
<tr><td>type</td>
<td>field_my_quantity</td>
<td>1</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td colspan="3"><b>Check 1 value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_quantity</td>
<td>1.00</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only' and text()='1,000']</td>
<td></td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only_percent' and text()='100.00%']</td>
<td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td colspan="3"><b>Check value is not modified by save only</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_quantity</td>
<td>1.00</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only' and text()='1,000']</td>
<td></td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only_percent' and text()='100.00%']</td>
<td></td></tr>
<tr><td>type</td>
<td>field_my_quantity</td>
<td>1000.1</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/save" />
<tr>
<td colspan="3"><b>Check 1000.1 value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_quantity</td>
<td>1000.10</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only' and text()='1.000,100']</td>
<td></td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only_percent' and text()='100010.00%']</td>
<td></td></tr>
<tr><td>type</td>
<td>field_my_quantity</td>
<td>0.99</td></tr>
<tr><td>type</td>
<td>field_your_first_failure</td>
<td>3</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_save" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="notification_configuration python: {'class': 'error',
'text': 'Input data has errors.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td colspan="3"><b>Check validator string value</b></td>
</tr>
<tr><td>assertValue</td>
<td>field_my_quantity</td>
<td>0.99</td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only' and text()='1.000,100']</td>
<td></td></tr>
<tr><td>assertElementPresent</td>
<td>//p[@id='field_my_quantity_read_only_percent' and text()='100010.00%']</td>
<td></td></tr>
</tbody></table>
</body>
</html>
\ 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