[REF] web: Fields: DEBOUNCE is a DebouncedField attribute

This commit is contained in:
Aaron Bohy
2017-04-11 19:44:38 +02:00
parent 64e0fe80a3
commit 942d5fc4a3
3 changed files with 12 additions and 10 deletions
@@ -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
@@ -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,
@@ -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);
};
}