배포용 수정
This commit is contained in:
@@ -254,7 +254,21 @@
|
||||
const date = new Date(detail.viewDate)
|
||||
const monthKey = this._getMonthKey(date)
|
||||
|
||||
// this._setupMonth(date)
|
||||
// 주 모드일 때 월이 변경되면 weekStart 업데이트
|
||||
if (this.state.mode === 'week') {
|
||||
this._setFirstDateDay(date)
|
||||
|
||||
// datepicker 옵션 업데이트
|
||||
this.instances.datepicker.setOptions({
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
|
||||
// refresh를 통해 요일 헤더 업데이트
|
||||
if (this.instances.datepicker.refresh) {
|
||||
this.instances.datepicker.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.state.isLoading) {
|
||||
await this.loadMonthData(date)
|
||||
@@ -263,6 +277,32 @@
|
||||
this.callbacks.changeMonth(monthKey, date)
|
||||
}
|
||||
|
||||
async _finalizeDateLoading(date) {
|
||||
this._setupMonth(date)
|
||||
|
||||
const today = new Date()
|
||||
const targetDate = this._getTargetDate(date, today)
|
||||
this.instances.datepicker.setDate(targetDate)
|
||||
|
||||
// 주 모드일 때 요일 헤더 업데이트
|
||||
if (this.state.mode === 'week') {
|
||||
this._setFirstDateDay(date)
|
||||
this.instances.datepicker.setOptions({
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
}
|
||||
|
||||
this._scheduleClick()
|
||||
|
||||
if (date >= this.data.minDate) {
|
||||
this.instances.datepicker.refresh()
|
||||
}
|
||||
|
||||
this._loadingEnd()
|
||||
this.elements.datepicker.classList.remove(DatepickerComponent.CONSTANTS.CLASSES.LOADING)
|
||||
}
|
||||
|
||||
_handleWeekChange({
|
||||
detail
|
||||
}) {
|
||||
@@ -325,15 +365,30 @@
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
// 옵션 변경 후 즉시 refresh 호출
|
||||
if (this.instances.datepicker.refresh) {
|
||||
this.instances.datepicker.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
_initializeWeekMode() {
|
||||
const selectedDate = this.instances.datepicker.getDate()
|
||||
const selectedDay = selectedDate.getDate()
|
||||
|
||||
// // 선택된 날짜가 포함된 주차 계산
|
||||
// 선택된 날짜가 포함된 주차 계산
|
||||
this.state.weekPaging = Math.floor((selectedDay - 1) / DatepickerComponent.CONSTANTS.DAYS_PER_WEEK)
|
||||
|
||||
// weekStart 설정 및 옵션 업데이트
|
||||
this._setFirstDateDay(selectedDate)
|
||||
this.instances.datepicker.setOptions({
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
|
||||
// refresh를 통해 요일 헤더 업데이트
|
||||
if (this.instances.datepicker.refresh) {
|
||||
this.instances.datepicker.refresh()
|
||||
}
|
||||
this._weekPagination()
|
||||
this._updateWeekNavigationButtons()
|
||||
}
|
||||
@@ -367,15 +422,31 @@
|
||||
if (this.state.mode !== 'week') return
|
||||
|
||||
const currentDate = this.instances.datepicker.getDate()
|
||||
const currentMonth = currentDate.getMonth()
|
||||
const currentYear = currentDate.getFullYear()
|
||||
|
||||
// // 이전주 버튼 상태 확인
|
||||
// 이전주 버튼 상태 확인
|
||||
const prevWeekDate = this._getPrevWeekDate(currentDate)
|
||||
const isPrevDisabled = prevWeekDate <= this.data.minDate
|
||||
this._toggleButtonDisabled(this.elements.prevWeek, isPrevDisabled)
|
||||
|
||||
// // 다음주 버튼 상태 확인
|
||||
const nextWeekDate = this._getNextWeekDate(currentDate)
|
||||
const isNextDisabled = nextWeekDate >= this.data.maxDate
|
||||
// 다음주 버튼 상태 확인 개선
|
||||
const nextWeekStart = this._getNextWeekDate(currentDate)
|
||||
|
||||
// maxDate와 비교할 때 더 정확한 계산
|
||||
// 다음주가 시작되는 날짜가 maxDate를 초과하는지 확인
|
||||
let isNextDisabled = false
|
||||
|
||||
// 다음주가 다음 달로 넘어가는 경우 체크
|
||||
if (nextWeekStart.getMonth() !== currentMonth) {
|
||||
// 다음 달의 첫째 날이 maxDate를 초과하는지 확인
|
||||
const nextMonthFirstDay = new Date(currentYear, currentMonth + 1, 1)
|
||||
isNextDisabled = nextMonthFirstDay > this.data.maxDate
|
||||
} else {
|
||||
// 같은 달 내에서 다음주 시작일이 maxDate를 초과하는지 확인
|
||||
isNextDisabled = nextWeekStart > this.data.maxDate
|
||||
}
|
||||
|
||||
this._toggleButtonDisabled(this.elements.nextWeek, isNextDisabled)
|
||||
}
|
||||
|
||||
@@ -385,8 +456,12 @@
|
||||
}
|
||||
|
||||
_getNextWeekDate(currentDate) {
|
||||
const endWeekDate = (this.state.weekPaging + 2) * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK
|
||||
return new Date(currentDate.getFullYear(), currentDate.getMonth(), endWeekDate)
|
||||
// 현재 주의 시작일 계산
|
||||
const currentWeekStart = (this.state.weekPaging * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK) + 1
|
||||
// 다음주의 시작일 계산
|
||||
const nextWeekStart = currentWeekStart + DatepickerComponent.CONSTANTS.DAYS_PER_WEEK
|
||||
|
||||
return new Date(currentDate.getFullYear(), currentDate.getMonth(), nextWeekStart)
|
||||
}
|
||||
|
||||
_weekPagingPrev() {
|
||||
@@ -412,11 +487,7 @@
|
||||
|
||||
this.state.maxWeekPaging = Math.ceil(lastDayOfMonth / DatepickerComponent.CONSTANTS.DAYS_PER_WEEK)
|
||||
|
||||
const endWeekDate = (this.state.weekPaging + 2) * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK
|
||||
const date = new Date(currentDate.getFullYear(), currentDate.getMonth(), endWeekDate)
|
||||
|
||||
this._disablePrevNextButtons('next', date)
|
||||
|
||||
// 현재 주가 마지막 주인지 확인
|
||||
if (this.state.weekPaging >= this.state.maxWeekPaging - 1) {
|
||||
this._moveToNextMonth()
|
||||
return
|
||||
@@ -425,6 +496,8 @@
|
||||
this.state.weekPaging += 1
|
||||
this._clickFirstVisibleCell()
|
||||
this._dispatchWeekChangeEvent('next', currentDate)
|
||||
this._weekPagination('next')
|
||||
this._updateWeekNavigationButtons() // 버튼 상태 업데이트 추가
|
||||
}
|
||||
|
||||
_clickFirstVisibleCell() {
|
||||
@@ -487,13 +560,31 @@
|
||||
|
||||
_moveToPreviousMonth() {
|
||||
const currentDate = this.instances.datepicker.getDate()
|
||||
const prevMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, 1)
|
||||
const lastDayOfPrevMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0).getDate()
|
||||
const lastWeekOfPrevMonth = Math.ceil(lastDayOfPrevMonth / DatepickerComponent.CONSTANTS.DAYS_PER_WEEK) - 1
|
||||
const firstDayOfLastWeek = (lastWeekOfPrevMonth * DatepickerComponent.CONSTANTS.DAYS_PER_WEEK) + 1
|
||||
const targetDate = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, firstDayOfLastWeek)
|
||||
|
||||
// 먼저 날짜 설정
|
||||
this.instances.datepicker.setDate(targetDate)
|
||||
|
||||
// 새로운 달의 첫째 날 기준으로 weekStart 업데이트
|
||||
this._setFirstDateDay(prevMonth)
|
||||
|
||||
// datepicker 옵션 업데이트
|
||||
this.instances.datepicker.setOptions({
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
|
||||
this.state.weekPaging = lastWeekOfPrevMonth
|
||||
|
||||
// refresh를 통해 요일 헤더 업데이트
|
||||
if (this.instances.datepicker.refresh) {
|
||||
this.instances.datepicker.refresh()
|
||||
}
|
||||
|
||||
this._weekPagination('prev')
|
||||
this._clickFirstVisibleCell()
|
||||
this._updateWeekNavigationButtons()
|
||||
@@ -503,18 +594,41 @@
|
||||
const currentDate = this.instances.datepicker.getDate()
|
||||
const nextMonthFirstDay = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1)
|
||||
|
||||
// 먼저 날짜 설정
|
||||
this.instances.datepicker.setDate(nextMonthFirstDay)
|
||||
|
||||
// 새로운 달의 첫째 날 기준으로 weekStart 업데이트
|
||||
this._setFirstDateDay(nextMonthFirstDay)
|
||||
|
||||
// datepicker 옵션 업데이트
|
||||
this.instances.datepicker.setOptions({
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
|
||||
this.state.weekPaging = 0
|
||||
|
||||
// // 주 모드에서 월 이동 시 적절한 날짜가 선택되도록 loadMonthData 호출
|
||||
// // changeMonth 이벤트가 자동으로 발생하여 loadMonthData가 호출됨
|
||||
// refresh를 통해 요일 헤더 업데이트
|
||||
if (this.instances.datepicker.refresh) {
|
||||
this.instances.datepicker.refresh()
|
||||
}
|
||||
|
||||
this._weekPagination('next')
|
||||
this._clickFirstVisibleCell()
|
||||
this._updateWeekNavigationButtons()
|
||||
}
|
||||
|
||||
_setFirstDateDay(date) {
|
||||
const firstDate = new Date(date.getFullYear(), date.getMonth(), 1)
|
||||
this.state.weekStart = firstDate.getDay()
|
||||
|
||||
// 주 모드일 때 datepicker 옵션도 즉시 업데이트
|
||||
if (this.state.mode === 'week' && this.instances.datepicker) {
|
||||
this.instances.datepicker.setOptions({
|
||||
...this.instances.datepickerComp.core.props,
|
||||
weekStart: this.state.weekStart
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
_weekPagination(direction) {
|
||||
|
||||
Reference in New Issue
Block a user