From 7ea6f653df0863e9c0dbaf0b07800c0277b962b1 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 26 Jun 2017 09:04:25 +0200 Subject: [FIX] web: MonetaryField: rerender with currency The MonetaryField can be rendered with or without a currency. The currency can change during the lifecyle of the widget (e.g. currency field in the view, whose value is set by an onchange). More precisely, the widget can be instantiated without currency, then a change on another field can trigger an onchange which sets the currency, and our monetary widget is re-rendered with a currency. Before this rev., this wasn't supported in edit mode because the $el's root node was different if there were a currency or not (it was an input if there were no currency, and a div containing an input and a span otherwise). This root node being rendered only once (at the creation of the widget), the widget wasn't re-rendered correctly if the currency was suddenly set or unset. This fix makes the widget behave uniformly whether or not there is a currency, so now it is always a div containing an input (and optionally a span if there is a currency). --- addons/web/static/src/js/fields/basic_fields.js | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 82970255b3e..f6e463c6da4 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -17,7 +17,6 @@ var dom = require('web.dom'); var Domain = require('web.Domain'); var DomainSelector = require('web.DomainSelector'); var DomainSelectorDialog = require('web.DomainSelectorDialog'); -var field_utils = require('web.field_utils'); var framework = require('web.framework'); var session = require('web.session'); var utils = require('web.utils'); @@ -476,15 +475,14 @@ var FieldMonetary = InputField.extend({ this._setCurrency(); - if (this.mode === 'edit' && this.currency) { + if (this.mode === 'edit') { this.tagName = 'div'; this.className += ' o_input'; - } - // use the formatFloat function in edit - if (this.mode === 'edit') { + // use the formatFloat function in edit this.formatType = 'float'; } + this.formatOptions.currency = this.currency; this.formatOptions.digits = [16, 2]; }, @@ -514,20 +512,19 @@ var FieldMonetary = InputField.extend({ * @private */ _renderEdit: function () { - if (!this.currency) { - this._super.apply(this, arguments); - return; - } - this.$el.empty(); + // Prepare and add the input this._prepareInput().appendTo(this.$el); - // prepare and add the currency symbol - var $currencySymbol = $('', {text: this.currency.symbol}); - if (this.currency.position === "after") { - this.$el.append($currencySymbol); - } else { - this.$el.prepend($currencySymbol); + + if (this.currency) { + // Prepare and add the currency symbol + var $currencySymbol = $('', {text: this.currency.symbol}); + if (this.currency.position === "after") { + this.$el.append($currencySymbol); + } else { + this.$el.prepend($currencySymbol); + } } }, /** -- cgit v1.2.3 From 7ada921e67c77e0a9f9ad83f1f685e51c364171d Mon Sep 17 00:00:00 2001 From: Darshan Kalola Date: Wed, 14 Jun 2017 18:26:29 +0530 Subject: [FIX] web_editor: make html widget translatable The translate feature of widgets html and html_frame had been broken by the new views refactoring. This commit restores it for the html widget, and removes it completely for html_frame as it wasn't working correctly before the new views anyway (moreover, it had already been disabled for mass_mailing: de403dc1ab440b9b08ea7fce189cd157745dfe74). This commit also ensures that the changes are correctly saved for the html_frame widget. Note that this widget still needs to be converted to our new coding guidelines. --- addons/web/static/src/js/fields/basic_fields.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index f6e463c6da4..575fe1875e3 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -2234,6 +2234,7 @@ var AceEditor = DebouncedField.extend({ }); return { + TranslatableFieldMixin: TranslatableFieldMixin, DebouncedField: DebouncedField, FieldEmail: FieldEmail, FieldBinaryFile: FieldBinaryFile, -- cgit v1.2.3 From 157732cfb15d743c66c36a1bdcb350026a0473e4 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Tue, 27 Jun 2017 17:56:00 +0200 Subject: [FIX] web: FieldText: keep editing the textarea after enter In the editable list, when pressing enter, the cursor goes to the next line and the current row is saved. This should not be the case for a textarea (i.e. in the FieldText widget). In this particular case, we just want to continue editing the textarea. --- addons/web/static/src/js/fields/basic_fields.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 575fe1875e3..1868a29a237 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -788,6 +788,23 @@ var FieldText = InputField.extend(TranslatableFieldMixin, { } return this._super(); }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Stops the enter navigation in a text area. + * + * @private + * @param {OdooEvent} ev + */ + _onKeydown: function (ev) { + if (ev.which === $.ui.keyCode.ENTER) { + return; + } + this._super.apply(this, arguments); + }, }); /** -- cgit v1.2.3