diff --git a/webapp/src/app/modules/institutions/institutions.component.html b/webapp/src/app/modules/institutions/institutions.component.html index 3f9c1230..31f42562 100644 --- a/webapp/src/app/modules/institutions/institutions.component.html +++ b/webapp/src/app/modules/institutions/institutions.component.html @@ -4,6 +4,7 @@ subtitle="Suche nach Hochschulen, Forschungszentren und weiteren Einrichtungen."> (); + private readonly resolverState = inject(ResolverStateService); + readonly loading = computed(() => + this.resolverState.isResolvingInside('/institutions'), + ); + observers: FilterObserver[] = [ { id: 'name', diff --git a/webapp/src/app/modules/projects/projects.component.html b/webapp/src/app/modules/projects/projects.component.html index 8e1f2bcc..5b1ebd87 100644 --- a/webapp/src/app/modules/projects/projects.component.html +++ b/webapp/src/app/modules/projects/projects.component.html @@ -4,6 +4,7 @@ subtitle="Durchsuche geförderte Projekte aus DFG-, EU- und Bundesdatenquellen."> (); + private readonly resolverState = inject(ResolverStateService); + readonly loading = computed(() => + this.resolverState.isResolvingInside('/projects'), + ); + page = computed(() => ({ page: this.fundingProjectPage().page || 0, size: this.fundingProjectPage().size || 10, diff --git a/webapp/src/app/modules/publications/publications.component.html b/webapp/src/app/modules/publications/publications.component.html index b84d5d21..1484323e 100644 --- a/webapp/src/app/modules/publications/publications.component.html +++ b/webapp/src/app/modules/publications/publications.component.html @@ -4,6 +4,7 @@ subtitle="Durchsuche wissenschaftliche Publikationen nach Titel, Autor:innen, Themen oder Institutionen."> + this.resolverState.isResolvingInside('/publications'), + ); workPage = input.required(); selectedAuthorsPage = input.required(); diff --git a/webapp/src/app/modules/topics/topics.component.html b/webapp/src/app/modules/topics/topics.component.html index c22a5496..61581c4b 100644 --- a/webapp/src/app/modules/topics/topics.component.html +++ b/webapp/src/app/modules/topics/topics.component.html @@ -4,6 +4,7 @@ subtitle="Entdecke Forschungsfelder nach Namen, Publikationen und Zitierungen."> (); + private readonly resolverState = inject(ResolverStateService); + readonly loading = computed(() => + this.resolverState.isResolvingInside('/topics'), + ); + observers: FilterObserver[] = [ { id: 'query', diff --git a/webapp/src/app/shared/ui/app-layout/app-layout.component.html b/webapp/src/app/shared/ui/app-layout/app-layout.component.html index 01566c95..b41ef3df 100644 --- a/webapp/src/app/shared/ui/app-layout/app-layout.component.html +++ b/webapp/src/app/shared/ui/app-layout/app-layout.component.html @@ -38,10 +38,16 @@ {{ MENU_ICON }} } - + @if (showBack()) { + + }
@@ -50,7 +56,7 @@ } -
+
@if (resolverState.isResolvingFromOutside('/persons')) { void; + private readonly destroyRef = inject(DestroyRef); + private readonly backNavigation = inject(BackNavigationService); + private readonly scrollService = inject(RouteScrollService); + // Instantiated for its router subscription; keeps document.title in sync. + private readonly pageTitle = inject(PageTitleService); + private readonly contentScroller = + viewChild>('contentScroller'); + private readonly currentPath = signal('/'); + + readonly showBack = computed( + () => !this.backNavigation.isRoot(this.currentPath()), + ); + private readonly sidebarCollapsedStorageKey = 'inse.sidebar.collapsed'; sideNavOpen = false; sideNavCollapsed = this.readSidebarCollapsedState(); @@ -79,11 +103,11 @@ export class AppLayoutComponent implements OnInit, OnDestroy { constructor( public credentialService: CredentialService, public router: Router, - private readonly location: Location, public changeDetector: ChangeDetectorRef, media: MediaMatcher, ) { this.mediaQuery = media.matchMedia('(max-width: 600px)'); + this.currentPath.set(this.pathOf(this.router.url)); this.mediaQueryListener = () => { this.sideNavOpen = !this.mediaQuery.matches; @@ -93,6 +117,29 @@ export class AppLayoutComponent implements OnInit, OnDestroy { changeDetector.detectChanges(); }; + + this.router.events + .pipe( + filter( + (event): event is NavigationEnd => event instanceof NavigationEnd, + ), + takeUntilDestroyed(this.destroyRef), + ) + .subscribe((event) => { + this.currentPath.set(this.pathOf(event.urlAfterRedirects)); + + // On phones the drawer is an overlay; keep it from covering the + // freshly opened page. + if (this.mediaQuery.matches && this.sideNavOpen) { + this.sideNavOpen = false; + this.drawer?.close(); + } + }); + + afterNextRender(() => { + const scroller = this.contentScroller()?.nativeElement; + if (scroller) this.scrollService.attach(scroller); + }); } toggle() { @@ -147,6 +194,10 @@ export class AppLayoutComponent implements OnInit, OnDestroy { } navigateBack() { - this.location.back(); + this.backNavigation.back(); + } + + private pathOf(url: string): string { + return url.split('?')[0].split('#')[0] || '/'; } }