Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
63 lines
2.3 KiB
JavaScript
Executable File
63 lines
2.3 KiB
JavaScript
Executable File
/**
|
|
* Server_Side_Flash - Bridge between server-generated flash messages and Flash_Alert display
|
|
*
|
|
* Processes flash_alerts arrays from server (page renders and Ajax responses)
|
|
* and displays them using the Flash_Alert component.
|
|
*
|
|
* Integration points:
|
|
* - Page render: window.rsxapp.flash_alerts populated by bundle renderer
|
|
* - Ajax responses: response.flash_alerts added to Ajax success/error responses
|
|
*
|
|
* Initialization:
|
|
* - Automatically called on framework init hook
|
|
* - Restores persisted queue state from sessionStorage before processing server messages
|
|
*/
|
|
class Server_Side_Flash {
|
|
/**
|
|
* Framework initialization hook
|
|
* Restores queue state and processes server flash messages
|
|
* @private
|
|
*/
|
|
static _on_framework_core_init() {
|
|
console.log('[Server_Side_Flash] Framework init hook called');
|
|
|
|
// Restore any persisted queue state from sessionStorage first
|
|
console.log('[Server_Side_Flash] Calling Flash_Alert._restore_queue_state()');
|
|
Flash_Alert._restore_queue_state();
|
|
|
|
// Then process server-generated flash messages
|
|
const has_server_messages = !!(window.rsxapp && window.rsxapp.flash_alerts);
|
|
console.log('[Server_Side_Flash] Checking for server messages:', {
|
|
has_rsxapp: !!window.rsxapp,
|
|
has_flash_alerts: has_server_messages,
|
|
flash_alerts: window.rsxapp?.flash_alerts
|
|
});
|
|
|
|
if (has_server_messages) {
|
|
console.log('[Server_Side_Flash] Processing server messages');
|
|
Server_Side_Flash.process(window.rsxapp.flash_alerts);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Process an array of flash alert messages
|
|
* @param {Array} flash_alerts - Array of {type: string, message: string} objects
|
|
*/
|
|
static process(flash_alerts) {
|
|
if (!Array.isArray(flash_alerts)) {
|
|
return;
|
|
}
|
|
|
|
flash_alerts.forEach((alert) => {
|
|
const method = alert.type; // 'success', 'error', 'info', 'warning'
|
|
|
|
// Call Flash_Alert method if it exists
|
|
if (Flash_Alert[method] && typeof Flash_Alert[method] === 'function') {
|
|
Flash_Alert[method](alert.message);
|
|
} else {
|
|
console.error('Unknown flash alert type:', alert.type);
|
|
}
|
|
});
|
|
}
|
|
}
|