Merge pull request #3893 from netchampfaris/fix-date-cache
Fix date cached between forms
This commit is contained in:
commit
c275f8fcfd
1 changed files with 18 additions and 3 deletions
|
|
@ -744,9 +744,24 @@ frappe.ui.form.ControlDate = frappe.ui.form.ControlData.extend({
|
|||
},
|
||||
set_formatted_input: function(value) {
|
||||
this._super(value);
|
||||
if(value
|
||||
&& ((this.last_value && this.last_value !== value)
|
||||
|| (!this.datepicker.selectedDates.length))) {
|
||||
if(!value) return;
|
||||
|
||||
let should_refresh = this.last_value && this.last_value !== value;
|
||||
|
||||
if (!should_refresh) {
|
||||
if(this.datepicker.selectedDates.length > 0) {
|
||||
// if date is selected but different from value, refresh
|
||||
const selected_date =
|
||||
moment(this.datepicker.selectedDates[0])
|
||||
.format(moment.defaultDateFormat);
|
||||
should_refresh = selected_date !== value;
|
||||
} else {
|
||||
// if datepicker has no selected date, refresh
|
||||
should_refresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(should_refresh) {
|
||||
this.datepicker.selectDate(frappe.datetime.str_to_obj(value));
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue