Commit 628eaa5f authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: auto focus on textarea

parent a48df1f1
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
error_text: field_json.error_text, error_text: field_json.error_text,
title: field_json.description, title: field_json.description,
hidden: field_json.hidden, hidden: field_json.hidden,
focus: field_json.focus,
trim: true, trim: true,
maxlength: field_json.maxlength, maxlength: field_json.maxlength,
// Force calling subfield render // Force calling subfield render
......
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <unicode>zope</unicode> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>988.26496.42040.8686</string> </value> <value> <string>1008.49638.7192.9762</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1609253229.32</float> <float>1701078143.96</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
title: field_json.description, title: field_json.description,
hidden: field_json.hidden, hidden: field_json.hidden,
required: field_json.required, required: field_json.required,
focus: field_json.focus,
// 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()
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <unicode>zope</unicode> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>989.27523.29749.43383</string> </value> <value> <string>1008.49638.7192.9762</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1614692613.61</float> <float>1701077004.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
id: options.id, id: options.id,
name: options.name, name: options.name,
title: options.title, title: options.title,
focus: options.focus,
error_text: options.error_text || "", error_text: options.error_text || "",
hidden: options.hidden hidden: options.hidden
}); });
...@@ -30,7 +31,8 @@ ...@@ -30,7 +31,8 @@
modification_dict.hasOwnProperty('required') || modification_dict.hasOwnProperty('required') ||
modification_dict.hasOwnProperty('id') || modification_dict.hasOwnProperty('id') ||
modification_dict.hasOwnProperty('name') || modification_dict.hasOwnProperty('name') ||
modification_dict.hasOwnProperty('title') modification_dict.hasOwnProperty('title') ||
modification_dict.hasOwnProperty('focus')
) { ) {
if (modification_dict.hasOwnProperty("value")) { if (modification_dict.hasOwnProperty("value")) {
...@@ -52,6 +54,11 @@ ...@@ -52,6 +54,11 @@
textarea.required = false; textarea.required = false;
} }
if (this.state.focus === true) {
textarea.autofocus = true;
textarea.focus();
}
if (this.state.editable) { if (this.state.editable) {
textarea.removeAttribute('readonly'); textarea.removeAttribute('readonly');
} else { } else {
...@@ -78,7 +85,11 @@ ...@@ -78,7 +85,11 @@
} }
}) })
.declareService(function focus() {
if (this.state.focus === true) {
this.element.querySelector('textarea').focus();
}
})
.declareMethod('getContent', function getContent() { .declareMethod('getContent', function getContent() {
var result = {}, var result = {},
input; input;
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <unicode>zope</unicode> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>990.28225.23941.23466</string> </value> <value> <string>1012.50673.40518.63351</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1614695136.35</float> <float>1701080787.95</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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