[FO] 일계불 월별 js
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -117,7 +117,9 @@
|
||||
}
|
||||
|
||||
_cacheElements() {
|
||||
const { SELECTORS } = DatepickerComponent.CONSTANTS
|
||||
const {
|
||||
SELECTORS
|
||||
} = DatepickerComponent.CONSTANTS
|
||||
|
||||
this.elements = {
|
||||
datepicker: document.querySelector(SELECTORS.DATEPICKER),
|
||||
@@ -164,7 +166,9 @@
|
||||
}
|
||||
|
||||
_cacheNavigationElements() {
|
||||
const { SELECTORS } = DatepickerComponent.CONSTANTS
|
||||
const {
|
||||
SELECTORS
|
||||
} = DatepickerComponent.CONSTANTS
|
||||
|
||||
Object.assign(this.elements, {
|
||||
prevMonth: document.querySelector(SELECTORS.PREV_MONTH),
|
||||
@@ -182,9 +186,21 @@
|
||||
_setupEventListeners() {
|
||||
// // Bind methods to maintain context
|
||||
this.boundMethods = {
|
||||
handleDateChange: ({ detail }) => this._handleDateChange({ detail }),
|
||||
handleMonthChange: ({ detail }) => this._handleMonthChange({ detail }),
|
||||
handleWeekChange: ({ detail }) => this._handleWeekChange({ detail }),
|
||||
handleDateChange: ({
|
||||
detail
|
||||
}) => this._handleDateChange({
|
||||
detail
|
||||
}),
|
||||
handleMonthChange: ({
|
||||
detail
|
||||
}) => this._handleMonthChange({
|
||||
detail
|
||||
}),
|
||||
handleWeekChange: ({
|
||||
detail
|
||||
}) => this._handleWeekChange({
|
||||
detail
|
||||
}),
|
||||
handlePrevWeek: () => this._handlePrevWeek(),
|
||||
handleNextWeek: () => this._handleNextWeek(),
|
||||
handleModeToggle: () => this._handleModeToggle()
|
||||
@@ -205,7 +221,9 @@
|
||||
}
|
||||
|
||||
// // Event handlers
|
||||
_handleDateChange({ detail }) {
|
||||
_handleDateChange({
|
||||
detail
|
||||
}) {
|
||||
const data = this.data.serverData.get(this.state.currentMonth)
|
||||
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 monthKey = this._getMonthKey(date)
|
||||
|
||||
this._setupMonth(date)
|
||||
// this._setupMonth(date)
|
||||
|
||||
if (!this.state.isLoading) {
|
||||
await this.loadMonthData(date)
|
||||
@@ -230,7 +250,9 @@
|
||||
this.callbacks.changeMonth(monthKey, date)
|
||||
}
|
||||
|
||||
_handleWeekChange({ detail }) {
|
||||
_handleWeekChange({
|
||||
detail
|
||||
}) {
|
||||
// // Week change logic can be added here
|
||||
// // console.log('changeWeek', detail.date)
|
||||
}
|
||||
@@ -260,7 +282,9 @@
|
||||
|
||||
// // Mode switching helpers
|
||||
_updateUIForMode(switchingToWeek) {
|
||||
const { CLASSES } = DatepickerComponent.CONSTANTS
|
||||
const {
|
||||
CLASSES
|
||||
} = DatepickerComponent.CONSTANTS
|
||||
|
||||
if (switchingToWeek) {
|
||||
this.elements.datepicker.classList.replace(CLASSES.MONTH, CLASSES.WEEK)
|
||||
@@ -414,7 +438,10 @@
|
||||
|
||||
_dispatchWeekChangeEvent(direction, date) {
|
||||
const event = new CustomEvent('changeWeek', {
|
||||
detail: { direction, date }
|
||||
detail: {
|
||||
direction,
|
||||
date
|
||||
}
|
||||
})
|
||||
this.elements.datepicker.dispatchEvent(event)
|
||||
}
|
||||
@@ -506,9 +533,9 @@
|
||||
const cellDate = new Date(Number(cell.dataset.date))
|
||||
cellDate.setHours(0, 0, 0, 0)
|
||||
|
||||
const classes = data
|
||||
? this._getCellClassesWithData(data, cellDate)
|
||||
: etUI.utils.findNumberPosition(cellDate)
|
||||
const classes = data ?
|
||||
this._getCellClassesWithData(data, cellDate) :
|
||||
etUI.utils.findNumberPosition(cellDate)
|
||||
|
||||
cell.classList.add(...classes.split(' '))
|
||||
})
|
||||
@@ -525,7 +552,9 @@
|
||||
const availToday = etUI.utils.getShowAvailDate(today)
|
||||
|
||||
if (availToday < date) {
|
||||
return { classes: DatepickerComponent.CONSTANTS.CLASSES.DISABLED }
|
||||
return {
|
||||
classes: DatepickerComponent.CONSTANTS.CLASSES.DISABLED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +582,7 @@
|
||||
}
|
||||
|
||||
async _finalizeDateLoading(date) {
|
||||
// this._setupMonth(date)
|
||||
this._setupMonth(date)
|
||||
|
||||
const today = new Date()
|
||||
const targetDate = this._getTargetDate(date, today)
|
||||
@@ -632,8 +661,8 @@
|
||||
|
||||
async _getData(month) {
|
||||
await new Promise(resolve => setTimeout(resolve, DatepickerComponent.CONSTANTS.LOADING_DELAY))
|
||||
// TODO
|
||||
//const response = await fetch(`http://localhost:8888/assets/json/${month}.json`)
|
||||
//TODO
|
||||
const response = await fetch(`/api/record/calendar/${month}`)
|
||||
return await response.json()
|
||||
}
|
||||
@@ -694,7 +723,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
new DatepickerComponent(function(data, currentDate, viewDate){
|
||||
new DatepickerComponent(function(data, currentDate, viewDate) {
|
||||
// data: {no: 2, start: 3, end: 4, children: Array(2)}
|
||||
// currentDate: {start: '2025.06.15', end: '2025.06.16'}
|
||||
// viewDate: instanceof Date
|
||||
@@ -702,7 +731,7 @@
|
||||
|
||||
// TODO
|
||||
formControl.setDetail(data, currentDate, viewDate);
|
||||
}, function(monthKey, currentDate){
|
||||
}, function(monthKey, currentDate) {
|
||||
console.log('changeMonthCallback', monthKey, currentDate);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user