[FIX] web: extract date picker's input setter

This commit extracts the DatePicker widget's input setter to allow
overriding it and preventing from calling the `datetimepicker` lib when
not initialized (like on mobile).

Note: this change will be used on enterprise.

opw-2242880

X-original-commit: c0413868a8728500c52b7e1dd9a0035f90b654fd
This commit is contained in:
Pierre Paridans
2020-07-03 15:54:08 +00:00
parent 88786d6123
commit eba83eddd4
@@ -183,9 +183,7 @@ var DateWidget = Widget.extend({
this.set({'value': value});
var formatted_value = value ? this._formatClient(value) : null;
this.$input.val(formatted_value);
this.__libInput++;
this.$el.datetimepicker('date', value || null);
this.__libInput--;
this._setLibInputValue(value);
},
//--------------------------------------------------------------------------
@@ -231,6 +229,15 @@ var DateWidget = Widget.extend({
_parseClient: function (v) {
return field_utils.parse[this.type_of_date](v, null, {timezone: false});
},
/**
* @private
* @param {Moment|false} value
*/
_setLibInputValue: function (value) {
this.__libInput++;
this.$el.datetimepicker('date', value || null);
this.__libInput--;
},
/**
* @private
* @param {boolean} readonly