fix: update toggleSelect to select only 4 authors
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@
|
||||
<mat-checkbox
|
||||
class="author-select"
|
||||
[checked]="isSelected(author)"
|
||||
(change)="toggleSelect(author)" />
|
||||
(change)="toggleSelect(author, $event)" />
|
||||
<a
|
||||
class="author-name"
|
||||
[routerLink]="['/person', authorProfileId(author), 'overview']">
|
||||
|
||||
+10
-2
@@ -6,7 +6,10 @@ import { DecimalPipe } from '@angular/common';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import {
|
||||
MatCheckboxChange,
|
||||
MatCheckboxModule,
|
||||
} from '@angular/material/checkbox';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
@@ -466,7 +469,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
|
||||
return this.selectedIds().includes(this.authorProfileId(author));
|
||||
}
|
||||
|
||||
toggleSelect(author: RankedAuthor): void {
|
||||
toggleSelect(author: RankedAuthor, event?: MatCheckboxChange): void {
|
||||
const id = this.authorProfileId(author);
|
||||
const current = this.selectedIds();
|
||||
|
||||
@@ -476,6 +479,11 @@ export class KeywordsToPersonsResultsComponent implements OnInit {
|
||||
}
|
||||
|
||||
if (current.length >= this.MAX_SELECTED) {
|
||||
// the checkbox already toggled itself, so revert it: the [checked] input
|
||||
// does not change here and would leave the box visually ticked
|
||||
if (event) {
|
||||
event.source.checked = false;
|
||||
}
|
||||
this.snackBar.open(
|
||||
`Es können maximal ${this.MAX_SELECTED} Autoren verglichen werden.`,
|
||||
'OK',
|
||||
|
||||
Reference in New Issue
Block a user