Implement global table sorting, dashboard UI enhancements, and secret cloud access
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { state } from '../../core/state';
|
||||
import { openHwModal } from '../../components/Modal/HWModal';
|
||||
import { formatInline, createBadge, sortAssets } from '../../core/utils';
|
||||
import { formatInline, createBadge, sortAssets, dynamicSort } from '../../core/utils';
|
||||
import { ASSET_SCHEMA, UI_TEXT } from '../../core/schema';
|
||||
import { setupTableSorting, SortState } from '../../core/tableHandler';
|
||||
import { createIcons, RefreshCcw } from 'lucide';
|
||||
|
||||
/**
|
||||
@@ -10,6 +11,7 @@ import { createIcons, RefreshCcw } from 'lucide';
|
||||
*/
|
||||
export function renderStorageList(container: HTMLElement) {
|
||||
const fullList = sortAssets(state.masterData.storage);
|
||||
let sortState: SortState = { key: '', direction: 'asc' };
|
||||
|
||||
const filterBar = document.createElement('div');
|
||||
filterBar.className = 'search-bar';
|
||||
@@ -42,14 +44,14 @@ export function renderStorageList(container: HTMLElement) {
|
||||
table.innerHTML = `
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">No</th>
|
||||
<th class="text-center">${ASSET_SCHEMA.CORP.ui}</th>
|
||||
<th class="text-center">${ASSET_SCHEMA.ORG.ui}</th>
|
||||
<th class="text-center">${ASSET_SCHEMA.ASSET_CODE.ui}</th>
|
||||
<th>용도</th>
|
||||
<th>상세</th>
|
||||
<th class="text-center">${ASSET_SCHEMA.LOCATION.ui}</th>
|
||||
<th class="text-center">담당자(정/부)</th>
|
||||
<th class="text-center" style="width:50px;">No</th>
|
||||
<th class="text-center" data-sort="${ASSET_SCHEMA.CORP.key}">${ASSET_SCHEMA.CORP.ui}</th>
|
||||
<th class="text-center" data-sort="${ASSET_SCHEMA.ORG.key}">${ASSET_SCHEMA.ORG.ui}</th>
|
||||
<th class="text-center" data-sort="${ASSET_SCHEMA.ASSET_CODE.key}">${ASSET_SCHEMA.ASSET_CODE.ui}</th>
|
||||
<th data-sort="용도">용도</th>
|
||||
<th data-sort="상세">상세</th>
|
||||
<th class="text-center" data-sort="${ASSET_SCHEMA.LOCATION.key}">${ASSET_SCHEMA.LOCATION.ui}</th>
|
||||
<th class="text-center" data-sort="${ASSET_SCHEMA.MANAGER_MAIN.key}">담당자(정/부)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="dynamic-tbody"></tbody>
|
||||
@@ -68,7 +70,7 @@ export function renderStorageList(container: HTMLElement) {
|
||||
const corp = corpSelect ? corpSelect.value : '';
|
||||
const orgUnit = orgSelect ? orgSelect.value : '';
|
||||
|
||||
const filtered = fullList.filter(asset => {
|
||||
let filtered = fullList.filter(asset => {
|
||||
const matchKeyword = !keyword ||
|
||||
String((asset as any)[ASSET_SCHEMA.ASSET_CODE.key]||'').toLowerCase().includes(keyword) ||
|
||||
String((asset as any)[ASSET_SCHEMA.ORG.key]||'').toLowerCase().includes(keyword);
|
||||
@@ -77,6 +79,10 @@ export function renderStorageList(container: HTMLElement) {
|
||||
return matchKeyword && matchCorp && matchOrg;
|
||||
});
|
||||
|
||||
if (sortState.key) {
|
||||
filtered = dynamicSort(filtered, sortState.key, sortState.direction);
|
||||
}
|
||||
|
||||
tbody.innerHTML = '';
|
||||
if (filtered.length === 0) {
|
||||
tbody.innerHTML = `<tr><td colspan="8" class="text-center" style="padding: 3rem; color: var(--text-muted);">${UI_TEXT.MESSAGES.NO_DATA}</td></tr>`;
|
||||
@@ -107,6 +113,11 @@ export function renderStorageList(container: HTMLElement) {
|
||||
tr.addEventListener('click', () => openHwModal(asset, 'view'));
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
setupTableSorting(table, sortState, (key, dir) => {
|
||||
sortState = { key, direction: dir };
|
||||
updateTable();
|
||||
});
|
||||
};
|
||||
|
||||
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
|
||||
|
||||
Reference in New Issue
Block a user