standartized resolving state of components
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
subtitle="Suche nach Hochschulen, Forschungszentren und weiteren Einrichtungen.">
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[loading]="loading()"
|
||||
[cardMinWidth]="550"
|
||||
[cardTmp]="cardTmp"
|
||||
[observers]="observers"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { Component, computed, inject, input } from '@angular/core';
|
||||
import { InstitutionPage } from '../../api';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -14,6 +14,7 @@ import { FilterObserver } from '../../shared/ui/selected-filters/selected-filter
|
||||
import { AppInstitutionCardComponent } from '../../shared/ui/app-institution-card/app-institution-card.component';
|
||||
import { SEARCH_ICON } from '../../shared/ui/icons';
|
||||
import { PageContainerComponent } from '../../shared/ui/page-container/page-container.component';
|
||||
import { ResolverStateService } from '../../shared/services/resolver-state.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institutions',
|
||||
@@ -32,6 +33,11 @@ import { PageContainerComponent } from '../../shared/ui/page-container/page-cont
|
||||
export class InstitutionsComponent {
|
||||
institutionPage = input.required<InstitutionPage>();
|
||||
|
||||
private readonly resolverState = inject(ResolverStateService);
|
||||
readonly loading = computed(() =>
|
||||
this.resolverState.isResolvingInside('/institutions'),
|
||||
);
|
||||
|
||||
observers: FilterObserver[] = [
|
||||
{
|
||||
id: 'name',
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
subtitle="Durchsuche geförderte Projekte aus DFG-, EU- und Bundesdatenquellen.">
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[loading]="loading()"
|
||||
[cardTmp]="cardTmp"
|
||||
[additionalFiltersTmp]="additionalFiltersTmp"
|
||||
[cardMinWidth]="380"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, computed, input, signal } from '@angular/core';
|
||||
import { Component, computed, inject, input, signal } from '@angular/core';
|
||||
import { FundingProjectPage, ProjectType } from '../../api';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -16,6 +16,7 @@ import { FilterObserver } from '../../shared/ui/selected-filters/selected-filter
|
||||
import { FilterCardComponent } from '../../shared/ui/filter-card/filter-card.component';
|
||||
import { SEARCH_ICON } from '../../shared/ui/icons';
|
||||
import { PageContainerComponent } from '../../shared/ui/page-container/page-container.component';
|
||||
import { ResolverStateService } from '../../shared/services/resolver-state.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-projects',
|
||||
@@ -36,6 +37,11 @@ import { PageContainerComponent } from '../../shared/ui/page-container/page-cont
|
||||
export class ProjectsComponent {
|
||||
fundingProjectPage = input.required<FundingProjectPage>();
|
||||
|
||||
private readonly resolverState = inject(ResolverStateService);
|
||||
readonly loading = computed(() =>
|
||||
this.resolverState.isResolvingInside('/projects'),
|
||||
);
|
||||
|
||||
page = computed<Page>(() => ({
|
||||
page: this.fundingProjectPage().page || 0,
|
||||
size: this.fundingProjectPage().size || 10,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
subtitle="Durchsuche wissenschaftliche Publikationen nach Titel, Autor:innen, Themen oder Institutionen.">
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[loading]="loading()"
|
||||
[cardMinWidth]="500"
|
||||
[cardTmp]="cardTmp"
|
||||
[additionalFiltersTmp]="additionalFiltersTmp"
|
||||
|
||||
@@ -19,6 +19,7 @@ import { PublicationFilterComponent } from '../../shared/ui/publication-filters/
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
import { PageContainerComponent } from '../../shared/ui/page-container/page-container.component';
|
||||
import { ResolverStateService } from '../../shared/services/resolver-state.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publications',
|
||||
@@ -34,6 +35,11 @@ import { PageContainerComponent } from '../../shared/ui/page-container/page-cont
|
||||
export class PublicationsComponent {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly resolverState = inject(ResolverStateService);
|
||||
|
||||
readonly loading = computed(() =>
|
||||
this.resolverState.isResolvingInside('/publications'),
|
||||
);
|
||||
|
||||
workPage = input.required<WorkPageV2>();
|
||||
selectedAuthorsPage = input.required<AuthorPage>();
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
subtitle="Entdecke Forschungsfelder nach Namen, Publikationen und Zitierungen.">
|
||||
<app-card-search
|
||||
[page]="page()"
|
||||
[loading]="loading()"
|
||||
[cardMinWidth]="550"
|
||||
[cardTmp]="cardTmp"
|
||||
[observers]="observers"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { Component, computed, inject, input } from '@angular/core';
|
||||
import {
|
||||
CardSearchComponent,
|
||||
Page,
|
||||
@@ -10,20 +10,22 @@ import { topicQueryParamKeys } from '../../resolvers/topic-page.resolver';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { SEARCH_ICON } from '../../shared/ui/icons';
|
||||
import { PageContainerComponent } from '../../shared/ui/page-container/page-container.component';
|
||||
import { ResolverStateService } from '../../shared/services/resolver-state.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topics',
|
||||
imports: [
|
||||
CardSearchComponent,
|
||||
AppTopicCardComponent,
|
||||
PageContainerComponent,
|
||||
],
|
||||
imports: [CardSearchComponent, AppTopicCardComponent, PageContainerComponent],
|
||||
templateUrl: './topics.component.html',
|
||||
styleUrl: './topics.component.scss',
|
||||
})
|
||||
export class TopicsComponent {
|
||||
topicPage = input.required<TopicPageV2>();
|
||||
|
||||
private readonly resolverState = inject(ResolverStateService);
|
||||
readonly loading = computed(() =>
|
||||
this.resolverState.isResolvingInside('/topics'),
|
||||
);
|
||||
|
||||
observers: FilterObserver[] = [
|
||||
{
|
||||
id: 'query',
|
||||
|
||||
@@ -38,10 +38,16 @@
|
||||
<mat-icon>{{ MENU_ICON }}</mat-icon>
|
||||
</button>
|
||||
}
|
||||
<button (click)="navigateBack()" class="back-link" type="button">
|
||||
<mat-icon>{{ ARROW_BACK_ICON }}</mat-icon>
|
||||
<span>Zurück</span>
|
||||
</button>
|
||||
@if (showBack()) {
|
||||
<button
|
||||
(click)="navigateBack()"
|
||||
class="back-link"
|
||||
type="button"
|
||||
aria-label="Zurück zur vorherigen Ansicht">
|
||||
<mat-icon>{{ ARROW_BACK_ICON }}</mat-icon>
|
||||
<span>Zurück</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
<app-searchbar />
|
||||
<div class="topbar-actions">
|
||||
@@ -50,7 +56,7 @@
|
||||
</mat-toolbar>
|
||||
}
|
||||
|
||||
<main class="content">
|
||||
<main class="content" #contentScroller>
|
||||
<div class="main-content-body">
|
||||
@if (resolverState.isResolvingFromOutside('/persons')) {
|
||||
<app-loading
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
import {
|
||||
afterNextRender,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
computed,
|
||||
inject,
|
||||
signal,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { CommonModule, Location } from '@angular/common';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatDrawer, MatSidenavModule } from '@angular/material/sidenav';
|
||||
import { Router } from '@angular/router';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { filter } from 'rxjs';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MediaMatcher } from '@angular/cdk/layout';
|
||||
import { AppMenuComponent } from '../app-menu/app-menu.component';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CredentialService } from '../../services/credential.service';
|
||||
import { AppSearchbarComponent } from '../app-searchbar/app-searchbar.component';
|
||||
import { ResolverStateService } from '../../services/resolver-state.service';
|
||||
import { BackNavigationService } from '../../services/back-navigation.service';
|
||||
import { PageTitleService } from '../../services/page-title.service';
|
||||
import { RouteScrollService } from '../../services/route-scroll.service';
|
||||
import { LoadingComponent } from '../loading/loading.component';
|
||||
import {
|
||||
ARROW_BACK_ICON,
|
||||
@@ -72,6 +83,19 @@ export class AppLayoutComponent implements OnInit, OnDestroy {
|
||||
protected resolverState = inject(ResolverStateService);
|
||||
mediaQueryListener: () => 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<ElementRef<HTMLElement>>('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] || '/';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user