Files
smartguide/webapp/src/app/modules/topics/topics.component.ts
T
2026-07-26 12:11:02 +02:00

53 lines
1.9 KiB
TypeScript

import { Component, computed, input } from '@angular/core';
import {
CardSearchComponent,
Page,
} from '../../shared/ui/card-search/card-search.component';
import { MatDividerModule } from '@angular/material/divider';
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';
@Component({
selector: 'app-topics',
imports: [CardSearchComponent, MatDividerModule, AppTopicCardComponent],
templateUrl: './topics.component.html',
styleUrl: './topics.component.scss',
})
export class TopicsComponent {
topicPage = input.required<TopicPageV2>();
observers: FilterObserver[] = [
{
id: 'query',
queryParamKey: topicQueryParamKeys.query,
icon: 'search',
},
];
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' },
];
}