Add validation for date picker [SCI-6541] (#3875)

Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
aignatov-bio 2022-02-21 11:10:50 +01:00 committed by GitHub
parent cce6a17e8f
commit ed5b69c0ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View file

@ -28,7 +28,7 @@
},
methods: {
update(value) {
this.$emit('change', value.toDate());
this.$emit('change', (value instanceof Date) ? value.toDate() : '');
}
}
}

View file

@ -53,15 +53,18 @@
},
recalcTimestamp() {
let date = this.timeOnly ? new Date() : this.date;
if (!this.isValidTime()) {
date.setHours(0);
date.setMinutes(0);
if (this.isValidDate(date)) {
if (!this.isValidTime()) {
date.setHours(0);
date.setMinutes(0);
} else {
date.setHours(this.time.split(':')[0]);
date.setMinutes(this.time.split(':')[1]);
}
this.datetime = date
} else {
date.setHours(this.time.split(':')[0]);
date.setMinutes(this.time.split(':')[1]);
this.datetime = null;
}
this.datetime = date
}
}
}