diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2019-11-14 10:49:14 +0000 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2020-01-27 09:31:52 +0000 |
| commit | d41d6275690e913efe63b88610ec73f0e796e253 (patch) | |
| tree | b926d165f694e1e2fdb0bf85ab8db5f2b791ea37 /addons/sms/static/src | |
| parent | 87397d008066c2e2e864c608ecd600ba9f0623d1 (diff) | |
[IMP] web: field phone widget deals with SMS by default
Task 2123526
Before this task, the phone widget on char fields was not
displaying the send sms button by default
After this task, the default behavior of the phone
widget is to display the send sms button
Diffstat (limited to 'addons/sms/static/src')
| -rw-r--r-- | addons/sms/static/src/js/fields_phone_widget.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/addons/sms/static/src/js/fields_phone_widget.js b/addons/sms/static/src/js/fields_phone_widget.js index f269b26d0ed..4dd9a033e23 100644 --- a/addons/sms/static/src/js/fields_phone_widget.js +++ b/addons/sms/static/src/js/fields_phone_widget.js @@ -8,11 +8,35 @@ var session = require('web.session'); var _t = core._t; /** - * Override of FieldPhone to use add a button calling SMS composer if option activated + * Override of FieldPhone to add a button calling SMS composer if option activated (default) */ var Phone = basic_fields.FieldPhone; Phone.include({ + /** + * By default, enable_sms is activated + * + * @override + */ + init() { + this._super.apply(this, arguments); + this.enableSMS = 'enable_sms' in this.attrs.options ? this.attrs.options.enable_sms : true; + // reinject in nodeOptions (and thus in this.attrs) to signal the property + this.attrs.options.enable_sms = this.enableSMS; + }, + /** + * When the send SMS button is displayed, $el becomes a div wrapping + * the original links. + * This method makes sure we always focus the phone number + * + * @override + */ + getFocusableElement() { + if (this.enableSMS && this.mode === 'readonly') { + return this.$('.' + this.className); + } + return this._super.apply(this, arguments); + }, //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- @@ -24,6 +48,7 @@ Phone.include({ */ _onClickSMS: function (ev) { ev.preventDefault(); + ev.stopPropagation(); var context = session.user_context; context = _.extend({}, context, { @@ -54,7 +79,7 @@ Phone.include({ */ _renderReadonly: function () { var def = this._super.apply(this, arguments); - if (this.nodeOptions.enable_sms) { + if (this.enableSMS) { var $composerButton = $('<a>', { title: _t('Send SMS Text Message'), href: '', |
