feat(publications): moved publications table as well as active filters to each own component
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
from enum import StrEnum
|
||||
from typing import List
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from inse.model import Page
|
||||
from inse.models.openalex.work_topic import WorkTopic
|
||||
from inse.models.openalex.work import Work
|
||||
|
||||
|
||||
class WorkSortBy(StrEnum):
|
||||
@@ -15,34 +12,5 @@ class WorkSortBy(StrEnum):
|
||||
CITED_BY_COUNT = "cited_by_count"
|
||||
|
||||
|
||||
class AuthorWorkInstitution(BaseModel):
|
||||
institution_id: str = Field(
|
||||
description="The ID of the institution associated with the work"
|
||||
)
|
||||
institution_name: str = Field(
|
||||
description="The name of the institution associated with the work"
|
||||
)
|
||||
institution_country_code: str = Field(
|
||||
description="The country code of the institution associated with the work"
|
||||
)
|
||||
|
||||
|
||||
class AuthorWork(BaseModel):
|
||||
id: str = Field(description="The ID of the work")
|
||||
title: str = Field(description="The title of the work")
|
||||
type: str = Field(description="The type of the work")
|
||||
publication_year: int = Field(description="The year the work was published")
|
||||
language_code: str = Field(description="The language code of the work")
|
||||
institutions: List[AuthorWorkInstitution] = Field(
|
||||
description="A list of institutions associated with the work"
|
||||
)
|
||||
topics: List[WorkTopic] = Field(
|
||||
description="A list of topics associated with the work"
|
||||
)
|
||||
cited_by_count: int = Field(
|
||||
description="The number of citations the work has received"
|
||||
)
|
||||
|
||||
|
||||
class AuthorWorkPage(Page[AuthorWork]):
|
||||
class WorkPage(Page[Work]):
|
||||
pass
|
||||
|
||||
@@ -4,7 +4,7 @@ from fastapi import APIRouter, Path, Query
|
||||
|
||||
from inse.tags import Tags
|
||||
from inse.model import SortDirection
|
||||
from inse.works.v2.model import AuthorWorkPage, WorkSortBy
|
||||
from inse.works.v2.model import WorkPage, WorkSortBy
|
||||
from inse.models.openalex.work_topic import WorkTopic
|
||||
from inse.models.openalex.institution import Institution
|
||||
|
||||
@@ -52,7 +52,7 @@ async def get_author_works(
|
||||
sort_order: Annotated[
|
||||
SortDirection, Query(description="The order to sort by.")
|
||||
] = SortDirection.DESCENDING,
|
||||
) -> AuthorWorkPage:
|
||||
) -> WorkPage:
|
||||
from inse.works.v2.service import get_author_works
|
||||
|
||||
return await get_author_works(
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import logging
|
||||
from typing import List, Optional, Dict
|
||||
from typing import List, Optional
|
||||
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESIndex, SortDirection
|
||||
from inse.works.v2.model import (
|
||||
AuthorWork,
|
||||
AuthorWorkInstitution,
|
||||
AuthorWorkPage,
|
||||
WorkPage,
|
||||
WorkSortBy,
|
||||
)
|
||||
from inse.models.openalex.work_topic import WorkTopic
|
||||
from inse.models.openalex.institution import Institution
|
||||
from inse.models.openalex.work import Work
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
@@ -27,7 +26,7 @@ async def get_author_works(
|
||||
language_codes: Optional[List[str]] = None,
|
||||
sort_by: WorkSortBy = WorkSortBy.PUBLICATION_YEAR,
|
||||
sort_order: SortDirection = SortDirection.DESCENDING,
|
||||
) -> AuthorWorkPage:
|
||||
) -> WorkPage:
|
||||
|
||||
must = [
|
||||
{
|
||||
@@ -84,6 +83,7 @@ async def get_author_works(
|
||||
"publication_year",
|
||||
"language",
|
||||
"cited_by_count",
|
||||
"authorships.author",
|
||||
"authorships.institutions.id",
|
||||
"authorships.institutions.display_name",
|
||||
"authorships.institutions.country_code",
|
||||
@@ -99,36 +99,14 @@ async def get_author_works(
|
||||
hits_block = response.get("hits", {})
|
||||
total = hits_block.get("total", {}).get("value", 0)
|
||||
hits = hits_block.get("hits", [])
|
||||
elements: List[AuthorWork] = []
|
||||
elements: List[Work] = []
|
||||
for hit in hits:
|
||||
source = hit.get("_source", {})
|
||||
logger.debug(f"Hit source for author {raw_oa_author_id} v2: {source}")
|
||||
institutions: Dict[str, AuthorWorkInstitution] = {}
|
||||
for authorship in source.get("authorships", []):
|
||||
for institution in authorship.get("institutions", []):
|
||||
institution_id = institution.get("id", "")
|
||||
if institution_id not in institutions:
|
||||
institutions[institution_id] = AuthorWorkInstitution(
|
||||
institution_id=institution.get("id", ""),
|
||||
institution_name=institution.get("display_name", ""),
|
||||
institution_country_code=institution.get("country_code") or "",
|
||||
)
|
||||
topics: List[WorkTopic] = [
|
||||
WorkTopic.from_dict(topic) for topic in source.get("topics", [])
|
||||
] # type: ignore
|
||||
elements.append(
|
||||
AuthorWork(
|
||||
id=source.get("id", ""),
|
||||
title=source.get("title", ""),
|
||||
type=source.get("type", ""),
|
||||
publication_year=source.get("publication_year", 0),
|
||||
language_code=source.get("language") or "",
|
||||
institutions=list(institutions.values()),
|
||||
topics=topics,
|
||||
cited_by_count=source.get("cited_by_count", 0),
|
||||
)
|
||||
)
|
||||
return AuthorWorkPage(
|
||||
work = Work.from_dict(source) # type: ignore
|
||||
if work is not None:
|
||||
elements.append(work)
|
||||
return WorkPage(
|
||||
elements=elements,
|
||||
total=total,
|
||||
page=page,
|
||||
|
||||
@@ -39,9 +39,6 @@ model/authorNetworkNode.ts
|
||||
model/authorParsedLongestName.ts
|
||||
model/authorPositionCount.ts
|
||||
model/authorSummaryStats.ts
|
||||
model/authorWork.ts
|
||||
model/authorWorkInstitution.ts
|
||||
model/authorWorkPage.ts
|
||||
model/authorWorkPurposes.ts
|
||||
model/authorsFilterProperties.ts
|
||||
model/authorsListResponse.ts
|
||||
@@ -130,7 +127,9 @@ model/hEUWebLink.ts
|
||||
model/hTTPValidationError.ts
|
||||
model/idTokenMetadata.ts
|
||||
model/inseAccountManagementModelOrganizationProfile.ts
|
||||
model/inseModelsOpenalexWorkPageWorkPage.ts
|
||||
model/inseOrganizationManagementModelOrganizationProfile.ts
|
||||
model/inseWorksV2ModelWorkPage.ts
|
||||
model/institution.ts
|
||||
model/institutionFunderSummary.ts
|
||||
model/institutionGeo.ts
|
||||
@@ -228,7 +227,6 @@ model/workIds.ts
|
||||
model/workKeyword.ts
|
||||
model/workMeshInner.ts
|
||||
model/workNetworkNode.ts
|
||||
model/workPage.ts
|
||||
model/workPurpose.ts
|
||||
model/workSortBy.ts
|
||||
model/workSustainableDevelopmentGoalsInner.ts
|
||||
|
||||
@@ -21,6 +21,8 @@ import { AuthorWorkPurposes } from '../model/authorWorkPurposes';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { InseModelsOpenalexWorkPageWorkPage } from '../model/inseModelsOpenalexWorkPageWorkPage';
|
||||
// @ts-ignore
|
||||
import { SpecificWorkPurpose } from '../model/specificWorkPurpose';
|
||||
// @ts-ignore
|
||||
import { TopicCount } from '../model/topicCount';
|
||||
@@ -29,8 +31,6 @@ import { TopicsByTime } from '../model/topicsByTime';
|
||||
// @ts-ignore
|
||||
import { Work } from '../model/work';
|
||||
// @ts-ignore
|
||||
import { WorkPage } from '../model/workPage';
|
||||
// @ts-ignore
|
||||
import { WorksListResponse } from '../model/worksListResponse';
|
||||
|
||||
// @ts-ignore
|
||||
@@ -174,9 +174,9 @@ export class WorksService extends BaseService {
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<WorkPage>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<WorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<WorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InseModelsOpenalexWorkPageWorkPage>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InseModelsOpenalexWorkPageWorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InseModelsOpenalexWorkPageWorkPage>>;
|
||||
public getAuthorWorks(authorId: string, page?: number, size?: number, publicationYear?: Array<number>, type?: Array<string>, language?: Array<string>, institutionId?: Array<string>, topicId?: Array<string>, sort?: 'year' | 'citations', observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (authorId === null || authorId === undefined) {
|
||||
throw new Error('Required parameter authorId was null or undefined when calling getAuthorWorks.');
|
||||
@@ -247,7 +247,7 @@ export class WorksService extends BaseService {
|
||||
|
||||
let localVarPath = `/api/works/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<WorkPage>('get', `${basePath}${localVarPath}`,
|
||||
return this.httpClient.request<InseModelsOpenalexWorkPageWorkPage>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
|
||||
@@ -16,11 +16,11 @@ import { HttpClient, HttpHeaders, HttpParams,
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
// @ts-ignore
|
||||
import { AuthorWorkPage } from '../model/authorWorkPage';
|
||||
// @ts-ignore
|
||||
import { HTTPValidationError } from '../model/hTTPValidationError';
|
||||
// @ts-ignore
|
||||
import { InseWorksV2ModelWorkPage } from '../model/inseWorksV2ModelWorkPage';
|
||||
// @ts-ignore
|
||||
import { Institution } from '../model/institution';
|
||||
// @ts-ignore
|
||||
import { SortDirection } from '../model/sortDirection';
|
||||
@@ -61,9 +61,9 @@ export class WorksV2Service extends BaseService {
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<AuthorWorkPage>;
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<AuthorWorkPage>>;
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<AuthorWorkPage>>;
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<InseWorksV2ModelWorkPage>;
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<InseWorksV2ModelWorkPage>>;
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<InseWorksV2ModelWorkPage>>;
|
||||
public getAuthorWorkPage(rawOaAuthorId: string, page?: number, size?: number, publicationYears?: Array<number>, publicationTypes?: Array<string>, institutionIds?: Array<string>, topicIds?: Array<string>, languageCodes?: Array<string>, sortBy?: WorkSortBy, sortOrder?: SortDirection, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (rawOaAuthorId === null || rawOaAuthorId === undefined) {
|
||||
throw new Error('Required parameter rawOaAuthorId was null or undefined when calling getAuthorWorkPage.');
|
||||
@@ -136,7 +136,7 @@ export class WorksV2Service extends BaseService {
|
||||
|
||||
let localVarPath = `/api/v2/works/${this.configuration.encodeParam({name: "rawOaAuthorId", value: rawOaAuthorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<AuthorWorkPage>('get', `${basePath}${localVarPath}`,
|
||||
return this.httpClient.request<InseWorksV2ModelWorkPage>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { AuthorWorkInstitution } from './authorWorkInstitution';
|
||||
import { WorkTopic } from './workTopic';
|
||||
|
||||
|
||||
export interface AuthorWork {
|
||||
/**
|
||||
* The ID of the work
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The title of the work
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* The type of the work
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* The year the work was published
|
||||
*/
|
||||
publication_year: number;
|
||||
/**
|
||||
* The language code of the work
|
||||
*/
|
||||
language_code: string;
|
||||
/**
|
||||
* A list of institutions associated with the work
|
||||
*/
|
||||
institutions: Array<AuthorWorkInstitution>;
|
||||
/**
|
||||
* A list of topics associated with the work
|
||||
*/
|
||||
topics: Array<WorkTopic>;
|
||||
/**
|
||||
* The number of citations the work has received
|
||||
*/
|
||||
cited_by_count: number;
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Innovation Search Engine API
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface AuthorWorkInstitution {
|
||||
/**
|
||||
* The ID of the institution associated with the work
|
||||
*/
|
||||
institution_id: string;
|
||||
/**
|
||||
* The name of the institution associated with the work
|
||||
*/
|
||||
institution_name: string;
|
||||
/**
|
||||
* The country code of the institution associated with the work
|
||||
*/
|
||||
institution_country_code: string;
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
import { Work } from './work';
|
||||
|
||||
|
||||
export interface WorkPage {
|
||||
export interface InseModelsOpenalexWorkPageWorkPage {
|
||||
/**
|
||||
* Total number of works matching the query
|
||||
*/
|
||||
+3
-3
@@ -7,14 +7,14 @@
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { AuthorWork } from './authorWork';
|
||||
import { Work } from './work';
|
||||
|
||||
|
||||
export interface AuthorWorkPage {
|
||||
export interface InseWorksV2ModelWorkPage {
|
||||
/**
|
||||
* The elements of the page.
|
||||
*/
|
||||
elements?: Array<AuthorWork>;
|
||||
elements?: Array<Work>;
|
||||
/**
|
||||
* The page number. (0-based)
|
||||
*/
|
||||
@@ -11,9 +11,6 @@ export * from './authorNetworkNode';
|
||||
export * from './authorParsedLongestName';
|
||||
export * from './authorPositionCount';
|
||||
export * from './authorSummaryStats';
|
||||
export * from './authorWork';
|
||||
export * from './authorWorkInstitution';
|
||||
export * from './authorWorkPage';
|
||||
export * from './authorWorkPurposes';
|
||||
export * from './authorsFilterProperties';
|
||||
export * from './authorsListResponse';
|
||||
@@ -102,7 +99,9 @@ export * from './hEUWebLink';
|
||||
export * from './hTTPValidationError';
|
||||
export * from './idTokenMetadata';
|
||||
export * from './inseAccountManagementModelOrganizationProfile';
|
||||
export * from './inseModelsOpenalexWorkPageWorkPage';
|
||||
export * from './inseOrganizationManagementModelOrganizationProfile';
|
||||
export * from './inseWorksV2ModelWorkPage';
|
||||
export * from './institution';
|
||||
export * from './institutionFunderSummary';
|
||||
export * from './institutionGeo';
|
||||
@@ -199,7 +198,6 @@ export * from './workIds';
|
||||
export * from './workKeyword';
|
||||
export * from './workMeshInner';
|
||||
export * from './workNetworkNode';
|
||||
export * from './workPage';
|
||||
export * from './workPurpose';
|
||||
export * from './workSortBy';
|
||||
export * from './workSustainableDevelopmentGoalsInner';
|
||||
|
||||
@@ -29,7 +29,10 @@ import { KeywordsToNewsResultsComponent } from './modules/keywords-search/search
|
||||
import { KeywordsToWorksResultsComponent } from './modules/keywords-search/search-results/works-results/works-results.component';
|
||||
import { UniTrendParentComponent } from './modules/university-ranking/uni-trend-parent/uni-trend-parent.component';
|
||||
import { authorWorkPurposesResolver } from './resolvers/author-work-purposes.resolver';
|
||||
import { workPageResolver } from './resolvers/work-page.resolver';
|
||||
import {
|
||||
RESOLVING_WORK_PAGE_FOR,
|
||||
workPageResolver,
|
||||
} from './resolvers/work-page.resolver';
|
||||
import { selectedTopicsResolver } from './resolvers/selected-topics.resolver';
|
||||
import { selectedInstitutionsResolver } from './resolvers/selected-institutions.resolver';
|
||||
import { roleGuard } from './shared/guards/role.guard';
|
||||
@@ -384,6 +387,9 @@ export const routes: Routes = [
|
||||
authorWorkPage: workPageResolver,
|
||||
authorWorkPurposes: authorWorkPurposesResolver,
|
||||
},
|
||||
data: {
|
||||
resolvingFor: RESOLVING_WORK_PAGE_FOR.PERSON,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'network',
|
||||
|
||||
@@ -218,151 +218,13 @@
|
||||
<span>Zurücksetzen</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@if (
|
||||
selectedInstitutionIdsQueryParams().length ||
|
||||
selectedTopicIdsQueryParams().length ||
|
||||
selectedYearsQueryParams().length ||
|
||||
selectedTypesQueryParams().length ||
|
||||
selectedLanguagesQueryParams().length
|
||||
) {
|
||||
<div class="active-filters-row" aria-label="Aktive Filter">
|
||||
<span class="active-filters-label">Aktive Filter:</span>
|
||||
<div class="chips-container">
|
||||
@for (year of selectedYearsQueryParams(); track year) {
|
||||
<span class="active-meta-filter">
|
||||
<span class="filter-meta-chip">
|
||||
<mat-icon class="filter-meta-chip__icon"
|
||||
>calendar_today</mat-icon
|
||||
>
|
||||
<span class="filter-meta-chip__label">{{ year }}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
(click)="toggleYearFilter(year)"
|
||||
[attr.aria-label]="'Jahresfilter ' + year + ' entfernen'">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
@for (type of selectedTypesQueryParams(); track type) {
|
||||
<span class="active-meta-filter">
|
||||
<span class="filter-meta-chip">
|
||||
<mat-icon class="filter-meta-chip__icon">category</mat-icon>
|
||||
<span class="filter-meta-chip__label">{{ type }}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
(click)="toggleTypeFilter(type)"
|
||||
[attr.aria-label]="'Typfilter ' + type + ' entfernen'">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
@for (
|
||||
language of selectedLanguagesQueryParams();
|
||||
track language
|
||||
) {
|
||||
<span class="active-meta-filter">
|
||||
<span class="filter-meta-chip">
|
||||
<mat-icon class="filter-meta-chip__icon"
|
||||
>translate</mat-icon
|
||||
>
|
||||
<span class="filter-meta-chip__label">{{
|
||||
language | languageCode
|
||||
}}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
(click)="toggleLanguageFilter(language)"
|
||||
[attr.aria-label]="
|
||||
'Sprachfilter ' + (language | languageCode) + ' entfernen'
|
||||
">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
@for (topic of selectedTopics(); track topic.id) {
|
||||
<span class="active-meta-filter">
|
||||
<span
|
||||
class="filter-topic-chip"
|
||||
[style.--topic-color]="getWorkTopicColor(topic)"
|
||||
[matTooltip]="getSelectedWorkTopicTooltip(topic)"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="!getSelectedWorkTopicTooltip(topic)">
|
||||
<mat-icon class="filter-topic-chip__icon">label</mat-icon>
|
||||
<span class="filter-topic-chip__label">{{
|
||||
topic.display_name
|
||||
}}</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
(click)="removeTopic(topic)"
|
||||
[attr.aria-label]="
|
||||
'Themenfilter ' + topic.display_name + ' entfernen'
|
||||
">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
@for (
|
||||
institution of selectedInstitutions();
|
||||
track institution.id
|
||||
) {
|
||||
@let instCountry = selectedInstitutionCountry(institution);
|
||||
<span class="active-institution-filter">
|
||||
<span class="filter-institution-chip">
|
||||
<mat-icon class="institution-icon">apartment</mat-icon>
|
||||
<span class="institution-name">{{
|
||||
institution.display_name
|
||||
}}</span>
|
||||
@if (instCountry) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
instCountry.toLowerCase() +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
<span class="country-code">{{
|
||||
instCountry.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
<mat-icon
|
||||
class="institution-open-icon"
|
||||
[routerLink]="[
|
||||
'/institution',
|
||||
extractRawId(institution.id),
|
||||
]"
|
||||
aria-label="Institutionsseite öffnen"
|
||||
>open_in_new</mat-icon
|
||||
>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
(click)="removeInstitution(institution)"
|
||||
aria-label="Institutionsfilter entfernen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<app-data-table
|
||||
[columns]="workColumns"
|
||||
[data]="elements()"
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
<app-selected-filters [observers]="observers" />
|
||||
|
||||
<app-publication-table
|
||||
[page]="authorWorkPage()"
|
||||
[institutionFilterEnabled]="true" />
|
||||
<app-query-param-paginator
|
||||
[total]="totalElements()"
|
||||
queryParamPageKey="page"
|
||||
@@ -371,159 +233,3 @@
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</div>
|
||||
|
||||
<ng-template #titleTmp let-work>
|
||||
<span>{{ work.title }}</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #typeTmp let-work>
|
||||
@if (work.type) {
|
||||
<button
|
||||
type="button"
|
||||
class="type-filter-btn"
|
||||
[class.active]="isTypeActive(work.type)"
|
||||
matTooltip="Nach Typ filtern"
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleTypeFilter(work.type)">
|
||||
<app-chip [color]="typeColor(work.type)">
|
||||
{{ work.type | workType }}
|
||||
</app-chip>
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #yearTmp let-work>
|
||||
@if (work.publication_year) {
|
||||
<button
|
||||
type="button"
|
||||
class="cell-filter-pill"
|
||||
[class.active]="isYearActive(work.publication_year)"
|
||||
matTooltip="Nach Jahr filtern"
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleYearFilter(work.publication_year)">
|
||||
{{ work.publication_year }}
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #languageTmp let-work>
|
||||
@if (work.language) {
|
||||
<button
|
||||
type="button"
|
||||
class="cell-filter-pill"
|
||||
[class.active]="isLanguageActive(work.language_code)"
|
||||
matTooltip="Nach Sprache filtern"
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleLanguageFilter(work.language_code)">
|
||||
{{ work.language_code | languageCode }}
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #institutionsTmp let-work>
|
||||
@let publicationInstitutions = work.institutions ?? [];
|
||||
@let institutionsExpanded = isWorkInstitutionsExpanded(work);
|
||||
@let visibleInstitutions =
|
||||
institutionsExpanded
|
||||
? publicationInstitutions
|
||||
: publicationInstitutions.slice(0, 3);
|
||||
<div
|
||||
class="institution-tags"
|
||||
aria-label="Institutionen"
|
||||
style="padding: 0.5rem 0">
|
||||
@for (
|
||||
institution of visibleInstitutions;
|
||||
track institution.institution_id
|
||||
) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
[class.active]="isInstitutionActive(institution.institution_id!)"
|
||||
[matTooltip]="institution.institution_name"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="
|
||||
'Nach Institution ' + institution.institution_name + ' filtern'
|
||||
"
|
||||
(click)="
|
||||
filterByInstitution({
|
||||
id: institution.institution_id!,
|
||||
name: institution.institution_name || '',
|
||||
})
|
||||
">
|
||||
<mat-icon class="institution-icon">apartment</mat-icon>
|
||||
<span class="institution-name">{{ institution.institution_name }}</span>
|
||||
@if (institution.institution_country_code) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
institution.institution_country_code.toLowerCase() +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
<span class="country-code">{{
|
||||
institution.institution_country_code.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (publicationInstitutions.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="institutionsExpanded"
|
||||
(click)="toggleWorkInstitutionsExpansion(work)">
|
||||
{{
|
||||
institutionsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (publicationInstitutions.length - 3)
|
||||
}}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-work>
|
||||
@let workTopics = work.topics ?? [];
|
||||
<div class="topic-chips" aria-label="Themen" style="padding: 0.5rem 0">
|
||||
@for (topic of workTopics; track topic.id) {
|
||||
<app-topic-chip
|
||||
size="mini"
|
||||
[label]="topic.display_name || ''"
|
||||
[description]="topic.description"
|
||||
[subfieldName]="topic.subfield?.display_name"
|
||||
[fieldName]="topic.field?.display_name"
|
||||
[domainName]="topic.domain?.display_name"
|
||||
[color]="getWorkTopicColor(topic)"
|
||||
[disabled]="!topic.id"
|
||||
[active]="isTopicActive(topic)"
|
||||
(chipClick)="filterByTopic(topic)">
|
||||
</app-topic-chip>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #citationsTmp let-work>
|
||||
{{ work.cited_by_count ?? 0 }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-work>
|
||||
<a
|
||||
mat-icon-button
|
||||
color="primary"
|
||||
[routerLink]="['/publication', extractRawId(work.id)]"
|
||||
matTooltip="Details anzeigen">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
|
||||
@@ -2,12 +2,10 @@ import {
|
||||
Component,
|
||||
DestroyRef,
|
||||
OnInit,
|
||||
TemplateRef,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
@@ -18,7 +16,7 @@ import {
|
||||
} from '@angular/material/autocomplete';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
@@ -37,20 +35,17 @@ import {
|
||||
} from 'rxjs';
|
||||
|
||||
import {
|
||||
AuthorWork,
|
||||
AuthorWorkInstitution,
|
||||
AuthorWorkPage,
|
||||
AuthorWorkPurposes,
|
||||
InseWorksV2ModelWorkPage,
|
||||
Institution,
|
||||
InstitutionsService,
|
||||
SpecificWorkPurpose,
|
||||
Work,
|
||||
WorkPurpose,
|
||||
WorksService,
|
||||
WorkTopic,
|
||||
} from '../../api';
|
||||
import { PaginationService } from '../../shared/services/pagination.service';
|
||||
import { ChipComponent } from '../../shared/ui/chip/chip.component';
|
||||
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { buildTopicHierarchyTooltip } from '../../resolvers/utils/topic-tooltip';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
@@ -64,14 +59,19 @@ import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { GraphChart } from 'echarts/charts';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatExpansionModule } from '@angular/material/expansion';
|
||||
import { translateWorkType } from '../../shared/pipes/work-type.pipe';
|
||||
import {
|
||||
GenericColumn,
|
||||
DataTableComponent,
|
||||
} from '../../shared/ui/data-table/data-table.component';
|
||||
import { WorkTypePipe } from '../../shared/pipes/work-type.pipe';
|
||||
import { LanguageCodePipe } from '../../shared/pipes/language-code.pipe';
|
||||
LanguageCodePipe,
|
||||
translateLanguageCode,
|
||||
} from '../../shared/pipes/language-code.pipe';
|
||||
import { QueryParamPaginatorComponent } from '../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import { AppInfoCardComponent } from '../../shared/ui/app-info-card/app-info-card.component';
|
||||
import { PublicationTableComponent } from '../../shared/ui/publication-table/publication-table.component';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
import {
|
||||
FilterObserver,
|
||||
SelectedFiltersComponent,
|
||||
} from '../../shared/ui/selected-filters/selected-filters.component';
|
||||
echarts.use([
|
||||
GridComponent,
|
||||
CanvasRenderer,
|
||||
@@ -136,7 +136,6 @@ const PURPOSE_LABELS: Record<
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatAutocompleteModule,
|
||||
ChipComponent,
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
@@ -147,15 +146,14 @@ const PURPOSE_LABELS: Record<
|
||||
MatTooltipModule,
|
||||
ReactiveFormsModule,
|
||||
RouterLink,
|
||||
TopicChipComponent,
|
||||
NgxEchartsDirective,
|
||||
MatCardModule,
|
||||
MatExpansionModule,
|
||||
DataTableComponent,
|
||||
WorkTypePipe,
|
||||
LanguageCodePipe,
|
||||
QueryParamPaginatorComponent,
|
||||
AppInfoCardComponent,
|
||||
PublicationTableComponent,
|
||||
SelectedFiltersComponent,
|
||||
],
|
||||
templateUrl: './person-publications.component.html',
|
||||
styleUrl: './person-publications.component.scss',
|
||||
@@ -165,7 +163,7 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
|
||||
private readonly worksService = inject(WorksService);
|
||||
|
||||
authorWorkPage = input.required<AuthorWorkPage>();
|
||||
authorWorkPage = input.required<InseWorksV2ModelWorkPage>();
|
||||
totalElements = computed(() => this.authorWorkPage().total ?? 0);
|
||||
elements = computed(() => this.authorWorkPage().elements ?? []);
|
||||
|
||||
@@ -210,11 +208,60 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
|
||||
expandedWorkInstitutionsId: string[] = [];
|
||||
|
||||
isWorkInstitutionsExpanded(work: AuthorWork): boolean {
|
||||
observers: FilterObserver[] = [
|
||||
{
|
||||
id: 'types',
|
||||
queryParamKey: workQueryParamKeys.types,
|
||||
icon: 'category',
|
||||
valueFormatter: (value: string) => {
|
||||
return translateWorkType(value) || value;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'years',
|
||||
queryParamKey: workQueryParamKeys.years,
|
||||
icon: 'calendar_today',
|
||||
},
|
||||
|
||||
{
|
||||
id: 'languages',
|
||||
queryParamKey: workQueryParamKeys.language,
|
||||
icon: 'translate',
|
||||
valueFormatter: (value: string) => {
|
||||
return translateLanguageCode(value) || value;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'institutions',
|
||||
queryParamKey: workQueryParamKeys.institutionId,
|
||||
icon: 'apartment',
|
||||
valueFormatter: (value: string) => {
|
||||
const institution = this.selectedInstitutions().find(
|
||||
(inst) => inst.id === value,
|
||||
);
|
||||
return institution ? institution.display_name : value;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'topics',
|
||||
queryParamKey: workQueryParamKeys.topicId,
|
||||
icon: 'label',
|
||||
valueFormatter: (value: string) => {
|
||||
const topic = this.selectedTopics().find((t) => t.id === value);
|
||||
return topic ? topic.display_name : value;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
isWorkInstitutionsExpanded(work: Work): boolean {
|
||||
if (!work.id) return false;
|
||||
|
||||
return this.expandedWorkInstitutionsId.includes(work.id);
|
||||
}
|
||||
|
||||
toggleWorkInstitutionsExpansion(work: AuthorWork): void {
|
||||
toggleWorkInstitutionsExpansion(work: Work): void {
|
||||
if (!work.id) return;
|
||||
|
||||
if (this.expandedWorkInstitutionsId.includes(work.id)) {
|
||||
this.expandedWorkInstitutionsId = this.expandedWorkInstitutionsId.filter(
|
||||
(id) => id !== work.id,
|
||||
@@ -239,16 +286,6 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
|
||||
chartOption!: echarts.EChartsCoreOption;
|
||||
|
||||
workColumns: GenericColumn<AuthorWork>[] = [];
|
||||
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
|
||||
typeTmp = viewChild.required<TemplateRef<any>>('typeTmp');
|
||||
yearTmp = viewChild.required<TemplateRef<any>>('yearTmp');
|
||||
languageTmp = viewChild.required<TemplateRef<any>>('languageTmp');
|
||||
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
|
||||
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
|
||||
citationsTmp = viewChild.required<TemplateRef<any>>('citationsTmp');
|
||||
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
|
||||
|
||||
institutionLookupLoading = false;
|
||||
topicLookupLoading = false;
|
||||
institutionOptions: InstitutionAutocompleteOption[] = [];
|
||||
@@ -267,21 +304,6 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
|
||||
readonly publicationYearOptions = this.createPublicationYearOptions();
|
||||
|
||||
private readonly queryParamKeys = {
|
||||
page: 'page',
|
||||
pageSize: 'size',
|
||||
years: 'publicationYear',
|
||||
types: 'publicationType',
|
||||
languages: 'publicationLanguage',
|
||||
institutionIds: 'publicationInstitutionId',
|
||||
institutionNames: 'publicationInstitutionName',
|
||||
topicIds: 'publicationTopicId',
|
||||
topicNames: 'publicationTopicName',
|
||||
topicFields: 'publicationTopicField',
|
||||
topicDomains: 'publicationTopicDomain',
|
||||
sort: 'publicationSort',
|
||||
} as const;
|
||||
|
||||
readonly typeOptions = [
|
||||
{ value: 'article', label: 'article' },
|
||||
{ value: 'book', label: 'book' },
|
||||
@@ -314,7 +336,6 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
private readonly router: Router,
|
||||
private readonly httpClient: HttpClient,
|
||||
public readonly paginationService: PaginationService,
|
||||
private readonly snackBar: MatSnackBar,
|
||||
private readonly institutionsService: InstitutionsService,
|
||||
) {
|
||||
effect(() => {
|
||||
@@ -330,28 +351,28 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
});
|
||||
|
||||
selectedYearsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.years).map(Number);
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.years).map(Number);
|
||||
});
|
||||
|
||||
handleYearSelectionChange(event: MatSelectChange): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.years]: event.value,
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.years]: event.value,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
selectedTypesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.types);
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.types);
|
||||
});
|
||||
|
||||
handleTypeSelectionChange(event: MatSelectChange): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.types]: event.value,
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.types]: event.value,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -359,15 +380,19 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
}
|
||||
|
||||
selectedLanguagesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.languages);
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.language);
|
||||
});
|
||||
|
||||
resolvedInstitutions = computed(() => {
|
||||
const institutionMap = new Map<string, AuthorWorkInstitution>();
|
||||
const institutionMap = new Map<string, Institution>();
|
||||
for (const work of this.elements()) {
|
||||
for (const institution of work.institutions ?? []) {
|
||||
if (!institutionMap.has(institution.institution_id)) {
|
||||
institutionMap.set(institution.institution_id, institution);
|
||||
for (const authorship of work.authorships ?? []) {
|
||||
for (const institution of authorship.institutions ?? []) {
|
||||
if (!institution.id) continue;
|
||||
|
||||
if (!institutionMap.has(institution.id)) {
|
||||
institutionMap.set(institution.id, institution);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -377,8 +402,8 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
handleLanguageSelectionChange(event: MatSelectChange): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.languages]: event.value,
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.language]: event.value,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -386,11 +411,11 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
}
|
||||
|
||||
selectedInstitutionIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.institutionIds);
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.institutionId);
|
||||
});
|
||||
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(this.queryParamKeys.topicIds);
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.topicId);
|
||||
});
|
||||
|
||||
getAuthorSpecificWorkPurposesByYear(
|
||||
@@ -510,61 +535,6 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.setupInstitutionAutocomplete();
|
||||
this.setupTopicAutocomplete();
|
||||
|
||||
this.workColumns = [
|
||||
{
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'title',
|
||||
cellTemplate: this.titleTmp(),
|
||||
},
|
||||
{
|
||||
id: 'type',
|
||||
header: 'Typ',
|
||||
type: 'accessor',
|
||||
accessorKey: 'type',
|
||||
cellTemplate: this.typeTmp(),
|
||||
},
|
||||
{
|
||||
id: 'publication_year',
|
||||
header: 'Jahr',
|
||||
type: 'accessor',
|
||||
accessorKey: 'publication_year',
|
||||
cellTemplate: this.yearTmp(),
|
||||
},
|
||||
{
|
||||
id: 'language',
|
||||
header: 'Sprache',
|
||||
type: 'display',
|
||||
cellTemplate: this.languageTmp(),
|
||||
},
|
||||
{
|
||||
id: 'institutions',
|
||||
header: 'Institutionen',
|
||||
type: 'display',
|
||||
cellTemplate: this.institutionsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'topics',
|
||||
header: 'Themen',
|
||||
type: 'display',
|
||||
cellTemplate: this.topicsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'cited_by_count',
|
||||
header: 'Zitiert von',
|
||||
type: 'accessor',
|
||||
accessorKey: 'cited_by_count',
|
||||
cellTemplate: this.citationsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: 'Aktionen',
|
||||
type: 'display',
|
||||
cellTemplate: this.actionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
clearFilters(): void {
|
||||
@@ -588,11 +558,11 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (!this.selectedInstitutionIdsQueryParams().includes(institution.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.institutionIds]: [
|
||||
[workQueryParamKeys.institutionId]: [
|
||||
...this.selectedInstitutionIdsQueryParams(),
|
||||
institution.id,
|
||||
],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -602,11 +572,11 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
removeInstitution(institution: InstitutionAutocompleteOption): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.institutionIds]:
|
||||
[workQueryParamKeys.institutionId]:
|
||||
this.selectedInstitutionIdsQueryParams().filter(
|
||||
(id) => id !== institution.id,
|
||||
),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -618,21 +588,21 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (selectedInstitutionIds.includes(institution.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.institutionIds]: selectedInstitutionIds.filter(
|
||||
[workQueryParamKeys.institutionId]: selectedInstitutionIds.filter(
|
||||
(id) => id !== institution.id,
|
||||
),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.institutionIds]: [
|
||||
[workQueryParamKeys.institutionId]: [
|
||||
...selectedInstitutionIds,
|
||||
institution.id,
|
||||
],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -650,12 +620,11 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
const authorWorkPage = this.authorWorkPage();
|
||||
if (!authorWorkPage?.elements) return null;
|
||||
for (const publication of authorWorkPage.elements) {
|
||||
for (const inst of publication.institutions ?? []) {
|
||||
if (
|
||||
institution.id === inst.institution_id &&
|
||||
inst.institution_country_code
|
||||
) {
|
||||
return inst.institution_country_code;
|
||||
for (const authorship of publication.authorships ?? []) {
|
||||
for (const inst of authorship.institutions ?? []) {
|
||||
if (institution.id === inst.id && inst.country_code) {
|
||||
return inst.country_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -667,16 +636,16 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (selectedYears.includes(year)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.years]: selectedYears.filter((y) => y !== year),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.years]: selectedYears.filter((y) => y !== year),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.years]: [...selectedYears, year],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.years]: [...selectedYears, year],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -688,16 +657,16 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (selectedTopics.includes(type)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.types]: selectedTopics.filter((t) => t !== type),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.types]: selectedTopics.filter((t) => t !== type),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.types]: [...selectedTopics, type],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.types]: [...selectedTopics, type],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -709,18 +678,18 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (selectedLanguages.includes(language)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.languages]: selectedLanguages.filter(
|
||||
[workQueryParamKeys.language]: selectedLanguages.filter(
|
||||
(l) => l !== language,
|
||||
),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.languages]: [...selectedLanguages, language],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.language]: [...selectedLanguages, language],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
@@ -749,40 +718,29 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
if (!this.selectedTopicIdsQueryParams().includes(topic.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.topicIds]: [
|
||||
[workQueryParamKeys.topicId]: [
|
||||
...this.selectedTopicIdsQueryParams(),
|
||||
topic.id,
|
||||
],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private fieldNameFromHint(
|
||||
hint: string | null | undefined,
|
||||
): string | undefined {
|
||||
const fieldName = (hint ?? '').split('·')[0]?.trim();
|
||||
return fieldName || undefined;
|
||||
}
|
||||
|
||||
removeTopic(topic: TopicAutocompleteOption): void {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.topicIds]:
|
||||
this.selectedTopicIdsQueryParams().filter((id) => id !== topic.id),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.topicId]: this.selectedTopicIdsQueryParams().filter(
|
||||
(id) => id !== topic.id,
|
||||
),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
|
||||
doiUrl(doi: string | null | undefined): string | null {
|
||||
if (!doi) return null;
|
||||
return doi.startsWith('http') ? doi : `https://doi.org/${doi}`;
|
||||
}
|
||||
|
||||
extractRawId(id: string | null | undefined): string | null {
|
||||
if (!id) return null;
|
||||
return id.split('/').filter(Boolean).pop() ?? null;
|
||||
@@ -809,80 +767,6 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getSelectedTopicTooltip(topic: TopicAutocompleteOption): string {
|
||||
const workTopic = this.findPublicationTopic(topic.id);
|
||||
|
||||
return buildTopicHierarchyTooltip({
|
||||
topicName: topic.display_name,
|
||||
description: workTopic?.description,
|
||||
subfieldName: workTopic?.subfield?.display_name,
|
||||
fieldName: workTopic?.field?.display_name ?? topic.field_name,
|
||||
domainName: workTopic?.domain?.display_name ?? topic.domain_name,
|
||||
});
|
||||
}
|
||||
|
||||
private findPublicationTopic(
|
||||
topicId: string | null | undefined,
|
||||
): WorkTopic | undefined {
|
||||
if (!topicId) return undefined;
|
||||
|
||||
const authorWorkPage = this.authorWorkPage();
|
||||
if (!authorWorkPage?.elements) return undefined;
|
||||
|
||||
for (const publication of authorWorkPage.elements) {
|
||||
const topic = publication.topics?.find((item) => item.id === topicId);
|
||||
if (topic) return topic;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getSelectedTopicColor(topic: TopicAutocompleteOption): string {
|
||||
return topicHierarchyColor({
|
||||
id: topic.id,
|
||||
name: topic.display_name,
|
||||
field_id: topic.field_id,
|
||||
field_name: topic.field_name,
|
||||
domain_id: topic.domain_id,
|
||||
domain_name: topic.domain_name,
|
||||
});
|
||||
}
|
||||
|
||||
isTopicActive(topic: WorkTopic): boolean {
|
||||
return !!topic.id && this.selectedTopicIdsQueryParams().includes(topic.id);
|
||||
}
|
||||
|
||||
filterByTopic(topic: WorkTopic): void {
|
||||
if (!topic.id) return;
|
||||
const selectedTopicIds = this.selectedTopicIdsQueryParams();
|
||||
if (selectedTopicIds.includes(topic.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.topicIds]: selectedTopicIds.filter(
|
||||
(id) => id !== topic.id,
|
||||
),
|
||||
[this.queryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[this.queryParamKeys.topicIds]: [...selectedTopicIds, topic.id],
|
||||
[this.queryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
typeColor(type: string | null | undefined): string {
|
||||
const normalized = (type ?? '').toLowerCase();
|
||||
if (normalized.includes('conference')) return 'success';
|
||||
if (normalized.includes('book')) return 'help';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
yearSelectionSummary(): string {
|
||||
return this.summarizeSelection(this.selectedYearsQueryParams().map(String));
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ export const selectedInstitutionsResolver: ResolveFn<Array<Institution>> = (
|
||||
route,
|
||||
state,
|
||||
) => {
|
||||
const institutionIds = route.queryParamMap.getAll('publicationInstitutionId');
|
||||
const institutionIdQueryParamKey =
|
||||
(route.data['institutionIdQueryParamKey'] as string) || 'institutionId';
|
||||
|
||||
const institutionIds = route.queryParamMap.getAll(institutionIdQueryParamKey);
|
||||
if (institutionIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
console.log('Resolving selected institutions for IDs:', institutionIds);
|
||||
|
||||
return inject(WorksV2Service).getInstitutionsByIds(
|
||||
institutionIds.map((id) => id.trim()).filter((id) => id.length > 0),
|
||||
|
||||
@@ -6,11 +6,13 @@ export const selectedTopicsResolver: ResolveFn<Array<WorkTopic>> = (
|
||||
route,
|
||||
state,
|
||||
) => {
|
||||
const topicIds = route.queryParamMap.getAll('publicationTopicId');
|
||||
const topicIdQueryParamKey =
|
||||
(route.data['topicIdQueryParamKey'] as string) || 'topicId';
|
||||
|
||||
const topicIds = route.queryParamMap.getAll(topicIdQueryParamKey);
|
||||
if (topicIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
console.log('Resolving selected topics for IDs:', topicIds);
|
||||
|
||||
return inject(WorksV2Service).getWorkTopicsByIds(
|
||||
topicIds.map((id) => id.trim()).filter((id) => id.length > 0),
|
||||
|
||||
@@ -1,32 +1,71 @@
|
||||
import { ResolveFn } from '@angular/router';
|
||||
import {
|
||||
AuthorWorkPage,
|
||||
ActivatedRouteSnapshot,
|
||||
ResolveFn,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router';
|
||||
import {
|
||||
InseWorksV2ModelWorkPage,
|
||||
SortDirection,
|
||||
WorkSortBy,
|
||||
WorksV2Service,
|
||||
} from '../api';
|
||||
import { inject } from '@angular/core';
|
||||
|
||||
export const workPageResolver: ResolveFn<AuthorWorkPage> = (route, state) => {
|
||||
const RESOLVING_WORK_PAGE_FOR_KEY = 'resolvingFor';
|
||||
export const RESOLVING_WORK_PAGE_FOR = {
|
||||
PERSON: 'PERSON',
|
||||
INSTITUTION: 'INSTITUTION',
|
||||
} as const;
|
||||
|
||||
export const workQueryParamKeys = {
|
||||
page: 'page',
|
||||
size: 'size',
|
||||
years: 'years',
|
||||
types: 'types',
|
||||
language: 'language',
|
||||
authorId: 'authorId',
|
||||
institutionId: 'institutionId',
|
||||
topicId: 'topicId',
|
||||
sortBy: 'sort_by',
|
||||
sortDirection: 'sort_direction',
|
||||
} as const;
|
||||
|
||||
export const workPageResolver: ResolveFn<InseWorksV2ModelWorkPage> = (
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot,
|
||||
) => {
|
||||
const resolvingFor: (typeof RESOLVING_WORK_PAGE_FOR)[keyof typeof RESOLVING_WORK_PAGE_FOR] =
|
||||
route.data[RESOLVING_WORK_PAGE_FOR_KEY] || RESOLVING_WORK_PAGE_FOR.PERSON;
|
||||
|
||||
console.log(
|
||||
'Resolving work page for',
|
||||
resolvingFor,
|
||||
'with route data:',
|
||||
route.data,
|
||||
);
|
||||
|
||||
const rawOaAuthorId =
|
||||
route.parent?.paramMap.get('id') || route.paramMap.get('id');
|
||||
if (!rawOaAuthorId) {
|
||||
throw new Error('Author ID is required to resolve author work purposes.');
|
||||
}
|
||||
|
||||
const page = Number(route.queryParamMap.get('page')) || 0;
|
||||
const size = Number(route.queryParamMap.get('size')) || 10;
|
||||
const page = Number(route.queryParamMap.get(workQueryParamKeys.page)) || 0;
|
||||
const size = Number(route.queryParamMap.get(workQueryParamKeys.size)) || 10;
|
||||
const publicationYears = route.queryParamMap
|
||||
.getAll('publicationYear')
|
||||
.getAll(workQueryParamKeys.years)
|
||||
.map(Number);
|
||||
const publicationTypes = route.queryParamMap.getAll('publicationType');
|
||||
const institutionIds = route.queryParamMap.getAll('publicationInstitutionId');
|
||||
const topicIds = route.queryParamMap.getAll('publicationTopicId');
|
||||
|
||||
const sortBy: WorkSortBy = (route.queryParamMap.get('sort_by') ||
|
||||
'publication_year') as WorkSortBy;
|
||||
const publicationTypes = route.queryParamMap.getAll(workQueryParamKeys.types);
|
||||
const institutionIds = route.queryParamMap.getAll(
|
||||
workQueryParamKeys.institutionId,
|
||||
);
|
||||
const topicIds = route.queryParamMap.getAll(workQueryParamKeys.topicId);
|
||||
const languages = route.queryParamMap.getAll(workQueryParamKeys.language);
|
||||
const sortBy: WorkSortBy = (route.queryParamMap.get(
|
||||
workQueryParamKeys.sortBy,
|
||||
) || 'publication_year') as WorkSortBy;
|
||||
const sortDirection: SortDirection = (route.queryParamMap.get(
|
||||
'sort_direction',
|
||||
workQueryParamKeys.sortDirection,
|
||||
) || 'desc') as SortDirection;
|
||||
|
||||
return inject(WorksV2Service).getAuthorWorkPage(
|
||||
@@ -37,7 +76,7 @@ export const workPageResolver: ResolveFn<AuthorWorkPage> = (route, state) => {
|
||||
publicationTypes,
|
||||
institutionIds,
|
||||
topicIds,
|
||||
undefined,
|
||||
languages,
|
||||
sortBy,
|
||||
sortDirection,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,64 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
export const translateLanguageCode = (
|
||||
languageCode: string | null | undefined,
|
||||
): string => {
|
||||
switch (languageCode) {
|
||||
case 'en':
|
||||
return 'Englisch';
|
||||
case 'de':
|
||||
return 'Deutsch';
|
||||
case 'fr':
|
||||
return 'Französisch';
|
||||
case 'es':
|
||||
return 'Spanisch';
|
||||
case 'it':
|
||||
return 'Italienisch';
|
||||
case 'pt':
|
||||
return 'Portugiesisch';
|
||||
case 'ru':
|
||||
return 'Russisch';
|
||||
case 'zh':
|
||||
return 'Chinesisch';
|
||||
case 'ja':
|
||||
return 'Japanisch';
|
||||
case 'ar':
|
||||
return 'Arabisch';
|
||||
case 'ko':
|
||||
return 'Koreanisch';
|
||||
case 'nl':
|
||||
return 'Niederländisch';
|
||||
case 'sv':
|
||||
return 'Schwedisch';
|
||||
case 'no':
|
||||
return 'Norwegisch';
|
||||
case 'da':
|
||||
return 'Dänisch';
|
||||
case 'fi':
|
||||
return 'Finnisch';
|
||||
case 'pl':
|
||||
return 'Polnisch';
|
||||
case 'cs':
|
||||
return 'Tschechisch';
|
||||
case 'hu':
|
||||
return 'Ungarisch';
|
||||
case 'tr':
|
||||
return 'Türkisch';
|
||||
case 'el':
|
||||
return 'Griechisch';
|
||||
case 'he':
|
||||
return 'Hebräisch';
|
||||
case 'hi':
|
||||
return 'Hindi';
|
||||
case 'th':
|
||||
return 'Thailändisch';
|
||||
case 'vi':
|
||||
return 'Vietnamesisch';
|
||||
default:
|
||||
return languageCode ?? 'Unbekannte Sprache';
|
||||
}
|
||||
};
|
||||
|
||||
@Pipe({
|
||||
name: 'languageCode',
|
||||
})
|
||||
@@ -8,59 +67,6 @@ export class LanguageCodePipe implements PipeTransform {
|
||||
languageCode: string | null | undefined,
|
||||
...args: unknown[]
|
||||
): string {
|
||||
switch (languageCode) {
|
||||
case 'en':
|
||||
return 'Englisch';
|
||||
case 'de':
|
||||
return 'Deutsch';
|
||||
case 'fr':
|
||||
return 'Französisch';
|
||||
case 'es':
|
||||
return 'Spanisch';
|
||||
case 'it':
|
||||
return 'Italienisch';
|
||||
case 'pt':
|
||||
return 'Portugiesisch';
|
||||
case 'ru':
|
||||
return 'Russisch';
|
||||
case 'zh':
|
||||
return 'Chinesisch';
|
||||
case 'ja':
|
||||
return 'Japanisch';
|
||||
case 'ar':
|
||||
return 'Arabisch';
|
||||
case 'ko':
|
||||
return 'Koreanisch';
|
||||
case 'nl':
|
||||
return 'Niederländisch';
|
||||
case 'sv':
|
||||
return 'Schwedisch';
|
||||
case 'no':
|
||||
return 'Norwegisch';
|
||||
case 'da':
|
||||
return 'Dänisch';
|
||||
case 'fi':
|
||||
return 'Finnisch';
|
||||
case 'pl':
|
||||
return 'Polnisch';
|
||||
case 'cs':
|
||||
return 'Tschechisch';
|
||||
case 'hu':
|
||||
return 'Ungarisch';
|
||||
case 'tr':
|
||||
return 'Türkisch';
|
||||
case 'el':
|
||||
return 'Griechisch';
|
||||
case 'he':
|
||||
return 'Hebräisch';
|
||||
case 'hi':
|
||||
return 'Hindi';
|
||||
case 'th':
|
||||
return 'Thailändisch';
|
||||
case 'vi':
|
||||
return 'Vietnamesisch';
|
||||
default:
|
||||
return languageCode ?? 'Unbekannte Sprache';
|
||||
}
|
||||
return translateLanguageCode(languageCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
export const translateWorkType = (value: string | null | undefined): string => {
|
||||
switch (value) {
|
||||
case 'article':
|
||||
return 'Artikel';
|
||||
case 'book':
|
||||
return 'Buch';
|
||||
case 'book-chapter':
|
||||
return 'Buchkapitel';
|
||||
case 'dataset':
|
||||
return 'Datensatz';
|
||||
case 'dissertation':
|
||||
return 'Dissertation';
|
||||
case 'report':
|
||||
return 'Bericht';
|
||||
case 'preprint':
|
||||
return 'Preprint';
|
||||
default:
|
||||
return value ?? 'Unbekannter Typ';
|
||||
}
|
||||
};
|
||||
|
||||
@Pipe({
|
||||
name: 'workType',
|
||||
})
|
||||
export class WorkTypePipe implements PipeTransform {
|
||||
transform(value: string | null | undefined, ...args: unknown[]): string {
|
||||
switch (value) {
|
||||
case 'article':
|
||||
return 'Artikel';
|
||||
case 'book':
|
||||
return 'Buch';
|
||||
case 'book-chapter':
|
||||
return 'Buchkapitel';
|
||||
case 'dataset':
|
||||
return 'Datensatz';
|
||||
case 'dissertation':
|
||||
return 'Dissertation';
|
||||
case 'report':
|
||||
return 'Bericht';
|
||||
case 'preprint':
|
||||
return 'Preprint';
|
||||
default:
|
||||
return value ?? 'Unbekannter Typ';
|
||||
}
|
||||
return translateWorkType(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
<app-data-table
|
||||
[columns]="columns"
|
||||
[data]="elements()"
|
||||
queryParamSortKey="sort_by"
|
||||
queryParamSortDirectionKey="sort_direction" />
|
||||
|
||||
<ng-template #titleTmp let-work>
|
||||
<span>{{ work.title }}</span>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #typeTmp let-work>
|
||||
@if (work.type) {
|
||||
<button
|
||||
type="button"
|
||||
class="type-filter-btn"
|
||||
[class.active]="isTypeActive(work.type)"
|
||||
matTooltip="Nach Typ filtern"
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleTypeFilter(work.type)">
|
||||
<app-chip [color]="typeColor(work.type)">
|
||||
{{ work.type | workType }}
|
||||
</app-chip>
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #yearTmp let-work>
|
||||
@if (work.publication_year) {
|
||||
<button
|
||||
type="button"
|
||||
class="cell-filter-pill"
|
||||
[class.active]="isYearActive(work.publication_year)"
|
||||
matTooltip="Nach Jahr filtern"
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleYearFilter(work.publication_year)">
|
||||
{{ work.publication_year }}
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #languageTmp let-work>
|
||||
@if (work.language) {
|
||||
<button
|
||||
type="button"
|
||||
class="cell-filter-pill"
|
||||
[class.active]="isLanguageActive(work.language)"
|
||||
matTooltip="Nach Sprache filtern"
|
||||
matTooltipPosition="above"
|
||||
(click)="toggleLanguageFilter(work.language)">
|
||||
{{ work.language | languageCode }}
|
||||
</button>
|
||||
} @else {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #authorsTmp let-work>
|
||||
@let workAuthors = getWorkAuthors(work);
|
||||
@let workAuthorsExpanded = isWorkAuthorsExpanded(work);
|
||||
@let visibleAuthors =
|
||||
workAuthorsExpanded ? workAuthors : workAuthors.slice(0, 3);
|
||||
<div class="author-tags" aria-label="Autoren" style="padding: 0.5rem 0">
|
||||
@for (author of visibleAuthors; track author.id) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
[class.active]="isAuthorActive(author.id!)"
|
||||
[matTooltip]="getAuthorTooltipText(author)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getAuthorTooltipText(author)"
|
||||
(click)="filterByAuthor(author.id!)">
|
||||
<mat-icon class="institution-icon">person</mat-icon>
|
||||
<span class="institution-name">{{ author.display_name }}</span>
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (workAuthors.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="workAuthorsExpanded"
|
||||
(click)="toggleWorkAuthorsExpansion(work)">
|
||||
{{ workAuthorsExpanded ? 'weniger' : '+' + (workAuthors.length - 3) }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #institutionsTmp let-work>
|
||||
@let publicationInstitutions = getWorkInstitutions(work);
|
||||
@let institutionsExpanded = isWorkInstitutionsExpanded(work);
|
||||
@let visibleInstitutions =
|
||||
institutionsExpanded
|
||||
? publicationInstitutions
|
||||
: publicationInstitutions.slice(0, 3);
|
||||
<div
|
||||
class="institution-tags"
|
||||
aria-label="Institutionen"
|
||||
style="padding: 0.5rem 0">
|
||||
@for (institution of visibleInstitutions; track institution.id) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-tag"
|
||||
[class.active]="isInstitutionActive(institution.id!)"
|
||||
[matTooltip]="getInstitutionTooltipText(institution)"
|
||||
matTooltipPosition="above"
|
||||
[attr.aria-label]="getInstitutionTooltipText(institution)"
|
||||
(click)="filterByInstitution(institution)">
|
||||
<mat-icon class="institution-icon">apartment</mat-icon>
|
||||
<span class="institution-name">{{ institution.display_name }}</span>
|
||||
@if (institution.country_code) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
institution.country_code.toLowerCase() +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
<span class="country-code">{{
|
||||
institution.country_code.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
</button>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
@if (publicationInstitutions.length > 3) {
|
||||
<button
|
||||
type="button"
|
||||
class="publication-institution-more"
|
||||
[attr.aria-expanded]="institutionsExpanded"
|
||||
(click)="toggleWorkInstitutionsExpansion(work)">
|
||||
{{
|
||||
institutionsExpanded
|
||||
? 'weniger'
|
||||
: '+' + (publicationInstitutions.length - 3)
|
||||
}}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #topicsTmp let-work>
|
||||
@let workTopics = work.topics ?? [];
|
||||
<div class="topic-chips" aria-label="Themen" style="padding: 0.5rem 0">
|
||||
@for (topic of workTopics; track topic.id) {
|
||||
<app-topic-chip
|
||||
size="mini"
|
||||
[label]="topic.display_name || ''"
|
||||
[description]="topic.description"
|
||||
[subfieldName]="topic.subfield?.display_name"
|
||||
[fieldName]="topic.field?.display_name"
|
||||
[domainName]="topic.domain?.display_name"
|
||||
[color]="getWorkTopicColor(topic)"
|
||||
[disabled]="!topic.id"
|
||||
[active]="isTopicActive(topic)"
|
||||
(chipClick)="filterByTopic(topic)">
|
||||
</app-topic-chip>
|
||||
} @empty {
|
||||
<span class="empty-text">-</span>
|
||||
}
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #citationsTmp let-work>
|
||||
{{ work.cited_by_count ?? 0 }}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #actionsTmp let-work>
|
||||
<a
|
||||
mat-icon-button
|
||||
color="primary"
|
||||
[routerLink]="['/publication', extractRawId(work.id)]"
|
||||
matTooltip="Details anzeigen">
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</ng-template>
|
||||
@@ -0,0 +1,594 @@
|
||||
.page {
|
||||
padding: 28px 32px 42px;
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.publication-filter-stack {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 25px;
|
||||
}
|
||||
|
||||
.publication-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.publication-filters mat-form-field {
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
.publication-filters .institution-filter,
|
||||
.publication-filters .topic-filter {
|
||||
flex: 1 1 200px;
|
||||
width: auto;
|
||||
min-width: 180px;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.publication-filters .sort-field {
|
||||
width: 235px;
|
||||
}
|
||||
|
||||
.publication-filters .reset-filter-btn {
|
||||
min-width: 132px;
|
||||
height: 42px;
|
||||
padding: 0 14px;
|
||||
border-color: #d9e2f0;
|
||||
border-radius: var(--sg-radius-sm);
|
||||
color: var(--sg-text);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.publication-filters .reset-filter-btn mat-icon {
|
||||
margin-right: 6px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-subscript-wrapper {
|
||||
display: none;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-text-field-wrapper {
|
||||
height: 42px;
|
||||
background: var(--sg-surface-soft);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
box-shadow 0.15s;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-focused .mat-mdc-text-field-wrapper {
|
||||
border-color: var(--sg-primary);
|
||||
box-shadow: 0 0 0 2px var(--sg-primary-soft);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-flex {
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-infix {
|
||||
min-height: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mdc-notched-outline__leading,
|
||||
::ng-deep .publication-filters .mdc-notched-outline__notch,
|
||||
::ng-deep .publication-filters .mdc-notched-outline__trailing {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.filter-prefix-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
font-size: 18px;
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-icon-prefix {
|
||||
padding: 0 4px 0 10px;
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-select-value,
|
||||
::ng-deep .publication-filters input.mat-mdc-input-element {
|
||||
color: var(--sg-text);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-select-placeholder,
|
||||
::ng-deep .publication-filters input.mat-mdc-input-element::placeholder {
|
||||
color: var(--sg-text-muted);
|
||||
opacity: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
::ng-deep .publication-filters .mat-mdc-form-field-icon-suffix,
|
||||
::ng-deep .publication-filters .mat-mdc-select-arrow-wrapper {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.active-filters-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding: 8px 16px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.active-filters-label {
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.chips-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.filter-meta-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--sg-border-strong);
|
||||
border-radius: 4px;
|
||||
background: var(--sg-surface-soft);
|
||||
color: var(--sg-text);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.filter-topic-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: min(320px, 46vw);
|
||||
padding: 3px 8px;
|
||||
border-radius: 7px;
|
||||
background: color-mix(in srgb, var(--topic-color) 22%, #ffffff);
|
||||
color: color-mix(in srgb, var(--topic-color) 45%, #07163d);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
box-shadow: inset 0 0 0 1px
|
||||
color-mix(in srgb, var(--topic-color) 45%, transparent);
|
||||
}
|
||||
|
||||
.filter-topic-chip__icon {
|
||||
flex: 0 0 auto;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.active-institution-filter,
|
||||
.active-meta-filter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.filter-institution-chip,
|
||||
.publication-institution-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
border: 1px solid var(--sg-primary-border, var(--sg-border));
|
||||
border-radius: 4px;
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-primary);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.filter-institution-chip {
|
||||
max-width: 340px;
|
||||
}
|
||||
|
||||
.publication-institution-tag {
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--sg-primary);
|
||||
color: #fff;
|
||||
border-color: var(--sg-primary);
|
||||
outline: none;
|
||||
box-shadow:
|
||||
0 0 0 2px var(--sg-background),
|
||||
0 0 0 4px var(--sg-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--sg-primary);
|
||||
box-shadow:
|
||||
0 0 0 1px #ffffff,
|
||||
0 0 0 3px var(--sg-primary);
|
||||
}
|
||||
|
||||
&.active:hover,
|
||||
&.active:focus-visible {
|
||||
background: var(--sg-primary);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-icon,
|
||||
.publication-institution-tag .institution-icon,
|
||||
.filter-meta-chip__icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-right: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.filter-meta-chip__icon {
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-name,
|
||||
.publication-institution-tag .institution-name {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.filter-institution-chip .flag-img,
|
||||
.publication-institution-tag .flag-img {
|
||||
flex-shrink: 0;
|
||||
margin-left: 6px;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.filter-institution-chip .country-code,
|
||||
.publication-institution-tag .country-code {
|
||||
flex-shrink: 0;
|
||||
margin-left: 2px;
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon,
|
||||
.publication-institution-tag .institution-open-icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-left: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.filter-institution-chip:hover .institution-open-icon,
|
||||
.publication-institution-tag:hover .institution-open-icon {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.filter-institution-chip .institution-open-icon:hover,
|
||||
.publication-institution-tag .institution-open-icon:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.filter-meta-chip__label,
|
||||
.filter-topic-chip__label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.active-institution-filter button,
|
||||
.active-meta-filter button {
|
||||
display: flex;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--sg-text-soft);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--sg-text);
|
||||
}
|
||||
}
|
||||
|
||||
.active-institution-filter button mat-icon,
|
||||
.active-meta-filter button mat-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
min-width: 1120px;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 10px;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: inline-block;
|
||||
max-width: 520px;
|
||||
line-height: 1.35;
|
||||
color: var(--sg-text);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.title:hover {
|
||||
color: var(--sg-text);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
table.is-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.table-status {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
min-height: 240px;
|
||||
padding: 32px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
color: rgba(0, 0, 0, 0.54);
|
||||
}
|
||||
|
||||
.cell-filter-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
padding: 3px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 999px;
|
||||
background: #fff;
|
||||
color: var(--sg-text);
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
font-weight: 600;
|
||||
box-shadow:
|
||||
0 0 0 1px #ffffff,
|
||||
0 0 0 3px var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.type-filter-btn {
|
||||
display: inline-flex;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 1px var(--sg-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
box-shadow:
|
||||
0 0 0 1px #ffffff,
|
||||
0 0 0 3px var(--sg-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.topic-chips,
|
||||
.institution-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.topic-chips {
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.institution-tags {
|
||||
align-items: flex-start;
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
.publication-institution-more,
|
||||
.publication-topic-more {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: #fff;
|
||||
color: var(--sg-text-muted);
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
line-height: 1.2;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--sg-primary);
|
||||
color: var(--sg-primary);
|
||||
background: var(--sg-surface-soft);
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
.publication-topic-more {
|
||||
max-width: 180px;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-header-cell {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-row {
|
||||
height: 86px;
|
||||
}
|
||||
|
||||
::ng-deep .mat-mdc-cell {
|
||||
color: var(--sg-text);
|
||||
border-bottom-color: var(--sg-border);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.table-wrap ::ng-deep {
|
||||
.mat-column-type,
|
||||
.mat-column-year,
|
||||
.mat-column-language,
|
||||
.mat-column-citations,
|
||||
.mat-mdc-header-cell {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mat-mdc-cell:not(:last-child),
|
||||
.mat-mdc-header-cell:not(:last-child) {
|
||||
border-right: 1px solid var(--sg-border);
|
||||
}
|
||||
|
||||
.mat-column-institutions,
|
||||
.mat-column-topics {
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
mat-paginator {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 66px;
|
||||
padding: 0 22px 0 28px;
|
||||
border: 0;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.page {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.table-footer {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.publication-filter-stack {
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.publication-filters {
|
||||
justify-content: stretch;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.publication-filters mat-form-field,
|
||||
.publication-filters button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.publication-filters .institution-filter,
|
||||
.publication-filters .topic-filter {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.active-filters-row {
|
||||
align-self: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
mat-expansion-panel {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-none);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
mat-expansion-panel-header {
|
||||
padding: 0 16px;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
mat-panel-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
mat-panel-description {
|
||||
font-size: 14px;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
// ------------------------
|
||||
|
||||
.author-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
align-items: flex-start;
|
||||
max-width: 280px;
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
input,
|
||||
OnInit,
|
||||
TemplateRef,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../data-table/data-table.component';
|
||||
import {
|
||||
DehydratedAuthor,
|
||||
InseWorksV2ModelWorkPage,
|
||||
Institution,
|
||||
Work,
|
||||
WorkTopic,
|
||||
} from '../../../api';
|
||||
import { TopicChipComponent } from '../topic-chip/topic-chip.component';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { ChipComponent } from '../chip/chip.component';
|
||||
import { WorkTypePipe } from '../../pipes/work-type.pipe';
|
||||
import { LanguageCodePipe } from '../../pipes/language-code.pipe';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { workQueryParamKeys } from '../../../resolvers/work-page.resolver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publication-table',
|
||||
imports: [
|
||||
MatIconModule,
|
||||
MatTooltipModule,
|
||||
MatButtonModule,
|
||||
RouterModule,
|
||||
DataTableComponent,
|
||||
TopicChipComponent,
|
||||
ChipComponent,
|
||||
WorkTypePipe,
|
||||
LanguageCodePipe,
|
||||
],
|
||||
templateUrl: './publication-table.component.html',
|
||||
styleUrl: './publication-table.component.scss',
|
||||
})
|
||||
export class PublicationTableComponent implements OnInit {
|
||||
page = input.required<InseWorksV2ModelWorkPage>();
|
||||
authorFilterEnabled = input<boolean>(false);
|
||||
institutionFilterEnabled = input<boolean>(false);
|
||||
|
||||
elements = computed(() => this.page().elements ?? []);
|
||||
|
||||
columns: GenericColumn<Work>[] = [];
|
||||
titleTmp = viewChild.required<TemplateRef<any>>('titleTmp');
|
||||
typeTmp = viewChild.required<TemplateRef<any>>('typeTmp');
|
||||
yearTmp = viewChild.required<TemplateRef<any>>('yearTmp');
|
||||
languageTmp = viewChild.required<TemplateRef<any>>('languageTmp');
|
||||
authorsTmp = viewChild.required<TemplateRef<any>>('authorsTmp');
|
||||
institutionsTmp = viewChild.required<TemplateRef<any>>('institutionsTmp');
|
||||
topicsTmp = viewChild.required<TemplateRef<any>>('topicsTmp');
|
||||
citationsTmp = viewChild.required<TemplateRef<any>>('citationsTmp');
|
||||
actionsTmp = viewChild.required<TemplateRef<any>>('actionsTmp');
|
||||
|
||||
private readonly activatedRoute = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
|
||||
initialValue: this.activatedRoute.snapshot.queryParamMap,
|
||||
});
|
||||
|
||||
selectedYearsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.years).map(Number);
|
||||
});
|
||||
|
||||
selectedTypesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.types);
|
||||
});
|
||||
|
||||
selectedLanguagesQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.language);
|
||||
});
|
||||
|
||||
selectedAuthorIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.authorId);
|
||||
});
|
||||
|
||||
selectedInstitutionIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.institutionId);
|
||||
});
|
||||
|
||||
selectedTopicIdsQueryParams = computed(() => {
|
||||
return this.queryParamMap().getAll(workQueryParamKeys.topicId);
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
this.columns = [
|
||||
{
|
||||
id: 'title',
|
||||
header: 'Titel',
|
||||
type: 'accessor',
|
||||
accessorKey: 'title',
|
||||
cellTemplate: this.titleTmp(),
|
||||
},
|
||||
{
|
||||
id: 'type',
|
||||
header: 'Typ',
|
||||
type: 'accessor',
|
||||
accessorKey: 'type',
|
||||
cellTemplate: this.typeTmp(),
|
||||
},
|
||||
{
|
||||
id: 'publication_year',
|
||||
header: 'Jahr',
|
||||
type: 'accessor',
|
||||
accessorKey: 'publication_year',
|
||||
cellTemplate: this.yearTmp(),
|
||||
},
|
||||
{
|
||||
id: 'language',
|
||||
header: 'Sprache',
|
||||
type: 'accessor',
|
||||
accessorKey: 'language',
|
||||
cellTemplate: this.languageTmp(),
|
||||
},
|
||||
{
|
||||
id: 'authors',
|
||||
header: 'Autoren',
|
||||
type: 'display',
|
||||
cellTemplate: this.authorsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'institutions',
|
||||
header: 'Institutionen',
|
||||
type: 'display',
|
||||
cellTemplate: this.institutionsTmp(),
|
||||
},
|
||||
|
||||
{
|
||||
id: 'topics',
|
||||
header: 'Themen',
|
||||
type: 'display',
|
||||
cellTemplate: this.topicsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'cited_by_count',
|
||||
header: 'Zitiert von',
|
||||
type: 'accessor',
|
||||
accessorKey: 'cited_by_count',
|
||||
cellTemplate: this.citationsTmp(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: 'Aktionen',
|
||||
type: 'display',
|
||||
cellTemplate: this.actionsTmp(),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
isTypeActive(type: string): boolean {
|
||||
return this.selectedTypesQueryParams().includes(type);
|
||||
}
|
||||
|
||||
isAuthorActive(authorId: string): boolean {
|
||||
return (
|
||||
!!authorId &&
|
||||
this.authorFilterEnabled() &&
|
||||
this.selectedAuthorIdsQueryParams().includes(authorId)
|
||||
);
|
||||
}
|
||||
|
||||
toggleTypeFilter(type: string): void {
|
||||
const selectedTopics = this.selectedTypesQueryParams();
|
||||
if (selectedTopics.includes(type)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.types]: selectedTopics.filter((t) => t !== type),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.types]: [...selectedTopics, type],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
typeColor(type: string | null | undefined): string {
|
||||
const normalized = (type ?? '').toLowerCase();
|
||||
if (normalized.includes('conference')) return 'success';
|
||||
if (normalized.includes('book')) return 'help';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
isYearActive(year: number): boolean {
|
||||
return this.selectedYearsQueryParams().includes(year);
|
||||
}
|
||||
|
||||
toggleYearFilter(year: number): void {
|
||||
const selectedYears = this.selectedYearsQueryParams();
|
||||
if (selectedYears.includes(year)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.years]: selectedYears.filter((y) => y !== year),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.years]: [...selectedYears, year],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
isLanguageActive(language: string): boolean {
|
||||
return this.selectedLanguagesQueryParams().includes(language);
|
||||
}
|
||||
|
||||
toggleLanguageFilter(language: string): void {
|
||||
const selectedLanguages = this.selectedLanguagesQueryParams();
|
||||
if (selectedLanguages.includes(language)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.language]: selectedLanguages.filter(
|
||||
(l) => l !== language,
|
||||
),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.language]: [...selectedLanguages, language],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
expandedWorkInstitutionsId: string[] = [];
|
||||
expandedWorkAuthorsId: string[] = [];
|
||||
|
||||
isWorkInstitutionsExpanded(work: Work): boolean {
|
||||
if (!work.id) return false;
|
||||
|
||||
return this.expandedWorkInstitutionsId.includes(work.id);
|
||||
}
|
||||
|
||||
toggleWorkInstitutionsExpansion(work: Work): void {
|
||||
if (!work.id) return;
|
||||
|
||||
if (this.expandedWorkInstitutionsId.includes(work.id)) {
|
||||
this.expandedWorkInstitutionsId = this.expandedWorkInstitutionsId.filter(
|
||||
(id) => id !== work.id,
|
||||
);
|
||||
} else {
|
||||
this.expandedWorkInstitutionsId.push(work.id);
|
||||
}
|
||||
}
|
||||
|
||||
isWorkAuthorsExpanded(work: Work): boolean {
|
||||
if (!work.id) return false;
|
||||
|
||||
return this.expandedWorkAuthorsId.includes(work.id);
|
||||
}
|
||||
|
||||
toggleWorkAuthorsExpansion(work: Work): void {
|
||||
if (!work.id) return;
|
||||
|
||||
if (this.expandedWorkAuthorsId.includes(work.id)) {
|
||||
this.expandedWorkAuthorsId = this.expandedWorkAuthorsId.filter(
|
||||
(id) => id !== work.id,
|
||||
);
|
||||
} else {
|
||||
this.expandedWorkAuthorsId.push(work.id);
|
||||
}
|
||||
}
|
||||
|
||||
isInstitutionActive(id: string): boolean {
|
||||
return !!id && this.selectedInstitutionIdsQueryParams().includes(id);
|
||||
}
|
||||
|
||||
filterByInstitution(institution: Institution): void {
|
||||
if (!institution.id || !this.institutionFilterEnabled()) return;
|
||||
const selectedInstitutionIds = this.selectedInstitutionIdsQueryParams();
|
||||
if (selectedInstitutionIds.includes(institution.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.institutionId]: selectedInstitutionIds.filter(
|
||||
(id) => id !== institution.id,
|
||||
),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.institutionId]: [
|
||||
...selectedInstitutionIds,
|
||||
institution.id,
|
||||
],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
filterByAuthor(authorId: string): void {
|
||||
if (!authorId || !this.authorFilterEnabled()) return;
|
||||
const selectedAuthorIds = this.selectedAuthorIdsQueryParams();
|
||||
if (selectedAuthorIds.includes(authorId)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.authorId]: selectedAuthorIds.filter(
|
||||
(id) => id !== authorId,
|
||||
),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.authorId]: [...selectedAuthorIds, authorId],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getWorkTopicColor(topic: WorkTopic): string {
|
||||
return topicHierarchyColor({
|
||||
id: topic.id,
|
||||
name: topic.display_name,
|
||||
field_id: topic.field?.id,
|
||||
field_name: topic.field?.display_name,
|
||||
domain_id: topic.domain?.id,
|
||||
domain_name: topic.domain?.display_name,
|
||||
});
|
||||
}
|
||||
|
||||
isTopicActive(topic: WorkTopic): boolean {
|
||||
return !!topic.id && this.selectedTopicIdsQueryParams().includes(topic.id);
|
||||
}
|
||||
|
||||
filterByTopic(topic: WorkTopic): void {
|
||||
if (!topic.id) return;
|
||||
const selectedTopicIds = this.selectedTopicIdsQueryParams();
|
||||
if (selectedTopicIds.includes(topic.id)) {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.topicId]: selectedTopicIds.filter(
|
||||
(id) => id !== topic.id,
|
||||
),
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
} else {
|
||||
this.router.navigate([], {
|
||||
queryParams: {
|
||||
[workQueryParamKeys.topicId]: [...selectedTopicIds, topic.id],
|
||||
[workQueryParamKeys.page]: 0,
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
extractRawId(id: string | null | undefined): string | null {
|
||||
if (!id) return null;
|
||||
|
||||
return id.split('/').filter(Boolean).pop() ?? null;
|
||||
}
|
||||
|
||||
getWorkInstitutions(work: Work): Institution[] {
|
||||
const institutions = new Map<string, Institution>();
|
||||
|
||||
for (const authorship of work.authorships ?? []) {
|
||||
if (!authorship.institutions) continue;
|
||||
|
||||
for (const institution of authorship.institutions) {
|
||||
if (!institution.id) continue;
|
||||
institutions.set(institution.id, institution);
|
||||
}
|
||||
}
|
||||
return Array.from(institutions.values());
|
||||
}
|
||||
|
||||
getWorkAuthors(work: Work): DehydratedAuthor[] {
|
||||
return (
|
||||
work.authorships
|
||||
?.map((a) => a.author)
|
||||
.filter((a): a is DehydratedAuthor => !!a) || []
|
||||
);
|
||||
}
|
||||
|
||||
getAuthorTooltipText(author: DehydratedAuthor): string {
|
||||
if (this.authorFilterEnabled()) {
|
||||
return `Nach Autor filtern: ${author.display_name}`;
|
||||
}
|
||||
return `Autor: ${author.display_name}`;
|
||||
}
|
||||
|
||||
getInstitutionTooltipText(institution: Institution): string {
|
||||
if (this.institutionFilterEnabled()) {
|
||||
return `Nach Institution filtern: ${institution.display_name}`;
|
||||
}
|
||||
return `Institution: ${institution.display_name}`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
@if (hasActiveFilters()) {
|
||||
<div class="active-filters-row" aria-label="Aktive Filter">
|
||||
<span class="active-filters-label">Aktive Filter:</span>
|
||||
<div class="chips-container">
|
||||
@for (key of observedQueryParamValuesMap().keys(); track $index) {
|
||||
@let observer = observerMap().get(key)!;
|
||||
|
||||
@let tmp = observerMap().get(key)?.template;
|
||||
@for (value of observedQueryParamValuesMap().get(key); track $index) {
|
||||
<div class="active-meta-filter">
|
||||
@if (tmp) {
|
||||
<ng-container
|
||||
*ngTemplateOutlet="
|
||||
tmp;
|
||||
context: { $implicit: value }
|
||||
"></ng-container>
|
||||
} @else {
|
||||
<div class="filter-meta-chip">
|
||||
@if (observer.icon) {
|
||||
<mat-icon class="filter-meta-chip__icon">{{
|
||||
observer.icon
|
||||
}}</mat-icon>
|
||||
}
|
||||
<span class="filter-meta-chip__label">{{
|
||||
formatValue(observer, value)
|
||||
}}</span>
|
||||
</div>
|
||||
}
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
(click)="_handleRemove(observer, value)">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
.active-filters-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding: 8px 16px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.active-filters-row {
|
||||
align-self: stretch;
|
||||
}
|
||||
}
|
||||
|
||||
.active-filters-label {
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.chips-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.active-meta-filter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.active-meta-filter button {
|
||||
display: flex;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--sg-text-soft);
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: var(--sg-text);
|
||||
}
|
||||
}
|
||||
|
||||
.filter-meta-chip__icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-right: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
|
||||
.filter-meta-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--sg-border-strong);
|
||||
border-radius: 4px;
|
||||
background: var(--sg-surface-soft);
|
||||
color: var(--sg-text);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.filter-meta-chip__label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { Component, computed, input, TemplateRef } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { NgTemplateOutlet } from '@angular/common';
|
||||
|
||||
export interface FilterObserver {
|
||||
id: string;
|
||||
queryParamKey: string;
|
||||
icon?: string;
|
||||
valueFormatter?: (value: string) => string | null | undefined;
|
||||
handleRemove?: (value: string) => void;
|
||||
template?: TemplateRef<any>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-selected-filters',
|
||||
imports: [MatIconModule, MatButtonModule, NgTemplateOutlet],
|
||||
templateUrl: './selected-filters.component.html',
|
||||
styleUrl: './selected-filters.component.scss',
|
||||
})
|
||||
export class SelectedFiltersComponent {
|
||||
observers = input.required<FilterObserver[]>();
|
||||
|
||||
observedQueryParamKeys = computed(() =>
|
||||
this.observers().map((observer) => observer.queryParamKey),
|
||||
);
|
||||
|
||||
observerMap = computed(() => {
|
||||
const map = new Map<string, FilterObserver>();
|
||||
this.observers().forEach((observer) => {
|
||||
map.set(observer.queryParamKey, observer);
|
||||
});
|
||||
return map;
|
||||
});
|
||||
|
||||
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
|
||||
initialValue: this.activatedRoute.snapshot.queryParamMap,
|
||||
});
|
||||
|
||||
observedQueryParamValuesMap = computed(() => {
|
||||
const map = new Map<string, string[]>();
|
||||
this.observedQueryParamKeys().forEach((key) => {
|
||||
const values = this.queryParamMap().getAll(key);
|
||||
if (values.length > 0) {
|
||||
map.set(key, values);
|
||||
}
|
||||
});
|
||||
return map;
|
||||
});
|
||||
|
||||
hasActiveFilters = computed(
|
||||
() => this.observedQueryParamValuesMap().size > 0,
|
||||
);
|
||||
|
||||
constructor(
|
||||
private readonly activatedRoute: ActivatedRoute,
|
||||
private readonly router: Router,
|
||||
) {}
|
||||
|
||||
formatValue(
|
||||
observer: FilterObserver,
|
||||
value: string,
|
||||
): string | null | undefined {
|
||||
if (observer.valueFormatter) {
|
||||
return observer.valueFormatter(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
_handleRemove(observer: FilterObserver, value: string) {
|
||||
if (observer.handleRemove) {
|
||||
observer.handleRemove(value);
|
||||
} else {
|
||||
this.removeFilter(observer.queryParamKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
removeFilter(queryParamKey: string, value: string) {
|
||||
this.router.navigate([], {
|
||||
relativeTo: this.activatedRoute,
|
||||
queryParams: {
|
||||
[queryParamKey]: this.queryParamMap()
|
||||
.getAll(queryParamKey)
|
||||
.filter((v) => v !== value),
|
||||
},
|
||||
queryParamsHandling: 'merge',
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user