mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-24 16:56:14 -04:00
fix: input date format not updating
Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
parent
5ec4c26f01
commit
4801519b9f
1 changed files with 17 additions and 18 deletions
|
@ -7,21 +7,19 @@
|
|||
<div class="text-center">
|
||||
<v-switch v-model="useCurrentDate" label="Use current date"/>
|
||||
</div>
|
||||
|
||||
<v-divider></v-divider>
|
||||
<br>
|
||||
|
||||
<v-row>
|
||||
<v-col md="4" sm="12" class="pt-0 pb-0">
|
||||
<v-select
|
||||
:items="formats.filter(f => !f.title.toLowerCase().includes('locale'))"
|
||||
item-value="dateFromFormat"
|
||||
item-text="title"
|
||||
:items="formats.filter(f => !f.title.toLowerCase().includes('locale')).map(v => v.title)"
|
||||
outlined
|
||||
label="Your date format"
|
||||
placeholder="Input format"
|
||||
v-model="inputFormater"
|
||||
v-model="inputFormatterTitle"
|
||||
@input="userInputChanged()"
|
||||
:disabled="useCurrentDate"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col md="8" sm="12" class="pt-0 pb-0">
|
||||
|
@ -31,6 +29,7 @@
|
|||
label="Your date string"
|
||||
@input="userInputChanged()"
|
||||
:error="invalidInput"
|
||||
:disabled="useCurrentDate"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
@ -67,14 +66,14 @@
|
|||
name: "DateConverter",
|
||||
created() {
|
||||
setInterval(this.refreshCurrentDate.bind(this), 1000);
|
||||
this.inputFormater = this.formats[1].dateFromFormat;
|
||||
this.inputFormatterTitle = this.formats[1].title;
|
||||
},
|
||||
data() {
|
||||
const vm = this;
|
||||
|
||||
return {
|
||||
inputString: '',
|
||||
inputFormater: undefined,
|
||||
inputFormatterTitle: undefined,
|
||||
useCurrentDate: true,
|
||||
displayedDate: new Date(),
|
||||
invalidInput: false,
|
||||
|
@ -137,7 +136,7 @@
|
|||
userInputChanged() {
|
||||
try {
|
||||
this.invalidInput = false;
|
||||
const newDate = this.inputFormater(this.inputString);
|
||||
const newDate = this.formats.find(f => f.title === this.inputFormatterTitle)?.dateFromFormat(this.inputString);
|
||||
|
||||
if (newDate && !isNaN(newDate.getTime())) {
|
||||
this.useCurrentDate = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue