- 서버PC 자산을 asset_pc 테이블로 통합 마이그레이션 및 스키마 확장 (위치, IP 정보 복구 완료) - 하드웨어 자산 페이지의 구매법인 필터를 자산위치 필터로 교체 및 동적 데이터 바인딩 적용 - 모든 자산 리스트 페이지 상단에 설명(Description) 필드 추가 및 헤더 표준화 - 상세 모달 내 삭제 버튼 기능 구현 및 서버PC 용도 필드 노출 오류 수정 - 현 사용조직 필터 리스트가 비어있던 DOM 셀렉터 버그 수정
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
/**
|
|
* 공통 테이블 핸들러
|
|
*/
|
|
|
|
export type SortDirection = 'asc' | 'desc';
|
|
|
|
export interface SortState {
|
|
key: string;
|
|
direction: SortDirection;
|
|
}
|
|
|
|
/**
|
|
* 테이블 헤더에 정렬 이벤트를 바인딩합니다.
|
|
* @param table 대상 테이블 요소
|
|
* @param currentState 현재 정렬 상태
|
|
* @param onSort 정렬 변경 시 호출될 콜백
|
|
*/
|
|
export function setupTableSorting(
|
|
table: HTMLTableElement,
|
|
currentState: SortState,
|
|
onSort: (key: string, direction: SortDirection) => void
|
|
) {
|
|
const headers = table.querySelectorAll('th[data-sort]');
|
|
|
|
headers.forEach(th => {
|
|
const key = th.getAttribute('data-sort')!;
|
|
th.classList.add('sortable');
|
|
|
|
// 현재 정렬 상태 표시
|
|
if (currentState.key === key) {
|
|
th.classList.add(currentState.direction);
|
|
} else {
|
|
th.classList.remove('asc', 'desc');
|
|
}
|
|
|
|
(th as HTMLElement).onclick = () => {
|
|
let nextDirection: SortDirection = 'asc';
|
|
|
|
if (currentState.key === key) {
|
|
nextDirection = currentState.direction === 'asc' ? 'desc' : 'asc';
|
|
}
|
|
|
|
onSort(key, nextDirection);
|
|
};
|
|
});
|
|
}
|