Initiated the process of refactoring the monolithic `work-report-calendar.js` file as outlined in the Phase 2 frontend modernization plan. - Created `CalendarAPI.js` to encapsulate all API calls related to the calendar, centralizing data fetching logic. - Created `CalendarState.js` to manage the component's state, removing global variables from the main script. - Refactored `work-report-calendar.js` to use the new state and API modules. - Refactored `manage-project.js` to use the existing global API helpers, providing a consistent example for API usage.
35 lines
829 B
JavaScript
35 lines
829 B
JavaScript
// web-ui/js/modules/calendar/CalendarState.js
|
|
|
|
/**
|
|
* 캘린더 페이지의 모든 상태를 관리하는 전역 객체입니다.
|
|
*/
|
|
(function(window) {
|
|
'use strict';
|
|
|
|
const CalendarState = {
|
|
// 캘린더 상태
|
|
currentDate: new Date(),
|
|
monthlyData: {}, // 월별 데이터 캐시
|
|
allWorkers: [], // 전체 작업자 목록 캐시
|
|
|
|
// 모달 상태
|
|
currentModalDate: null,
|
|
currentEditingWork: null,
|
|
existingWorks: [],
|
|
|
|
// 상태 초기화
|
|
reset: function() {
|
|
this.currentDate = new Date();
|
|
this.monthlyData = {};
|
|
// allWorkers는 유지
|
|
this.currentModalDate = null;
|
|
this.currentEditingWork = null;
|
|
this.existingWorks = [];
|
|
}
|
|
};
|
|
|
|
// 전역 스코프에 CalendarState 객체 할당
|
|
window.CalendarState = CalendarState;
|
|
|
|
})(window);
|