diff options
| author | David Monjoie <dmo@odoo.com> | 2017-03-14 10:53:34 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 8992b7751c626a30fd188473400ed43951c26b35 (patch) | |
| tree | 52be8225088e25be16dd8655538f93c37fd78386 /addons/web/static/src/js/fields/basic_fields.js | |
| parent | c7e4ffad4f3a70f1d980a56430ff0a9430164832 (diff) | |
[ADD] web: add boolean field tests and documentation
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index ec0c161e4e4..f4f5496006c 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -283,11 +283,22 @@ var FieldBoolean = AbstractField.extend({ // Public //-------------------------------------------------------------------------- + /** + * Automatically selects the field. + * + * @override + */ activate: function () { this.$input.focus(); setTimeout(this.$input.select.bind(this.$input), 0); }, - isSet: function () { + + /** + * A boolean field is always set since false is a valid value. + * + * @override + */ + isSet: function () { return true; }, @@ -295,11 +306,28 @@ var FieldBoolean = AbstractField.extend({ // Private //-------------------------------------------------------------------------- + /** + * The actual checkbox is designed in css to have full control over its + * appearance, as opposed to letting the browser and the os decide how + * a checkbox should look. The actual input is disabled and hidden. + * + * @override + * @private + */ _renderReadonly: function () { var $checkbox = this._formatValue(this.value); this.$input = $checkbox.find('input'); this.$el.empty().append($checkbox); }, + + /** + * The actual checkbox is designed in css to have full control over its + * appearance, as opposed to letting the browser and the os decide how + * a checkbox should look. The actual input is hidden. + * + * @override + * @private + */ _renderEdit: function () { this._renderReadonly(); this.$input.prop('disabled', false); @@ -309,10 +337,22 @@ var FieldBoolean = AbstractField.extend({ // Handlers //-------------------------------------------------------------------------- + /** + * Properly update the value when the checkbox is (un)ticked to trigger + * possible onchanges. + * + * @private + */ _onChange: function () { this._setValue(this.$input[0].checked); }, + /** + * Implement keyboard movements. Mostly useful for its environment, such + * as a list view. + * + * @override + * @private * @param {KeyEvent} event */ _onKeydown: function (event) { |
