Skip to content

Commit

Permalink
fix:日付のデフォルト値を入れた
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsuky committed Jan 9, 2025
1 parent 3bc33a3 commit 3145337
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/components/event/EventFormBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import FormNextButton from '@/components/shared/FormNextButton.vue'
import FormBackButton from '@/components/shared/FormBackButton.vue'
import { useDraftConfirmer } from '@/workers/draftConfirmer'
import { removeDraftConfirmer } from '@/workers/draftConfirmer'
import { today } from '@/workers/date'
import router from '@/router'
import { Route } from 'vue-router'
Expand Down Expand Up @@ -126,6 +127,20 @@ export default class EventFormBase extends Vue {
beforeEachControl: (() => void) | null = null
roundToNextHour(date: Date): Date {
const roundedDate = new Date(date)
const minutes = roundedDate.getMinutes()
const seconds = roundedDate.getSeconds()
const milliseconds = roundedDate.getMilliseconds()
if (minutes > 0 || seconds > 0 || milliseconds > 0) {
roundedDate.setHours(roundedDate.getHours() + 1)
}
roundedDate.setMinutes(0, 0, 0)
return roundedDate
}
created() {
this.content = {
name: this.event?.name ?? '',
Expand All @@ -149,8 +164,15 @@ export default class EventFormBase extends Vue {
: true,
}
this.timeAndPlaceInstant = {
timeStart: this.event?.instant ? this.event.timeStart ?? '' : '',
timeEnd: this.event?.instant ? this.event.timeEnd ?? '' : '',
// TODO: placeだけ初期値がないとvalidationが先に走ってしまう
timeStart: this.event?.instant
? this.event.timeStart ?? ''
: this.roundToNextHour(new Date()).toISOString(),
timeEnd: this.event?.instant
? this.event.timeEnd ?? ''
: this.roundToNextHour(
new Date(new Date().getTime() + 60 * 60 * 1000)
).toISOString(),
place: this.event?.instant ? this.event.place ?? '' : '',
}
this.instant = this.event?.instant ?? false
Expand Down
1 change: 1 addition & 0 deletions src/components/event/EventFormTimeAndPlaceInstant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default class EventFormTimeAndPlaceInstant extends Vue {
}
}
// TODO:やっぱり日付を跨いだ時の処理がおかしい
public autoFillTimeEnd() {
if (!this.timeEndMem) {
this.minuteDiff = 60
Expand Down

0 comments on commit 3145337

Please sign in to comment.