UNPKG

@memberjunction/ng-shared

Version:

MemberJunction: MJ Explorer Angular Shared Package - utility functions and other reusable elements used across other MJ Angular packages within the MJ Explorer App - do not use outside of MJ Explorer.

163 lines 7.54 kB
import { OnDestroy } from '@angular/core'; import { WorkspaceStateManager, NavItem, ApplicationManager } from '@memberjunction/ng-base-application'; import { NavigationOptions } from './navigation.interfaces'; import { CompositeKey } from '@memberjunction/core'; import * as i0 from "@angular/core"; /** * System application ID for non-app-specific resources (fallback only) * Uses double underscore prefix to indicate system-level resource * @deprecated Prefer using NavigationService.getDefaultApplicationId() instead */ export declare const SYSTEM_APP_ID = "__explorer"; /** * Centralized navigation service that handles all navigation operations * with automatic shift-key detection for power user workflows */ export declare class NavigationService implements OnDestroy { private workspaceManager; private appManager; private shiftKeyPressed; private subscriptions; /** Cached Home app ID (null means not found, undefined means not checked) */ private _homeAppId; /** Cached Home app color */ private _homeAppColor; constructor(workspaceManager: WorkspaceStateManager, appManager: ApplicationManager); /** * Get the neutral color used for system-wide resources (entities, views, dashboards) * Returns a light neutral gray * @deprecated Use getDefaultAppColor() for better UX with Home app integration */ get ExplorerAppColor(): string; /** * Gets the default application ID for orphan resources. * Priority: Home app > Active app > SYSTEM_APP_ID * * This ensures orphan resources (entity records, dashboards, views opened directly) * are grouped under the Home app instead of being orphaned in the tab system. */ private getDefaultApplicationId; /** * Gets the default app color for orphan resources. * Returns Home app color if available, otherwise neutral gray. */ private getDefaultAppColor; /** * Clears the cached Home app info. * Call this if apps are reloaded or user logs out. */ clearHomeAppCache(): void; ngOnDestroy(): void; /** * Set up global keyboard event listeners to track shift key state */ private setupGlobalShiftKeyDetection; /** * Get current shift key state */ private isShiftPressed; /** * Determine if a new tab should be forced based on options and shift key state */ private shouldForceNewTab; /** * Handle temporary tab preservation when forcing new tabs * Rule: Only ONE tab should be temporary at a time * When shift+clicking to force a new tab, pin the current active tab if it's temporary */ private handleSingleResourceModeTransition; /** * Check if a tab request matches an existing tab's resource */ private isSameResource; /** * Open a navigation item within an app */ OpenNavItem(appId: string, navItem: NavItem, appColor: string, options?: NavigationOptions): string; /** * Open an entity record view * Uses Home app if available, otherwise falls back to active app or system app */ OpenEntityRecord(entityName: string, recordPkey: CompositeKey, options?: NavigationOptions): string; /** * Open a view * Uses Home app if available, otherwise falls back to active app or system app */ OpenView(viewId: string, viewName: string, options?: NavigationOptions): string; /** * Open a dashboard * Uses Home app if available, otherwise falls back to active app or system app */ OpenDashboard(dashboardId: string, dashboardName: string, options?: NavigationOptions): string; /** * Open a report * Uses Home app if available, otherwise falls back to active app or system app */ OpenReport(reportId: string, reportName: string, options?: NavigationOptions): string; /** * Open an artifact * Artifacts are versioned content containers (reports, dashboards, UI components, etc.) * Uses Home app if available, otherwise falls back to active app or system app */ OpenArtifact(artifactId: string, artifactName?: string, options?: NavigationOptions): string; /** * Open a dynamic view * Dynamic views are entity-based views with custom filters, not saved views * Uses Home app if available, otherwise falls back to active app or system app */ OpenDynamicView(entityName: string, extraFilter?: string, options?: NavigationOptions): string; /** * Open a query * Uses Home app if available, otherwise falls back to active app or system app */ OpenQuery(queryId: string, queryName: string, options?: NavigationOptions): string; /** * Open a new entity record creation form * Uses Home app if available, otherwise falls back to active app or system app * @param entityName The name of the entity to create a new record for * @param options Navigation options including optional newRecordValues for pre-populating fields */ OpenNewEntityRecord(entityName: string, options?: NavigationOptions): string; /** * Navigate to a nav item by name within the current or specified application. * Allows passing additional configuration parameters to merge with the nav item's config. * This is useful for cross-resource navigation where a component needs to navigate * to another nav item with specific parameters (e.g., navigate to Conversations with a specific conversationId). * * @param navItemName The label/name of the nav item to navigate to * @param configuration Additional configuration to merge (e.g., conversationId, artifactId) * @param appId Optional app ID (defaults to current active app) * @param options Navigation options * @returns The tab ID if successful, null if nav item not found */ OpenNavItemByName(navItemName: string, configuration?: Record<string, unknown>, appId?: string, options?: NavigationOptions): Promise<string | null>; /** * Switch to an application by ID. * This sets the app as active and either opens a specific nav item or creates a default tab. * If the requested nav item already has an open tab, switches to that tab instead of creating a new one. * @param appId The application ID to switch to * @param navItemName Optional name of a nav item to open within the app. If provided, opens that nav item. */ SwitchToApp(appId: string, navItemName?: string): Promise<void>; /** * Update the query params for the currently active tab. * This updates the tab's configuration and triggers a URL sync via the shell's * workspace configuration subscription. * * Use this instead of directly calling router.navigate() to ensure proper * URL management that respects app-scoped routes. * * @param queryParams Object containing query param key-value pairs. * Use null values to remove a query param. * @example * // Add or update query params * navigationService.UpdateActiveTabQueryParams({ category: 'abc123', dashboard: 'xyz789' }); * * // Remove a query param * navigationService.UpdateActiveTabQueryParams({ category: null }); */ UpdateActiveTabQueryParams(queryParams: Record<string, string | null>): void; static ɵfac: i0.ɵɵFactoryDeclaration<NavigationService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<NavigationService>; } //# sourceMappingURL=navigation.service.d.ts.map