Files
Hyungi Ahn 22a37ac4d9 fix: TBM 관리 탭 데스크탑-모바일 데이터 불일치 해결
- TBM 관리 탭의 비관리자 클라이언트 필터링 제거 (모바일과 동일하게 전체 표시)
- tbm.js의 state.js 프록시 변수 중복 선언 제거 (mapRegions, mapCanvas 등)
- 누락된 common/utils.js, common/base-state.js 추가
- 캐시 버스팅을 위한 버전 쿼리 스트링 업데이트

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 15:42:29 +09:00

57 lines
1.2 KiB
JavaScript

/**
* BaseState - 상태 관리 베이스 클래스
* TbmState / DailyWorkReportState 공통 패턴
*/
class BaseState {
constructor() {
this.listeners = new Map();
}
/**
* 상태 업데이트 + 리스너 알림
*/
update(key, value) {
const prevValue = this[key];
this[key] = value;
this.notifyListeners(key, value, prevValue);
}
/**
* 리스너 등록
*/
subscribe(key, callback) {
if (!this.listeners.has(key)) {
this.listeners.set(key, []);
}
this.listeners.get(key).push(callback);
}
/**
* 리스너 알림
*/
notifyListeners(key, newValue, prevValue) {
const keyListeners = this.listeners.get(key) || [];
keyListeners.forEach(callback => {
try {
callback(newValue, prevValue);
} catch (error) {
console.error(`[${this.constructor.name}] 리스너 오류 (${key}):`, error);
}
});
}
/**
* 현재 사용자 정보 (localStorage)
*/
getUser() {
const userInfo = localStorage.getItem('sso_user');
return userInfo ? JSON.parse(userInfo) : null;
}
}
// 전역 노출
window.BaseState = BaseState;
console.log('[Module] common/base-state.js 로드 완료');