From aa473a652360aecfb7291bc75453e11fdaff7489 Mon Sep 17 00:00:00 2001 From: Kazgatari <56477241+Kazgatari@users.noreply.github.com> Date: Fri, 10 Jul 2026 10:49:55 +0200 Subject: [PATCH] added shared institution selector --- .../institution-selector.component.html | 131 +++++++ .../institution-selector.component.scss | 340 ++++++++++++++++++ .../institution-selector.component.ts | 67 ++++ 3 files changed, 538 insertions(+) create mode 100644 webapp/src/app/shared/ui/institution-selector/institution-selector.component.html create mode 100644 webapp/src/app/shared/ui/institution-selector/institution-selector.component.scss create mode 100644 webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts diff --git a/webapp/src/app/shared/ui/institution-selector/institution-selector.component.html b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.html new file mode 100644 index 00000000..a4203df9 --- /dev/null +++ b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.html @@ -0,0 +1,131 @@ +
+ +
+
+

Einrichtungen vergleichen

+ @if (primaryInstitutionName()) { +
+ Zugewiesen: + {{ primaryInstitutionName() }} +
+ } +
+ + + + + +
+ @if (comparisonInstitutions().length > 0) { +
+ @for (inst of comparisonInstitutions(); track inst.id) { +
+ + apartment {{ inst.name }} + +
+ + +
+
+ } +
+ } @else { +
+ Keine weiteren Einrichtungen ausgewählt. Suchen zum Hinzufügen. +
+ } +
+
+ + +
+

+ Empfohlene Top-Einrichtungen für das Thema: {{ activeChartTopic() }} +

+ +
+ @if (isSuggestionsLoading()) { +
+
+ Empfehlungen werden geladen... +
+ } @else { + @if (topSuggestions().length === 0) { +

+ Keine Empfehlungen für dieses Thema gefunden. +

+ } @else { +
+ @for (item of topSuggestions(); track item.id || '') { + + } +
+ } + } +
+
+
diff --git a/webapp/src/app/shared/ui/institution-selector/institution-selector.component.scss b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.scss new file mode 100644 index 00000000..a9fe0b99 --- /dev/null +++ b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.scss @@ -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); + } +} diff --git a/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts new file mode 100644 index 00000000..c72629a7 --- /dev/null +++ b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts @@ -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([]); + readonly primaryInstitution = input(null); + readonly primaryInstitutionName = input(null); + readonly topSuggestions = input([]); + readonly isSuggestionsLoading = input(false); + readonly activeChartTopic = input(''); + readonly searchQuery = input(''); + readonly searchResults = input([]); + readonly getEntityColor = input<(id: string) => string>(() => '#9ca3af'); + readonly isVisible = input<(id: string) => boolean>(() => true); + + readonly addInstitution = output<{ id: string; name: string }>(); + readonly removeInstitution = output(); + readonly searchChange = output(); + readonly toggleVisibility = output(); + + 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; + } +}