implemented shared components & databinding of legend to buttons
This commit is contained in:
+9
-10
@@ -76,6 +76,9 @@ export class UniTrendChartComponent {
|
||||
// Build series: Line in top grid, growth volume bars and S-Curve in bottom grid
|
||||
trendData.series.forEach((entity, entityIdx) => {
|
||||
const color = getEntityColor(entityIdx);
|
||||
if ((entity as any).visible === false) {
|
||||
return;
|
||||
}
|
||||
const yrTopicData = entity.topic_data[selectedTopic] || [];
|
||||
|
||||
// 1. Add line series for the currently selected topic (placed in Grid 0)
|
||||
@@ -194,6 +197,9 @@ export class UniTrendChartComponent {
|
||||
|
||||
trendData.series.forEach((entity: TrendSeries, entityIdx: number) => {
|
||||
const color = getEntityColor(entityIdx);
|
||||
if ((entity as any).visible === false) {
|
||||
return;
|
||||
}
|
||||
const yrTopicData = entity.topic_data[selectedTopic] || [];
|
||||
|
||||
// Recalculate cumulative sum map for this entity
|
||||
@@ -329,14 +335,7 @@ export class UniTrendChartComponent {
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
right: 10,
|
||||
top: 'middle',
|
||||
type: 'scroll',
|
||||
textStyle: { color: '#4b5563' },
|
||||
formatter: (name: string) => {
|
||||
return name.length > 22 ? name.substring(0, 20) + '...' : name;
|
||||
},
|
||||
show: false,
|
||||
},
|
||||
axisPointer: {
|
||||
link: [{ xAxisIndex: 'all' }],
|
||||
@@ -345,13 +344,13 @@ export class UniTrendChartComponent {
|
||||
grid: [
|
||||
{
|
||||
left: 80,
|
||||
right: 220,
|
||||
right: 50,
|
||||
top: 80,
|
||||
height: 230,
|
||||
},
|
||||
{
|
||||
left: 80,
|
||||
right: 220,
|
||||
right: 50,
|
||||
top: 360,
|
||||
height: 70,
|
||||
},
|
||||
|
||||
+37
-199
@@ -21,162 +21,28 @@
|
||||
</div>
|
||||
|
||||
<!-- Zeitraum-Auswahl -->
|
||||
<div class="control-card">
|
||||
<h3>2. Zeitraum</h3>
|
||||
<div class="year-selectors">
|
||||
<select
|
||||
[ngModel]="startYear()"
|
||||
(ngModelChange)="startYear.set(+$event); updateUrlParams()">
|
||||
@for (y of availableYears; track y) {
|
||||
<option [value]="y" [disabled]="y > endYear()">{{ y }}</option>
|
||||
}
|
||||
</select>
|
||||
<span>bis</span>
|
||||
<select
|
||||
[ngModel]="endYear()"
|
||||
(ngModelChange)="endYear.set(+$event); updateUrlParams()">
|
||||
@for (y of availableYears; track y) {
|
||||
<option [value]="y" [disabled]="y < startYear()">{{ y }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<app-year-range-slider
|
||||
[minYear]="2000"
|
||||
[maxYear]="2026"
|
||||
[(startYear)]="startYear"
|
||||
[(endYear)]="endYear"
|
||||
(startYearChange)="updateUrlParams()"
|
||||
(endYearChange)="updateUrlParams()">
|
||||
</app-year-range-slider>
|
||||
|
||||
<!-- Länder/Kontinente vergleichen -->
|
||||
<div class="control-card">
|
||||
<h3>3. Länder/Kontinente vergleichen</h3>
|
||||
|
||||
<div class="comparison-list">
|
||||
@if (
|
||||
comparisonCountries().length > 0 || comparisonRegions().length > 0
|
||||
) {
|
||||
@for (c of comparisonCountries(); track c.id) {
|
||||
<div class="comparison-item location-item font-country">
|
||||
<span class="item-name" [title]="c.name"
|
||||
><mat-icon>flag</mat-icon> {{ c.name }}</span
|
||||
>
|
||||
<button
|
||||
class="remove-btn"
|
||||
(click)="removeLocation(c.id, 'country')"
|
||||
aria-label="Land entfernen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
@for (r of comparisonRegions(); track r.id) {
|
||||
<div class="comparison-item location-item font-region">
|
||||
<span class="item-name" [title]="r.name"
|
||||
><mat-icon>public</mat-icon> {{ r.name }}</span
|
||||
>
|
||||
<button
|
||||
class="remove-btn"
|
||||
(click)="removeLocation(r.id, 'continent')"
|
||||
aria-label="Kontinent entfernen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="empty-list-info">
|
||||
Keine Länder/Kontinente ausgewählt. Suchen zum Hinzufügen.
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Autocomplete-Suche für Länder/Kontinente -->
|
||||
<div class="autocomplete-search">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Land oder Kontinent suchen..."
|
||||
[value]="locationQuery()"
|
||||
(input)="onLocationSearchChange($any($event.target).value)" />
|
||||
@if (locationSearchResults().length > 0) {
|
||||
<ul class="autocomplete-results">
|
||||
@for (loc of locationSearchResults(); track loc.id) {
|
||||
<li>
|
||||
<button (click)="addLocation(loc)">
|
||||
<span class="name">{{ loc.display_name }}</span>
|
||||
<span class="hint">{{
|
||||
loc.type === 'country' ? 'Land' : 'Kontinent'
|
||||
}}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Einrichtungen vergleichen -->
|
||||
<div class="control-card">
|
||||
<h3>4. Einrichtungen vergleichen</h3>
|
||||
|
||||
@if (primaryInstitutionName()) {
|
||||
<div class="primary-inst-badge">
|
||||
<span class="label">Zugewiesen:</span>
|
||||
<strong class="name">{{ primaryInstitutionName() }}</strong>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="comparison-list">
|
||||
@if (comparisonInstitutions().length > 0) {
|
||||
@for (inst of comparisonInstitutions(); track inst.id) {
|
||||
<div class="comparison-item">
|
||||
<span class="item-name" [title]="inst.name"
|
||||
><mat-icon>apartment</mat-icon> {{ inst.name }}</span
|
||||
>
|
||||
<button
|
||||
class="remove-btn"
|
||||
(click)="removeInstitution(inst.id)"
|
||||
aria-label="Einrichtung aus Vergleich entfernen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="empty-list-info">
|
||||
Keine weiteren Einrichtungen ausgewählt. Suchen zum Hinzufügen.
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="autocomplete-search">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Einrichtung suchen und hinzufügen..."
|
||||
[value]="searchQuery()"
|
||||
(input)="onSearchChange($any($event.target).value)" />
|
||||
@if (searchResults().length > 0) {
|
||||
<ul class="autocomplete-results">
|
||||
@for (result of searchResults(); track result.id) {
|
||||
<li>
|
||||
<button
|
||||
(click)="
|
||||
addInstitution(result.id || '', result.display_name || '')
|
||||
">
|
||||
<span class="name">{{ result.display_name }}</span>
|
||||
<span class="hint">{{
|
||||
result.hint || result.entity_type
|
||||
}}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Änderungen übernehmen / Suche Button -->
|
||||
<div class="search-trend-btn-container">
|
||||
<button
|
||||
class="search-trend-btn"
|
||||
[class.dirty]="isDirty()"
|
||||
[disabled]="isTrendLoading() || selectedTrendTopics().length === 0"
|
||||
(click)="fetchTrendData()">
|
||||
<mat-icon>search</mat-icon>
|
||||
{{ isDirty() ? 'Änderungen übernehmen' : 'Trend suchen' }}
|
||||
</button>
|
||||
</div>
|
||||
<app-location-selector
|
||||
[comparisonCountries]="comparisonCountries()"
|
||||
[comparisonRegions]="comparisonRegions()"
|
||||
[locationQuery]="locationQuery()"
|
||||
[locationSearchResults]="locationSearchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
(addLocation)="addLocation($event)"
|
||||
(removeLocation)="removeLocation($event.id, $event.type)"
|
||||
(searchChange)="onLocationSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)">
|
||||
</app-location-selector>
|
||||
</aside>
|
||||
|
||||
<!-- Rechtes Haupt-Panel: Toggles & Diagramm -->
|
||||
@@ -232,50 +98,22 @@
|
||||
[endYear]="endYear()"></app-uni-trend-chart>
|
||||
</div>
|
||||
|
||||
<!-- Empfehlungen unter dem Diagramm, gebunden an das aktive Thema -->
|
||||
<div class="suggestions-below-card">
|
||||
<h3>
|
||||
Empfohlene Top-Einrichtungen für das Thema: {{ activeChartTopic() }}
|
||||
</h3>
|
||||
<div class="suggestions-grid">
|
||||
@if (isSuggestionsLoading()) {
|
||||
<div class="suggestions-loader">
|
||||
<div class="spinner-small"></div>
|
||||
<span>Empfehlungen werden geladen...</span>
|
||||
</div>
|
||||
} @else {
|
||||
@if (topSuggestions().length === 0) {
|
||||
<p class="no-suggestions-msg">
|
||||
Keine Empfehlungen für dieses Thema gefunden.
|
||||
</p>
|
||||
} @else {
|
||||
<div class="suggestions-flex">
|
||||
@for (item of topSuggestions(); track item.id || '') {
|
||||
<button
|
||||
class="suggestion-item-horizontal"
|
||||
(click)="
|
||||
addInstitution(item.id || '', item.display_name || '')
|
||||
"
|
||||
[disabled]="
|
||||
(item.id
|
||||
? comparisonInstitutions().some((i) => i.id === item.id)
|
||||
: false) || primaryInstitution() === item.id
|
||||
">
|
||||
<mat-icon class="add-icon">add</mat-icon>
|
||||
<div class="info">
|
||||
<strong class="name">{{ item.display_name }}</strong>
|
||||
<span class="meta">
|
||||
{{ item.country_code }} •
|
||||
{{ item.exact_topic_count?.toLocaleString() }}
|
||||
Publikationen
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Unified Institution Search, Compare, & Recommendations -->
|
||||
<app-institution-selector
|
||||
[comparisonInstitutions]="comparisonInstitutions()"
|
||||
[primaryInstitution]="primaryInstitution()"
|
||||
[primaryInstitutionName]="primaryInstitutionName()"
|
||||
[topSuggestions]="topSuggestions()"
|
||||
[isSuggestionsLoading]="isSuggestionsLoading()"
|
||||
[activeChartTopic]="activeChartTopic()"
|
||||
[searchQuery]="searchQuery()"
|
||||
[searchResults]="searchResults()"
|
||||
[getEntityColor]="boundGetEntityColor"
|
||||
[isVisible]="boundIsVisible"
|
||||
(addInstitution)="addInstitution($event.id, $event.name)"
|
||||
(removeInstitution)="removeInstitution($event)"
|
||||
(searchChange)="onSearchChange($event)"
|
||||
(toggleVisibility)="toggleVisibility($event)">
|
||||
</app-institution-selector>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
+10
-428
@@ -31,10 +31,6 @@
|
||||
margin: 0 0 0.75rem 0;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
&.suggestions-card {
|
||||
background: #fafafa;
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox-group {
|
||||
@@ -59,211 +55,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
.comparison-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
max-height: 140px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 0.75rem;
|
||||
|
||||
.empty-list-info {
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
padding: 8px 0;
|
||||
border: 1px dashed #e5e7eb;
|
||||
border-radius: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.comparison-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: #f3f4f6;
|
||||
border: 1px solid #e5e7eb;
|
||||
.empty-list-info {
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
padding: 8px 0;
|
||||
border: 1px dashed #e5e7eb;
|
||||
border-radius: 5px;
|
||||
padding: 0.3rem 0.5rem;
|
||||
|
||||
.item-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 0.75rem;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 210px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.remove-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
padding: 1px 4px;
|
||||
border-radius: 3px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
mat-icon {
|
||||
font-size: 12px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #ef4444;
|
||||
background: #fee2e2;
|
||||
}
|
||||
}
|
||||
|
||||
&.location-item {
|
||||
&.font-country {
|
||||
background: #f0fdf4 !important;
|
||||
border-color: #bbf7d0 !important;
|
||||
.item-name {
|
||||
color: #166534 !important;
|
||||
}
|
||||
}
|
||||
&.font-region {
|
||||
background: #eff6ff !important;
|
||||
border-color: #bfdbfe !important;
|
||||
.item-name {
|
||||
color: #1e40af !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.autocomplete-search {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #d1d5db;
|
||||
font-size: 0.8125rem;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.autocomplete-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 50;
|
||||
background: white;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
margin-top: 3px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
|
||||
li button {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0.5rem 0.75rem;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
&:hover {
|
||||
background: #f3f4f6;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
color: #1f2937;
|
||||
}
|
||||
.hint {
|
||||
font-size: 0.65rem;
|
||||
color: #9ca3af;
|
||||
margin-top: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.suggestions-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
|
||||
.suggestions-loader {
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
padding: 8px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.suggestion-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: white;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
padding: 0.4rem 0.6rem;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover:not([disabled]) {
|
||||
border-color: #3b82f6;
|
||||
background: #f0f9ff;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: #f3f4f6;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-width: 210px;
|
||||
|
||||
.name {
|
||||
font-size: 0.75rem;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.meta {
|
||||
font-size: 0.65rem;
|
||||
color: #9ca3af;
|
||||
margin-top: 1px;
|
||||
}
|
||||
}
|
||||
.add-icon {
|
||||
font-size: 1rem;
|
||||
color: #3b82f6;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.trend-main {
|
||||
@@ -341,40 +139,6 @@
|
||||
padding: 0.6rem 1rem;
|
||||
background: #f9fafb;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
|
||||
button {
|
||||
padding: 0.3rem 0.6rem;
|
||||
border: 1px solid #e5e7eb;
|
||||
background: white;
|
||||
color: #4b5563;
|
||||
border-radius: 5px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #3b82f6;
|
||||
color: #3b82f6;
|
||||
background: #f0f9ff;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #3b82f6;
|
||||
border-color: #3b82f6;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.loader-overlay {
|
||||
@@ -407,193 +171,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.search-trend-btn-container {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 0.5rem 0;
|
||||
}
|
||||
|
||||
.search-trend-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.6rem 1.2rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: 1px solid #3b82f6;
|
||||
background-color: #3b82f6;
|
||||
color: white;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
&:hover:not([disabled]) {
|
||||
background-color: #2563eb;
|
||||
border-color: #2563eb;
|
||||
box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
background-color: #9ca3af;
|
||||
border-color: #9ca3af;
|
||||
}
|
||||
|
||||
&.dirty {
|
||||
animation: pulse-border 2s infinite;
|
||||
background-color: #2563eb;
|
||||
border-color: #1d4ed8;
|
||||
}
|
||||
}
|
||||
|
||||
.year-selectors {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
|
||||
select {
|
||||
flex: 1;
|
||||
padding: 0.4rem;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #d1d5db;
|
||||
font-size: 0.8125rem;
|
||||
background: white;
|
||||
outline: none;
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse-border {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.suggestions-below-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 1.25rem;
|
||||
border: 1px solid #e5e7eb;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
margin-top: 1rem;
|
||||
|
||||
h3 {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
margin: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
.suggestions-loader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: #6b7280;
|
||||
font-size: 0.8125rem;
|
||||
padding: 1rem 0;
|
||||
|
||||
.spinner-small {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 2px solid rgba(59, 130, 246, 0.1);
|
||||
border-radius: 50%;
|
||||
border-top-color: #3b82f6;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
}
|
||||
|
||||
.no-suggestions-msg {
|
||||
font-size: 0.8125rem;
|
||||
color: #6b7280;
|
||||
text-align: center;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.suggestions-flex {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.suggestion-item-horizontal {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
background: #f9fafb;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
padding: 0.6rem 0.8rem;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:hover:not([disabled]) {
|
||||
border-color: #3b82f6;
|
||||
background: #f0f9ff;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: #f3f4f6;
|
||||
}
|
||||
|
||||
.add-icon {
|
||||
color: #3b82f6;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
flex-shrink: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
.name {
|
||||
font-size: 0.8125rem;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-weight: 600;
|
||||
}
|
||||
.meta {
|
||||
font-size: 0.7rem;
|
||||
color: #6b7280;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+138
-48
@@ -35,6 +35,9 @@ import {
|
||||
} from '../../../api';
|
||||
import { TopicChipComponent } from '../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
|
||||
import { YearRangeSliderComponent } from '../../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
import { LocationSelectorComponent } from '../../../shared/ui/location-selector/location-selector.component';
|
||||
import { InstitutionSelectorComponent } from '../../../shared/ui/institution-selector/institution-selector.component';
|
||||
|
||||
export interface CompareItem {
|
||||
id: string;
|
||||
@@ -47,15 +50,14 @@ export interface CompareItem {
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
UniTrendChartComponent,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatSelectModule,
|
||||
MatCheckboxModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatAutocompleteModule,
|
||||
TopicChipComponent,
|
||||
YearRangeSliderComponent,
|
||||
LocationSelectorComponent,
|
||||
InstitutionSelectorComponent,
|
||||
],
|
||||
templateUrl: './uni-trend-parent.component.html',
|
||||
styleUrl: './uni-trend-parent.component.scss',
|
||||
@@ -113,6 +115,58 @@ export class UniTrendParentComponent implements OnInit {
|
||||
// Years array for selects
|
||||
readonly availableYears: number[] = [];
|
||||
|
||||
readonly entityVisibilityMap = signal<Map<string, boolean>>(new Map());
|
||||
|
||||
isVisible(id: string): boolean {
|
||||
return this.entityVisibilityMap().get(id) !== false;
|
||||
}
|
||||
|
||||
toggleVisibility(id: string): void {
|
||||
this.entityVisibilityMap.update((map) => {
|
||||
const newMap = new Map(map);
|
||||
const current = newMap.get(id) !== false;
|
||||
newMap.set(id, !current);
|
||||
return newMap;
|
||||
});
|
||||
}
|
||||
|
||||
getEntityColor(entityId: string): string {
|
||||
const defaultInstId = 'https://openalex.org/I62318514';
|
||||
const primaryId = this.primaryInstitution() || defaultInstId;
|
||||
const insts = this.comparisonInstitutions().map((i) => i.id);
|
||||
const countries = this.comparisonCountries().map((c) => c.id);
|
||||
const regions = this.comparisonRegions().map((r) => r.id);
|
||||
|
||||
const orderedIds = [primaryId, ...insts, ...countries, ...regions];
|
||||
|
||||
const idx = orderedIds.indexOf(entityId);
|
||||
if (idx === -1) return '#9ca3af';
|
||||
|
||||
const entityColors = [
|
||||
'#3b82f6',
|
||||
'#10b981',
|
||||
'#f59e0b',
|
||||
'#ec4899',
|
||||
'#8b5cf6',
|
||||
'#06b6d4',
|
||||
'#6366f1',
|
||||
'#ef4444',
|
||||
'#14b8a6',
|
||||
'#f97316',
|
||||
'#d946ef',
|
||||
'#84cc16',
|
||||
'#22c55e',
|
||||
'#a855f7',
|
||||
'#eab308',
|
||||
'#f43f5e',
|
||||
];
|
||||
|
||||
return entityColors[idx % entityColors.length];
|
||||
}
|
||||
|
||||
readonly boundGetEntityColor = (id: string) => this.getEntityColor(id);
|
||||
readonly boundIsVisible = (id: string) => this.isVisible(id);
|
||||
|
||||
// Computed: filters out items locally if they were removed from list
|
||||
readonly trendResponse = computed(() => {
|
||||
const raw = this.rawTrendResponse();
|
||||
@@ -129,63 +183,46 @@ export class UniTrendParentComponent implements OnInit {
|
||||
);
|
||||
const defaultInstId = 'https://openalex.org/I62318514'.toLowerCase();
|
||||
|
||||
const filteredSeries = raw.series.filter((s: TrendSeries) => {
|
||||
const primaryInstSeries: TrendSeries[] = [];
|
||||
const compInstSeries: TrendSeries[] = [];
|
||||
const countrySeries: TrendSeries[] = [];
|
||||
const regionSeries: TrendSeries[] = [];
|
||||
|
||||
raw.series.forEach((s: TrendSeries) => {
|
||||
const id = s.entity_id.toLowerCase();
|
||||
if (s.entity_type === 'institution') {
|
||||
return id === defaultInstId || currentInstIds.has(id);
|
||||
if (id === defaultInstId) {
|
||||
primaryInstSeries.push(s);
|
||||
} else if (currentInstIds.has(id)) {
|
||||
compInstSeries.push(s);
|
||||
}
|
||||
} else if (s.entity_type === 'country') {
|
||||
return currentCountryIds.has(id);
|
||||
if (currentCountryIds.has(id)) {
|
||||
countrySeries.push(s);
|
||||
}
|
||||
} else if (s.entity_type === 'region') {
|
||||
return currentRegionIds.has(id);
|
||||
if (currentRegionIds.has(id)) {
|
||||
regionSeries.push(s);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
const filteredSeries = [
|
||||
...primaryInstSeries,
|
||||
...compInstSeries,
|
||||
...countrySeries,
|
||||
...regionSeries,
|
||||
].map((s) => ({
|
||||
...s,
|
||||
visible: this.isVisible(s.entity_id),
|
||||
}));
|
||||
|
||||
return {
|
||||
...raw,
|
||||
series: filteredSeries,
|
||||
};
|
||||
});
|
||||
|
||||
// Computed dirty state to enable "Search" button
|
||||
readonly isDirty = computed(() => {
|
||||
const fetchedInsts = this.fetchedInstitutions()
|
||||
.map((i: CompareItem) => i.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
const currentInsts = this.comparisonInstitutions()
|
||||
.map((i: CompareItem) => i.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
if (fetchedInsts !== currentInsts) return true;
|
||||
|
||||
const fetchedC = this.fetchedCountries()
|
||||
.map((c: CompareItem) => c.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
const currentC = this.comparisonCountries()
|
||||
.map((c: CompareItem) => c.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
if (fetchedC !== currentC) return true;
|
||||
|
||||
const fetchedR = this.fetchedRegions()
|
||||
.map((r: CompareItem) => r.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
const currentR = this.comparisonRegions()
|
||||
.map((r: CompareItem) => r.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
if (fetchedR !== currentR) return true;
|
||||
|
||||
const fetchedT = this.fetchedTopics().sort().join(',');
|
||||
const currentT = this.selectedTrendTopics().sort().join(',');
|
||||
if (fetchedT !== currentT) return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
constructor() {
|
||||
// Generate year range from 2000 to current year
|
||||
const currentYear = new Date().getFullYear();
|
||||
@@ -238,6 +275,59 @@ export class UniTrendParentComponent implements OnInit {
|
||||
});
|
||||
});
|
||||
|
||||
// Effect: automatically refetch trend data whenever topics or comparisons change (fully reactive)
|
||||
effect(() => {
|
||||
const topics = this.selectedTrendTopics();
|
||||
const insts = this.comparisonInstitutions();
|
||||
const countries = this.comparisonCountries();
|
||||
const regions = this.comparisonRegions();
|
||||
|
||||
if (topics.length === 0) return;
|
||||
|
||||
const topicsStr = [...topics].sort().join(',');
|
||||
const fetchedT = untracked(() => this.fetchedTopics())
|
||||
.sort()
|
||||
.join(',');
|
||||
|
||||
const instsStr = insts
|
||||
.map((i) => i.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
const fetchedI = untracked(() => this.fetchedInstitutions())
|
||||
.map((i) => i.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
|
||||
const countriesStr = countries
|
||||
.map((c) => c.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
const fetchedC = untracked(() => this.fetchedCountries())
|
||||
.map((c) => c.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
|
||||
const regionsStr = regions
|
||||
.map((r) => r.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
const fetchedR = untracked(() => this.fetchedRegions())
|
||||
.map((r) => r.id)
|
||||
.sort()
|
||||
.join(',');
|
||||
|
||||
if (
|
||||
topicsStr === fetchedT &&
|
||||
instsStr === fetchedI &&
|
||||
countriesStr === fetchedC &&
|
||||
regionsStr === fetchedR
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
untracked(() => this.fetchTrendData());
|
||||
});
|
||||
|
||||
// Handle initialization and synchronization of URL state
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
// Parse institutions serialized as id|name
|
||||
|
||||
Reference in New Issue
Block a user