summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2017-03-14 11:01:18 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit868bcc90ba6eb1469ff4b9f211b1343046d1d5b4 (patch)
treec653607cea2f9d185aede0b249b4ccaa04c5552b /addons/web/static/src/js/fields/basic_fields.js
parenta47c342b9e1af45ba8e00777288c52bdc024298c (diff)
[ADD] web: add text field documentation
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index bd2d350385b..183ce3104db 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -480,15 +480,20 @@ var FieldText = AbstractField.extend({
},
}),
supportedFieldTypes: ['text'],
+
+ /**
+ * In edit mode, the text widget contains a textarea. We append it in
+ * start() instead of _renderEdit() to keep the same textarea even
+ * if several _renderEdit are done. This allows to keep the cursor
+ * position and to autoresize only once.
+ *
+ * @override
+ */
start: function () {
this.$el.addClass('o_list_text o_form_textarea');
this.$el.attr('id', this.idForLabel);
if (this.mode === 'edit') {
- // in edit mode, the widget contains a textarea. We append it in
- // start() instead of _renderEdit() to keep the same textarea even
- // if several _renderEdit are done. This allows to keep the cursor
- // position and to autoresize only once
this.$textarea = $('<textarea>').appendTo(this.$el);
if (this.attrs.placeholder) {
this.$textarea.attr('placeholder', this.attrs.placeholder);
@@ -503,6 +508,11 @@ var FieldText = AbstractField.extend({
// Public
//--------------------------------------------------------------------------
+ /**
+ * Automatically selects the content of the field.
+ *
+ * @override
+ */
activate: function () {
var $textarea = this.$('textarea');
$textarea.focus();
@@ -513,9 +523,22 @@ var FieldText = AbstractField.extend({
// Private
//--------------------------------------------------------------------------
+ /**
+ * Format the value and put it in the textarea.
+ *
+ * @override
+ * @private
+ */
_renderEdit: function () {
this.$textarea.val(this._formatValue(this.value));
},
+
+ /**
+ * Format the value and display it.
+ *
+ * @override
+ * @private
+ */
_renderReadonly: function () {
this.$el.empty().text(this._formatValue(this.value));
},