[FIX] web: use the default library behaviour

The library reset the time set when the date is changed.
Then it was not possible to set the time then set the date
and expect the widget to close since the time will be reset
to the default value.
Instead we use the library behaviour and add a 'close' button
for the datetime widgets.
This commit is contained in:
fwi-odoo
2017-02-08 12:53:34 +01:00
parent 2e40f53279
commit 5bd0318594
@@ -34,6 +34,7 @@ var DateWidget = Widget.extend({
previous: 'fa fa-chevron-left',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
close: 'fa fa-times',
},
locale : moment.locale(),
allowInputToggle: true,
@@ -96,16 +97,11 @@ var DateWidget = Widget.extend({
this.picker.date(value);
},
change_datetime: function(e) {
change_datetime: function() {
if(this.is_valid()) {
this.set_value_from_ui();
this.trigger("datetime_changed");
}
//Close the datetimepicker when a date is selected
//We check only if the date has changed.
if(!e.date.isSame(e.oldDate, 'day')){
this.picker.hide();
}
},
commit_value: function() {
this.change_datetime();
@@ -117,7 +113,13 @@ var DateWidget = Widget.extend({
});
var DateTimeWidget = DateWidget.extend({
type_of_date: "datetime"
type_of_date: "datetime",
init: function() {
this._super.apply(this, arguments);
this.options = _.defaults(this.options, {
showClose: true,
});
},
});
return {