-
+
+
+ {{ person().display_name ?? '' }}
+
-
- {{ person().display_name ?? '' }}
-
{{ distinguishingId() }}
diff --git a/webapp/src/app/modules/person-card/person-card.component.scss b/webapp/src/app/modules/person-card/person-card.component.scss
index 2172cd99..fdbb1e9b 100644
--- a/webapp/src/app/modules/person-card/person-card.component.scss
+++ b/webapp/src/app/modules/person-card/person-card.component.scss
@@ -25,6 +25,7 @@
.card-header {
padding: 16px;
display: flex;
+ align-items: flex-start;
gap: 12px;
border-bottom: 1px solid var(--sg-surface-soft);
text-decoration: none;
@@ -52,6 +53,14 @@
}
}
+.name-row {
+ display: flex;
+ min-width: 0;
+ min-height: 40px;
+ align-items: center;
+ gap: 8px;
+}
+
.rating-and-bookmark {
display: flex;
justify-content: space-between;
@@ -82,18 +91,30 @@
}
.bookmark-btn {
+ display: grid;
+ place-items: center;
+ flex: 0 0 32px;
+ width: 32px;
+ height: 32px;
border: none;
+ border-radius: 50%;
background: transparent;
cursor: pointer;
- padding: 2px;
+ padding: 0;
color: var(--sg-text-soft);
+ transition:
+ color 0.15s ease,
+ background-color 0.15s ease;
- &:hover {
+ &:hover,
+ &:focus-visible {
+ background: var(--sg-primary-soft);
color: var(--sg-primary);
+ outline: none;
}
&.bookmarked {
- color: #e53935;
+ color: var(--sg-success);
}
mat-icon {
@@ -104,11 +125,12 @@
}
.person-name {
- margin: 6px 0 2px;
+ flex: 1 1 auto;
+ min-width: 0;
+ margin: 0;
font-size: 16px;
font-weight: 600;
color: var(--sg-text);
- min-height: 24px;
line-height: 24px;
white-space: nowrap;
overflow: hidden;
diff --git a/webapp/src/app/modules/person-list/person-list.component.ts b/webapp/src/app/modules/person-list/person-list.component.ts
index 36f8f0fa..7bca3280 100644
--- a/webapp/src/app/modules/person-list/person-list.component.ts
+++ b/webapp/src/app/modules/person-list/person-list.component.ts
@@ -42,6 +42,7 @@ import {
MatAutocompleteSelectedEvent,
} from '@angular/material/autocomplete';
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
+import { BookmarkService } from '../../shared/services/bookmark.service';
@Component({
selector: 'app-person-list',
@@ -73,6 +74,7 @@ export class PersonListComponent {
private readonly topicsService = inject(TopicsService);
private readonly institutionsService = inject(InstitutionsService);
private readonly destroyRef = inject(DestroyRef);
+ private readonly bookmarkService = inject(BookmarkService);
public readonly state = inject(SharedStateService);
public readonly paginationService = inject(PaginationService);
public readonly resolverStateService = inject(ResolverStateService);
@@ -120,9 +122,12 @@ export class PersonListComponent {
],
});
- // Bookmarking
- bookmarkedIds = new Set
();
constructor() {
+ this.bookmarkService
+ .load()
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe();
+
if (!this.institutionControl.value) {
this.yearFilterEnabledControl.disable();
}
@@ -510,12 +515,10 @@ export class PersonListComponent {
// Bookmarks
toggleBookmark(person: CustomAuthor): void {
- if (!person.id) return;
- if (this.bookmarkedIds.has(person.id)) {
- this.bookmarkedIds.delete(person.id);
- } else {
- this.bookmarkedIds.add(person.id);
- }
+ this.bookmarkService
+ .confirmToggle(person)
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe();
}
onTopicSelectionChange(newSelection: Set): void {
@@ -540,7 +543,7 @@ export class PersonListComponent {
}
isBookmarked(person: CustomAuthor): boolean {
- return !!person.id && this.bookmarkedIds.has(person.id);
+ return this.bookmarkService.isBookmarked(person.id);
}
clearSearch(): void {
diff --git a/webapp/src/app/modules/person/person.component.html b/webapp/src/app/modules/person/person.component.html
index 62654c2b..316c07be 100644
--- a/webapp/src/app/modules/person/person.component.html
+++ b/webapp/src/app/modules/person/person.component.html
@@ -6,6 +6,27 @@
Person
{{ displayName() }}
+
apartment
diff --git a/webapp/src/app/modules/person/person.component.scss b/webapp/src/app/modules/person/person.component.scss
index 201df358..60f4b087 100644
--- a/webapp/src/app/modules/person/person.component.scss
+++ b/webapp/src/app/modules/person/person.component.scss
@@ -76,6 +76,32 @@
font-weight: 700;
}
+.profile-bookmark-button {
+ display: grid;
+ place-items: center;
+ width: 36px;
+ height: 36px;
+ margin-left: 4px;
+ padding: 0;
+ border: 1px solid var(--sg-border);
+ border-radius: 50%;
+ background: white;
+ color: var(--sg-text-muted);
+ cursor: pointer;
+
+ &:hover,
+ &.bookmarked {
+ border-color: var(--sg-primary);
+ color: var(--sg-primary);
+ }
+
+ mat-icon {
+ width: 21px;
+ height: 21px;
+ font-size: 21px;
+ }
+}
+
.institution-line {
display: flex;
align-items: center;
diff --git a/webapp/src/app/modules/person/person.component.ts b/webapp/src/app/modules/person/person.component.ts
index 494338a8..a890dc6e 100644
--- a/webapp/src/app/modules/person/person.component.ts
+++ b/webapp/src/app/modules/person/person.component.ts
@@ -24,6 +24,7 @@ import { PersonInterestingComponent } from '../person-interesting/person-interes
import { WorksService } from '../../api';
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
import { PersonBioResolved } from '../../resolvers/person-bio.resolver';
+import { BookmarkService } from '../../shared/services/bookmark.service';
@Component({
selector: 'app-person',
@@ -47,6 +48,14 @@ export class PersonComponent {
private readonly worksApi = inject(WorksService);
private readonly destroyRef = inject(DestroyRef);
+ readonly bookmarkService = inject(BookmarkService);
+
+ constructor() {
+ this.bookmarkService
+ .load()
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe();
+ }
readonly params = toSignal(this.activatedRoute.paramMap);
readonly routerEvents = toSignal(this.router.events);
@@ -99,6 +108,15 @@ export class PersonComponent {
{ initialValue: null },
);
+ toggleBookmark(): void {
+ const person = this.person();
+ if (!person) return;
+ this.bookmarkService
+ .confirmToggle(person)
+ .pipe(takeUntilDestroyed(this.destroyRef))
+ .subscribe();
+ }
+
readonly personBio = toSignal(
this.activatedRoute.data.pipe(
switchMap((data) => {
diff --git a/webapp/src/app/shared/services/bookmark.service.ts b/webapp/src/app/shared/services/bookmark.service.ts
new file mode 100644
index 00000000..0b3c34db
--- /dev/null
+++ b/webapp/src/app/shared/services/bookmark.service.ts
@@ -0,0 +1,105 @@
+import { HttpClient } from '@angular/common/http';
+import { Injectable, inject, signal } from '@angular/core';
+import { MatDialog } from '@angular/material/dialog';
+import { EMPTY, Observable, finalize, map, of, switchMap, tap } from 'rxjs';
+
+import { Configuration, CustomAuthor } from '../../api';
+import { ConfirmationDialogComponent } from '../ui/confirmation-dialog/confirmation-dialog.component';
+
+export interface PersonBookmark {
+ person_id: string;
+ person_name: string | null;
+ created_at: string;
+}
+
+@Injectable({ providedIn: 'root' })
+export class BookmarkService {
+ private readonly http = inject(HttpClient);
+ private readonly configuration = inject(Configuration, { optional: true });
+ private readonly dialog = inject(MatDialog);
+ private readonly bookmarkState = signal
([]);
+ private loading = false;
+ private loaded = false;
+
+ readonly bookmarks = this.bookmarkState.asReadonly();
+
+ load(force = false): Observable {
+ if (this.loaded && !force) return of(this.bookmarkState());
+ if (this.loading) return of(this.bookmarkState());
+
+ this.loading = true;
+ return this.http
+ .get(`${this.basePath}/api/bookmarks/persons`)
+ .pipe(
+ tap((bookmarks) => {
+ this.bookmarkState.set(bookmarks);
+ this.loaded = true;
+ }),
+ finalize(() => (this.loading = false)),
+ );
+ }
+
+ isBookmarked(personId: string | null | undefined): boolean {
+ const id = this.normalizeId(personId);
+ return !!id && this.bookmarkState().some((item) => item.person_id === id);
+ }
+
+ toggle(person: CustomAuthor): Observable {
+ const personId = this.normalizeId(person.id);
+ if (!personId) return of(false);
+
+ if (this.isBookmarked(personId)) {
+ return this.http
+ .delete(`${this.basePath}/api/bookmarks/persons/${personId}`)
+ .pipe(
+ tap(() =>
+ this.bookmarkState.update((items) =>
+ items.filter((item) => item.person_id !== personId),
+ ),
+ ),
+ map(() => false),
+ );
+ }
+
+ return this.http
+ .put(`${this.basePath}/api/bookmarks/persons/${personId}`, {
+ person_name: person.display_name ?? null,
+ })
+ .pipe(
+ tap((bookmark) =>
+ this.bookmarkState.update((items) => [
+ bookmark,
+ ...items.filter((item) => item.person_id !== bookmark.person_id),
+ ]),
+ ),
+ map(() => true),
+ );
+ }
+
+ confirmToggle(person: CustomAuthor): Observable {
+ const removing = this.isBookmarked(person.id);
+ const personName = person.display_name?.trim() || 'diese Person';
+ const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
+ data: {
+ title: removing ? 'Bookmark entfernen' : 'Person speichern',
+ message: removing
+ ? `Möchtest Du „${personName}“ wirklich aus Deinen Bookmarks entfernen?`
+ : `Möchtest Du „${personName}“ in Deinen Bookmarks speichern?`,
+ confirmText: removing ? 'Entfernen' : 'Speichern',
+ cancelText: 'Abbrechen',
+ },
+ });
+
+ return dialogRef.afterClosed().pipe(
+ switchMap((confirmed) => (confirmed ? this.toggle(person) : EMPTY)),
+ );
+ }
+
+ private normalizeId(personId: string | null | undefined): string {
+ return personId?.trim().replace(/\/$/, '').split('/').pop() ?? '';
+ }
+
+ private get basePath(): string {
+ return this.configuration?.basePath ?? '';
+ }
+}
diff --git a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts
index f39ff565..644c59a3 100644
--- a/webapp/src/app/shared/ui/app-menu/app-menu.component.ts
+++ b/webapp/src/app/shared/ui/app-menu/app-menu.component.ts
@@ -74,6 +74,12 @@ export class AppMenuComponent {
},
disabled: false,
},
+ {
+ label: 'Bookmarks',
+ icon: 'bookmarks',
+ route: '/bookmarks',
+ disabled: false,
+ },
{
label: 'News',
icon: 'newspaper',
diff --git a/webapp/src/app/shared/ui/confirmation-dialog/confirmation-dialog.component.ts b/webapp/src/app/shared/ui/confirmation-dialog/confirmation-dialog.component.ts
index bfeb4734..bc2b33aa 100644
--- a/webapp/src/app/shared/ui/confirmation-dialog/confirmation-dialog.component.ts
+++ b/webapp/src/app/shared/ui/confirmation-dialog/confirmation-dialog.component.ts
@@ -51,11 +51,11 @@ export class ConfirmationDialogComponent {
}
onCancelClick(): void {
- this.dialogRef.close();
+ this.dialogRef.close(false);
}
onConfirmClick(): void {
this.confirmDelete.emit();
- this.dialogRef.close();
+ this.dialogRef.close(true);
}
}