From 942d5fc4a3c4f9c4e4b9ec3cc955f77d47b6aac3 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 6 Apr 2017 14:40:00 +0200 Subject: [PATCH] [REF] web: Fields: DEBOUNCE is a DebouncedField attribute --- addons/web/static/src/js/fields/abstract_field.js | 6 ------ addons/web/static/src/js/fields/basic_fields.js | 7 +++++++ addons/web/static/tests/helpers/test_utils.js | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index be271ec3d3d..66bf2aaabe7 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -39,12 +39,6 @@ var AbstractField = Widget.extend({ events: { 'keydown': '_onKeydown', }, - /** - * for field widgets that may have a large number of field changes quickly, - * it could be a good idea to debounce the changes. In that case, this is - * the suggested value. For example, @see DebouncedField. - */ - DEBOUNCE: 1000, /** * if this flag is set to true, the rest of the web client will assume that * it is not editable. For example, the list view in editable mode will diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index a8d026fc8ec..4eb13eb0ec5 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -31,6 +31,12 @@ var DebouncedField = AbstractField.extend({ 'input': '_onInput', 'change': '_onChange', }), + /** + * for field widgets that may have a large number of field changes quickly, + * it could be a good idea to debounce the changes. In that case, this is + * the suggested value. + */ + DEBOUNCE: 1000, /** * Override init to debounce the input changes to make sure they are not @@ -2044,6 +2050,7 @@ var AceEditor = AbstractField.extend({ }); return { + DebouncedField: DebouncedField, EmailWidget: EmailWidget, FieldBinaryFile: FieldBinaryFile, FieldBinaryImage: FieldBinaryImage, diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index 442c67b1954..cff182f21fe 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -10,13 +10,14 @@ odoo.define('web.test_utils', function (require) { * instance of a view, appended in the dom, ready to be tested. */ -var AbstractField = require('web.AbstractField'); +var basic_fields = require('web.basic_fields'); var config = require('web.config'); var core = require('web.core'); var session = require('web.session'); var MockServer = require('web.MockServer'); var Widget = require('web.Widget'); +var DebouncedField = basic_fields.DebouncedField; /** * intercepts an event bubbling up the widget hierarchy. The event intercepted @@ -244,8 +245,8 @@ function addMockEnvironment(widget, params) { var widgetDestroy; // make sure the debounce value for input fields is set to 0 - var initialDebounce = AbstractField.prototype.DEBOUNCE; - AbstractField.prototype.DEBOUNCE = params.fieldDebounce || 0; + var initialDebounce = DebouncedField.prototype.DEBOUNCE; + DebouncedField.prototype.DEBOUNCE = params.fieldDebounce || 0; if ('session' in params) { var initialSession = _.extend({}, session); @@ -269,7 +270,7 @@ function addMockEnvironment(widget, params) { delete config[key]; } _.extend(config, initialConfig); - AbstractField.prototype.DEBOUNCE = initialDebounce; + DebouncedField.prototype.DEBOUNCE = initialDebounce; widgetDestroy.call(this); }; }