[FIX] web: fix FieldDate widget default value

The FieldDate widget did not properly select the correct default value
when opening the datepicker.  We did not notice it, because the test
hardcoded the february month.
This commit is contained in:
Géry Debongnie
2017-04-11 19:44:38 +02:00
committed by Aaron Bohy
parent 60a518dcce
commit e357e26735
2 changed files with 6 additions and 4 deletions
@@ -162,11 +162,12 @@ var FieldDate = InputField.extend({
//--------------------------------------------------------------------------
_makeDatePicker: function () {
return new datepicker.DateWidget(this);
return new datepicker.DateWidget(this, {defaultDate: this.value});
},
_renderEdit: function () {
this.datewidget.set_value(this.value);
},
});
var FieldDateTime = FieldDate.extend({
@@ -177,7 +178,7 @@ var FieldDateTime = FieldDate.extend({
//--------------------------------------------------------------------------
_makeDatePicker: function () {
return new datepicker.DateTimeWidget(this);
return new datepicker.DateTimeWidget(this, {defaultDate: this.value});
},
});
@@ -50,13 +50,14 @@ var DateWidget = Widget.extend({
this.picker = this.$input.data('DateTimePicker');
this.$input.click(this.picker.toggle.bind(this.picker));
this.set_readonly(false);
this.set_value(false);
},
set_value: function(value) {
this.set({'value': value});
var formatted_value = value ? this.format_client(value) : null;
this.$input.val(formatted_value);
this.picker.date(formatted_value);
if (this.picker) {
this.picker.date(formatted_value);
}
},
get_value: function() {
return this.get('value');