added shared institution selector
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
<div class="institution-selector-container">
|
||||
<!-- Left Column: Search & Compared Institutions -->
|
||||
<div class="search-compare-section">
|
||||
<div class="section-header">
|
||||
<h3>Einrichtungen vergleichen</h3>
|
||||
@if (primaryInstitutionName()) {
|
||||
<div class="primary-inst-badge">
|
||||
<span class="label">Zugewiesen:</span>
|
||||
<strong class="name">{{ primaryInstitutionName() }}</strong>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Autocomplete Search Input -->
|
||||
<div class="autocomplete-search">
|
||||
<mat-icon class="search-icon">search</mat-icon>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Einrichtung suchen und hinzufügen..."
|
||||
[value]="searchQuery()"
|
||||
(input)="onSearchInput($event)" />
|
||||
|
||||
@if (searchResults().length > 0) {
|
||||
<ul class="autocomplete-results">
|
||||
@for (result of searchResults(); track result.id) {
|
||||
<li>
|
||||
<button (click)="onSelectResult(result)">
|
||||
<span class="name">{{ result.display_name }}</span>
|
||||
<span class="hint">{{
|
||||
result.hint || result.entity_type
|
||||
}}</span>
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- List of Compared Institutions -->
|
||||
<div class="comparison-list">
|
||||
@if (comparisonInstitutions().length > 0) {
|
||||
<div class="chips-flex">
|
||||
@for (inst of comparisonInstitutions(); track inst.id) {
|
||||
<div
|
||||
class="comparison-item"
|
||||
[style.border-color]="getEntityColor()(inst.id)"
|
||||
[style.background]="
|
||||
'color-mix(in srgb, ' +
|
||||
getEntityColor()(inst.id) +
|
||||
' 8%, #ffffff)'
|
||||
"
|
||||
[style.color]="getEntityColor()(inst.id)">
|
||||
<span class="item-name" [title]="inst.name">
|
||||
<mat-icon>apartment</mat-icon> {{ inst.name }}
|
||||
</span>
|
||||
<div class="item-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn visibility-btn"
|
||||
(click)="onToggleVisibility(inst.id)"
|
||||
[style.color]="getEntityColor()(inst.id)"
|
||||
[title]="
|
||||
isVisible()(inst.id)
|
||||
? 'In Visualisierung ausblenden'
|
||||
: 'In Visualisierung einblenden'
|
||||
">
|
||||
<mat-icon>{{
|
||||
isVisible()(inst.id) ? 'visibility' : 'visibility_off'
|
||||
}}</mat-icon>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn remove-btn"
|
||||
(click)="onRemove(inst.id)"
|
||||
[style.color]="getEntityColor()(inst.id)"
|
||||
aria-label="Einrichtung entfernen">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="empty-list-info">
|
||||
Keine weiteren Einrichtungen ausgewählt. Suchen zum Hinzufügen.
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right Column: Recommendations -->
|
||||
<div class="recommendations-section">
|
||||
<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
|
||||
type="button"
|
||||
class="suggestion-item-horizontal"
|
||||
(click)="onSelectSuggestion(item)"
|
||||
[disabled]="isAlreadyAdded(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>
|
||||
</div>
|
||||
@@ -0,0 +1,340 @@
|
||||
.institution-selector-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.5fr;
|
||||
gap: 24px;
|
||||
background: white;
|
||||
border: 1px solid #d7e4ff;
|
||||
border-radius: 16px;
|
||||
padding: 24px;
|
||||
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
box-sizing: border-box;
|
||||
margin-top: 20px;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 20px;
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.search-compare-section,
|
||||
.recommendations-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
|
||||
h3 {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 700;
|
||||
color: #07163d;
|
||||
margin: 0 0 1rem 0;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
h3 {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.primary-inst-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: #f0fdf4;
|
||||
border: 1px solid #bbf7d0;
|
||||
padding: 3px 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 0.7rem;
|
||||
|
||||
.label {
|
||||
color: #166534;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.name {
|
||||
color: #15803d;
|
||||
}
|
||||
}
|
||||
|
||||
/* Autocomplete Search input */
|
||||
.autocomplete-search {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
|
||||
.search-icon {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
color: #9ca3af;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 100%;
|
||||
padding: 0.6rem 0.6rem 0.6rem 2.2rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #d1d5db;
|
||||
font-size: 0.8125rem;
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.autocomplete-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 50;
|
||||
background: white;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
||||
margin-top: 4px;
|
||||
padding: 4px 0;
|
||||
list-style: none;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
|
||||
li button {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0.6rem 1rem;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: #f3f4f6;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
}
|
||||
.hint {
|
||||
font-size: 0.65rem;
|
||||
color: #6b7280;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Comparison list & chips */
|
||||
.comparison-list {
|
||||
flex: 1;
|
||||
min-height: 80px;
|
||||
|
||||
.empty-list-info {
|
||||
font-size: 0.75rem;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
padding: 16px;
|
||||
border: 1px dashed #e5e7eb;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.chips-flex {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.comparison-item {
|
||||
display: inline-flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
padding: 0.35rem 0.6rem;
|
||||
gap: 8px;
|
||||
transition: all 0.2s ease;
|
||||
max-width: 100%;
|
||||
|
||||
.item-name {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 180px;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.item-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 2px;
|
||||
border-radius: 4px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.15s ease;
|
||||
|
||||
mat-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
&.remove-btn:hover {
|
||||
color: #ef4444 !important;
|
||||
background: #fee2e2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Recommendations suggestions section */
|
||||
.suggestions-grid {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.suggestions-flex {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
max-height: 250px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
|
||||
@media (max-width: 600px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.suggestion-item-horizontal {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
background: #f9fafb;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
box-sizing: border-box;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #f3f4f6;
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
background: #f3f4f6;
|
||||
}
|
||||
|
||||
.add-icon {
|
||||
color: #3b82f6;
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
|
||||
.name {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.meta {
|
||||
font-size: 0.65rem;
|
||||
color: #6b7280;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.no-suggestions-msg {
|
||||
font-size: 0.75rem;
|
||||
color: #6b7280;
|
||||
margin: 12px 0 0 0;
|
||||
}
|
||||
|
||||
.suggestions-loader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 0.75rem;
|
||||
color: #6b7280;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.spinner-small {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border: 2px solid #e5e7eb;
|
||||
border-top: 2px solid #3b82f6;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import { Component, input, output } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
export interface CompareItem {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution-selector',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatIconModule],
|
||||
templateUrl: './institution-selector.component.html',
|
||||
styleUrl: './institution-selector.component.scss',
|
||||
})
|
||||
export class InstitutionSelectorComponent {
|
||||
readonly comparisonInstitutions = input<CompareItem[]>([]);
|
||||
readonly primaryInstitution = input<string | null>(null);
|
||||
readonly primaryInstitutionName = input<string | null>(null);
|
||||
readonly topSuggestions = input<any[]>([]);
|
||||
readonly isSuggestionsLoading = input<boolean>(false);
|
||||
readonly activeChartTopic = input<string>('');
|
||||
readonly searchQuery = input<string>('');
|
||||
readonly searchResults = input<any[]>([]);
|
||||
readonly getEntityColor = input<(id: string) => string>(() => '#9ca3af');
|
||||
readonly isVisible = input<(id: string) => boolean>(() => true);
|
||||
|
||||
readonly addInstitution = output<{ id: string; name: string }>();
|
||||
readonly removeInstitution = output<string>();
|
||||
readonly searchChange = output<string>();
|
||||
readonly toggleVisibility = output<string>();
|
||||
|
||||
onSearchInput(event: Event): void {
|
||||
const val = (event.target as HTMLInputElement).value;
|
||||
this.searchChange.emit(val);
|
||||
}
|
||||
|
||||
onSelectResult(result: any): void {
|
||||
this.addInstitution.emit({
|
||||
id: result.id || '',
|
||||
name: result.display_name || '',
|
||||
});
|
||||
}
|
||||
|
||||
onSelectSuggestion(item: any): void {
|
||||
this.addInstitution.emit({
|
||||
id: item.id || '',
|
||||
name: item.display_name || '',
|
||||
});
|
||||
}
|
||||
|
||||
onRemove(id: string): void {
|
||||
this.removeInstitution.emit(id);
|
||||
}
|
||||
|
||||
onToggleVisibility(id: string): void {
|
||||
this.toggleVisibility.emit(id);
|
||||
}
|
||||
|
||||
isAlreadyAdded(id: string | undefined): boolean {
|
||||
if (!id) return false;
|
||||
const isPrimary = this.primaryInstitution() === id;
|
||||
const isComp = this.comparisonInstitutions().some((i) => i.id === id);
|
||||
return isPrimary || isComp;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user