Files
duty-teller/webapp/js/ui.js
Nikolay Tatarinov c9cf86a8f6 refactor: restructure web application with modular JavaScript and remove legacy code
- Deleted the `app.js` file and migrated its functionality to a modular structure with multiple JavaScript files for better organization and maintainability.
- Updated `index.html` to reference the new `main.js` module, ensuring proper loading of the application.
- Introduced new utility modules for API requests, authentication, calendar handling, and DOM manipulation to enhance code clarity and separation of concerns.
- Enhanced CSS styles for improved layout and theming consistency across the application.
- Added comprehensive comments and documentation to new modules to facilitate future development and understanding.
2026-02-19 15:24:52 +03:00

62 lines
1.5 KiB
JavaScript

/**
* Screen states: access denied, error, nav enabled.
*/
import {
calendarEl,
dutyListEl,
loadingEl,
errorEl,
accessDeniedEl,
headerEl,
weekdaysEl,
prevBtn,
nextBtn
} from "./dom.js";
/**
* Show access-denied view and hide calendar/list/loading/error.
* @param {string} [serverDetail] - message from API 403 detail (unused; kept for callers)
*/
export function showAccessDenied(serverDetail) {
if (headerEl) headerEl.hidden = true;
if (weekdaysEl) weekdaysEl.hidden = true;
if (calendarEl) calendarEl.hidden = true;
if (dutyListEl) dutyListEl.hidden = true;
if (loadingEl) loadingEl.classList.add("hidden");
if (errorEl) errorEl.hidden = true;
if (accessDeniedEl) accessDeniedEl.hidden = false;
}
/**
* Hide access-denied and show calendar/list/header/weekdays.
*/
export function hideAccessDenied() {
if (accessDeniedEl) accessDeniedEl.hidden = true;
if (headerEl) headerEl.hidden = false;
if (weekdaysEl) weekdaysEl.hidden = false;
if (calendarEl) calendarEl.hidden = false;
if (dutyListEl) dutyListEl.hidden = false;
}
/**
* Show error message and hide loading.
* @param {string} msg - Error text
*/
export function showError(msg) {
if (errorEl) {
errorEl.textContent = msg;
errorEl.hidden = false;
}
if (loadingEl) loadingEl.classList.add("hidden");
}
/**
* Enable or disable prev/next month buttons.
* @param {boolean} enabled
*/
export function setNavEnabled(enabled) {
if (prevBtn) prevBtn.disabled = !enabled;
if (nextBtn) nextBtn.disabled = !enabled;
}