61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
import { Component, computed, inject, input } from '@angular/core';
|
|
import {
|
|
CardSearchComponent,
|
|
Page,
|
|
} from '../../shared/ui/card-search/card-search.component';
|
|
import { AppTopicCardComponent } from '../../shared/ui/app-topic-card/app-topic-card.component';
|
|
import { SortDirection, TopicPageV2, TopicSortBy } from '../../api';
|
|
import { FilterObserver } from '../../shared/ui/selected-filters/selected-filters.component';
|
|
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 { NavigationStateService } from '../../shared/services/navigation-state.service';
|
|
|
|
@Component({
|
|
selector: 'app-topics',
|
|
imports: [CardSearchComponent, AppTopicCardComponent, PageContainerComponent],
|
|
templateUrl: './topics.component.html',
|
|
styleUrl: './topics.component.scss',
|
|
})
|
|
export class TopicsComponent {
|
|
topicPage = input.required<TopicPageV2>();
|
|
|
|
private readonly navigationState = inject(NavigationStateService);
|
|
readonly loading = computed(() =>
|
|
this.navigationState.isResolvingInside('/topics'),
|
|
);
|
|
|
|
observers: FilterObserver[] = [
|
|
{
|
|
id: 'query',
|
|
queryParamKey: topicQueryParamKeys.query,
|
|
icon: SEARCH_ICON,
|
|
removable: true,
|
|
},
|
|
];
|
|
|
|
readonly topicSearchQueryParamKey = topicQueryParamKeys.query;
|
|
readonly topicSortByQueryParamKey = topicQueryParamKeys.sortBy;
|
|
readonly topicSortingDirectionQueryParamKey =
|
|
topicQueryParamKeys.sortDirection;
|
|
|
|
page = computed<Page>(() => ({
|
|
page: this.topicPage().page || 0,
|
|
size: this.topicPage().size || 10,
|
|
total: this.topicPage().total || 0,
|
|
elements: this.topicPage().elements || [],
|
|
}));
|
|
|
|
sortingOptions: SelectorOption[] = [
|
|
{ value: TopicSortBy.DisplayName, display_name: 'Name' },
|
|
{ value: TopicSortBy.WorksCount, display_name: 'Anzahl Publikationen' },
|
|
{ value: TopicSortBy.CitedByCount, display_name: 'Anzahl Zitationen' },
|
|
];
|
|
|
|
sortingDirectionOptions: SelectorOption[] = [
|
|
{ value: SortDirection.Asc, display_name: 'Aufsteigend' },
|
|
{ value: SortDirection.Desc, display_name: 'Absteigend' },
|
|
];
|
|
}
|