[FO] 일계불 월별 js

This commit is contained in:
김현주
2025-06-19 10:55:55 +09:00
parent 16ffd19b85
commit 1284a0d03d
2 changed files with 51 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@@ -117,7 +117,9 @@
} }
_cacheElements() { _cacheElements() {
const { SELECTORS } = DatepickerComponent.CONSTANTS const {
SELECTORS
} = DatepickerComponent.CONSTANTS
this.elements = { this.elements = {
datepicker: document.querySelector(SELECTORS.DATEPICKER), datepicker: document.querySelector(SELECTORS.DATEPICKER),
@@ -164,7 +166,9 @@
} }
_cacheNavigationElements() { _cacheNavigationElements() {
const { SELECTORS } = DatepickerComponent.CONSTANTS const {
SELECTORS
} = DatepickerComponent.CONSTANTS
Object.assign(this.elements, { Object.assign(this.elements, {
prevMonth: document.querySelector(SELECTORS.PREV_MONTH), prevMonth: document.querySelector(SELECTORS.PREV_MONTH),
@@ -182,9 +186,21 @@
_setupEventListeners() { _setupEventListeners() {
// // Bind methods to maintain context // // Bind methods to maintain context
this.boundMethods = { this.boundMethods = {
handleDateChange: ({ detail }) => this._handleDateChange({ detail }), handleDateChange: ({
handleMonthChange: ({ detail }) => this._handleMonthChange({ detail }), detail
handleWeekChange: ({ detail }) => this._handleWeekChange({ detail }), }) => this._handleDateChange({
detail
}),
handleMonthChange: ({
detail
}) => this._handleMonthChange({
detail
}),
handleWeekChange: ({
detail
}) => this._handleWeekChange({
detail
}),
handlePrevWeek: () => this._handlePrevWeek(), handlePrevWeek: () => this._handlePrevWeek(),
handleNextWeek: () => this._handleNextWeek(), handleNextWeek: () => this._handleNextWeek(),
handleModeToggle: () => this._handleModeToggle() handleModeToggle: () => this._handleModeToggle()
@@ -205,7 +221,9 @@
} }
// // Event handlers // // Event handlers
_handleDateChange({ detail }) { _handleDateChange({
detail
}) {
const data = this.data.serverData.get(this.state.currentMonth) const data = this.data.serverData.get(this.state.currentMonth)
this.state.currentList = etUI.utils.getServerDataChildren(data, detail.viewDate.getDate()) this.state.currentList = etUI.utils.getServerDataChildren(data, detail.viewDate.getDate())
@@ -217,11 +235,13 @@
) )
} }
async _handleMonthChange({ detail }) { async _handleMonthChange({
detail
}) {
const date = new Date(detail.viewDate) const date = new Date(detail.viewDate)
const monthKey = this._getMonthKey(date) const monthKey = this._getMonthKey(date)
this._setupMonth(date) // this._setupMonth(date)
if (!this.state.isLoading) { if (!this.state.isLoading) {
await this.loadMonthData(date) await this.loadMonthData(date)
@@ -230,7 +250,9 @@
this.callbacks.changeMonth(monthKey, date) this.callbacks.changeMonth(monthKey, date)
} }
_handleWeekChange({ detail }) { _handleWeekChange({
detail
}) {
// // Week change logic can be added here // // Week change logic can be added here
// // console.log('changeWeek', detail.date) // // console.log('changeWeek', detail.date)
} }
@@ -260,7 +282,9 @@
// // Mode switching helpers // // Mode switching helpers
_updateUIForMode(switchingToWeek) { _updateUIForMode(switchingToWeek) {
const { CLASSES } = DatepickerComponent.CONSTANTS const {
CLASSES
} = DatepickerComponent.CONSTANTS
if (switchingToWeek) { if (switchingToWeek) {
this.elements.datepicker.classList.replace(CLASSES.MONTH, CLASSES.WEEK) this.elements.datepicker.classList.replace(CLASSES.MONTH, CLASSES.WEEK)
@@ -414,7 +438,10 @@
_dispatchWeekChangeEvent(direction, date) { _dispatchWeekChangeEvent(direction, date) {
const event = new CustomEvent('changeWeek', { const event = new CustomEvent('changeWeek', {
detail: { direction, date } detail: {
direction,
date
}
}) })
this.elements.datepicker.dispatchEvent(event) this.elements.datepicker.dispatchEvent(event)
} }
@@ -506,9 +533,9 @@
const cellDate = new Date(Number(cell.dataset.date)) const cellDate = new Date(Number(cell.dataset.date))
cellDate.setHours(0, 0, 0, 0) cellDate.setHours(0, 0, 0, 0)
const classes = data const classes = data ?
? this._getCellClassesWithData(data, cellDate) this._getCellClassesWithData(data, cellDate) :
: etUI.utils.findNumberPosition(cellDate) etUI.utils.findNumberPosition(cellDate)
cell.classList.add(...classes.split(' ')) cell.classList.add(...classes.split(' '))
}) })
@@ -525,7 +552,9 @@
const availToday = etUI.utils.getShowAvailDate(today) const availToday = etUI.utils.getShowAvailDate(today)
if (availToday < date) { if (availToday < date) {
return { classes: DatepickerComponent.CONSTANTS.CLASSES.DISABLED } return {
classes: DatepickerComponent.CONSTANTS.CLASSES.DISABLED
}
} }
} }
@@ -553,7 +582,7 @@
} }
async _finalizeDateLoading(date) { async _finalizeDateLoading(date) {
// this._setupMonth(date) this._setupMonth(date)
const today = new Date() const today = new Date()
const targetDate = this._getTargetDate(date, today) const targetDate = this._getTargetDate(date, today)
@@ -632,8 +661,8 @@
async _getData(month) { async _getData(month) {
await new Promise(resolve => setTimeout(resolve, DatepickerComponent.CONSTANTS.LOADING_DELAY)) await new Promise(resolve => setTimeout(resolve, DatepickerComponent.CONSTANTS.LOADING_DELAY))
// TODO
//const response = await fetch(`http://localhost:8888/assets/json/${month}.json`) //const response = await fetch(`http://localhost:8888/assets/json/${month}.json`)
//TODO
const response = await fetch(`/api/record/calendar/${month}`) const response = await fetch(`/api/record/calendar/${month}`)
return await response.json() return await response.json()
} }