forked from Techsystech/web
Apply default time on manual entry of date string
parent
3af6b1d7f4
commit
bda8836396
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
import {DateTimePicker} from "@web/core/datepicker/datepicker";
|
import {DateTimePicker} from "@web/core/datepicker/datepicker";
|
||||||
import {patch} from "@web/core/utils/patch";
|
import {patch} from "@web/core/utils/patch";
|
||||||
|
import {localization} from "@web/core/l10n/localization";
|
||||||
|
|
||||||
patch(DateTimePicker.prototype, "DateTimePickerDefaultTime", {
|
patch(DateTimePicker.prototype, "DateTimePickerDefaultTime", {
|
||||||
onMounted() {
|
onMounted() {
|
||||||
|
@ -21,6 +22,27 @@ patch(DateTimePicker.prototype, "DateTimePickerDefaultTime", {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
isStrDate(input_string) {
|
||||||
|
return input_string.trim().length == localization.dateFormat.length;
|
||||||
|
},
|
||||||
|
customParseValue(input_value, options) {
|
||||||
|
const default_time = this.props.defaultTime;
|
||||||
|
let [res, error] = this.parseValueOriginal(input_value, options);
|
||||||
|
if (default_time && this.isStrDate(input_value)) {
|
||||||
|
const new_value = res.set({
|
||||||
|
hour: default_time.hour,
|
||||||
|
minute: default_time.minute,
|
||||||
|
second: default_time.second,
|
||||||
|
});
|
||||||
|
res = new_value;
|
||||||
|
}
|
||||||
|
return [res, error];
|
||||||
|
},
|
||||||
|
initFormat() {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
this.parseValueOriginal = this.parseValue;
|
||||||
|
this.parseValue = this.customParseValue;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
DateTimePicker.props = _.extend({}, DateTimePicker.props, {
|
DateTimePicker.props = _.extend({}, DateTimePicker.props, {
|
||||||
|
|
Loading…
Reference in New Issue