person-publication: show topic hierarchy tooltip on active filter chip
This commit is contained in:
@@ -235,7 +235,10 @@
|
||||
<span class="active-meta-filter">
|
||||
<span
|
||||
class="filter-topic-chip"
|
||||
[style.--topic-color]="getSelectedTopicColor(topic)">
|
||||
[style.--topic-color]="getSelectedTopicColor(topic)"
|
||||
[matTooltip]="getSelectedTopicTooltip(topic)"
|
||||
matTooltipClass="topic-chip-tooltip"
|
||||
[matTooltipDisabled]="!getSelectedTopicTooltip(topic)">
|
||||
<mat-icon class="filter-topic-chip__icon">label</mat-icon>
|
||||
<span class="filter-topic-chip__label">{{
|
||||
topic.display_name
|
||||
|
||||
@@ -44,6 +44,7 @@ import { createLoadError } from '../../resolvers/utils/errorHandler';
|
||||
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';
|
||||
|
||||
interface InstitutionAutocompleteOption {
|
||||
id?: string | null;
|
||||
@@ -485,6 +486,31 @@ 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;
|
||||
|
||||
for (const publication of this.publications) {
|
||||
const topic = publication.topics?.find((item) => item.id === topicId);
|
||||
if (topic) return topic;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getSelectedTopicColor(topic: TopicAutocompleteOption): string {
|
||||
return topicHierarchyColor({
|
||||
id: topic.id,
|
||||
|
||||
Reference in New Issue
Block a user