[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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user