Files
magistr/frontend/admin/js/view-state.js
2026-08-20 00:55:27 +03:00

25 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { escapeHtml } from './utils.js';
export function renderTableLoading(tbody, columns, message = 'Загрузка данных...') {
tbody.innerHTML = `<tr><td colspan="${columns}" class="loading-row"><span class="state-spinner" aria-hidden="true"></span>${escapeHtml(message)}</td></tr>`;
tbody.setAttribute('aria-busy', 'true');
}
export function renderTableEmpty(tbody, columns, message = 'Данных пока нет') {
tbody.innerHTML = `<tr><td colspan="${columns}" class="loading-row view-state-empty">${escapeHtml(message)}</td></tr>`;
tbody.setAttribute('aria-busy', 'false');
}
export function renderTableError(tbody, columns, message, retry) {
tbody.innerHTML = `<tr><td colspan="${columns}" class="loading-row view-state-error">
<span>${escapeHtml(message || 'Не удалось загрузить данные')}</span>
${retry ? '<button type="button" class="btn btn-sm btn-secondary" data-view-retry>Повторить</button>' : ''}
</td></tr>`;
tbody.setAttribute('aria-busy', 'false');
tbody.querySelector('[data-view-retry]')?.addEventListener('click', retry);
}
export function markTableReady(tbody) {
tbody.setAttribute('aria-busy', 'false');
}