publication detail: paginate authors and institutions lists
This commit is contained in:
@@ -142,7 +142,10 @@
|
||||
@if (authorsExpanded) {
|
||||
<div class="accordion-body">
|
||||
<div class="author-list">
|
||||
@for (authorship of authors(); track authorship.author?.id) {
|
||||
@for (
|
||||
authorship of pagedAuthors();
|
||||
track authorship.author?.id
|
||||
) {
|
||||
<article>
|
||||
<div class="avatar">
|
||||
{{
|
||||
@@ -184,6 +187,27 @@
|
||||
<p class="empty">Keine Angaben vorhanden.</p>
|
||||
}
|
||||
</div>
|
||||
@if (authorsPageCount() > 1) {
|
||||
<div class="list-pagination">
|
||||
<button
|
||||
type="button"
|
||||
class="page-btn"
|
||||
[disabled]="authorsPage === 0"
|
||||
(click)="authorsPage = authorsPage - 1">
|
||||
<mat-icon>chevron_left</mat-icon>
|
||||
</button>
|
||||
<span class="page-indicator"
|
||||
>{{ authorsPage + 1 }} / {{ authorsPageCount() }}</span
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="page-btn"
|
||||
[disabled]="authorsPage === authorsPageCount() - 1"
|
||||
(click)="authorsPage = authorsPage + 1">
|
||||
<mat-icon>chevron_right</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
@@ -362,7 +386,10 @@
|
||||
@if (institutionsExpanded) {
|
||||
<div class="accordion-body">
|
||||
<div class="compact-list">
|
||||
@for (institution of institutions(); track institution.id) {
|
||||
@for (
|
||||
institution of pagedInstitutions();
|
||||
track institution.id
|
||||
) {
|
||||
<div>
|
||||
<a
|
||||
class="institution-link"
|
||||
@@ -391,6 +418,30 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@if (institutionsPageCount() > 1) {
|
||||
<div class="list-pagination">
|
||||
<button
|
||||
type="button"
|
||||
class="page-btn"
|
||||
[disabled]="institutionsPage === 0"
|
||||
(click)="institutionsPage = institutionsPage - 1">
|
||||
<mat-icon>chevron_left</mat-icon>
|
||||
</button>
|
||||
<span class="page-indicator"
|
||||
>{{ institutionsPage + 1 }} /
|
||||
{{ institutionsPageCount() }}</span
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="page-btn"
|
||||
[disabled]="
|
||||
institutionsPage === institutionsPageCount() - 1
|
||||
"
|
||||
(click)="institutionsPage = institutionsPage + 1">
|
||||
<mat-icon>chevron_right</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
|
||||
@@ -444,6 +444,50 @@ dd {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.list-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.page-btn {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 8px;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
color: var(--sg-text-muted);
|
||||
transition: background 0.12s;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: var(--sg-surface-muted);
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.35;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
font-size: 18px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.page-indicator {
|
||||
font-size: 12px;
|
||||
color: var(--sg-text-muted);
|
||||
min-width: 36px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.institution-country {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -65,12 +65,20 @@ export class PublicationDetailComponent implements OnInit {
|
||||
fundingExpanded = false;
|
||||
linksExpanded = false;
|
||||
|
||||
authorsPage = 0;
|
||||
readonly authorsPageSize = 10;
|
||||
|
||||
institutionsPage = 0;
|
||||
readonly institutionsPageSize = 5;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loading = true;
|
||||
|
||||
this.route.data.pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
||||
next: ({ publication }) => {
|
||||
this.publication = publication;
|
||||
this.authorsPage = 0;
|
||||
this.institutionsPage = 0;
|
||||
this.loading = false;
|
||||
},
|
||||
error: () => {
|
||||
@@ -130,6 +138,28 @@ export class PublicationDetailComponent implements OnInit {
|
||||
return this.publication?.authorships ?? [];
|
||||
}
|
||||
|
||||
pagedAuthors(): Authorship[] {
|
||||
return this.authors().slice(
|
||||
this.authorsPage * this.authorsPageSize,
|
||||
(this.authorsPage + 1) * this.authorsPageSize,
|
||||
);
|
||||
}
|
||||
|
||||
authorsPageCount(): number {
|
||||
return Math.ceil(this.authors().length / this.authorsPageSize);
|
||||
}
|
||||
|
||||
pagedInstitutions(): InstitutionDetail[] {
|
||||
return this.institutions().slice(
|
||||
this.institutionsPage * this.institutionsPageSize,
|
||||
(this.institutionsPage + 1) * this.institutionsPageSize,
|
||||
);
|
||||
}
|
||||
|
||||
institutionsPageCount(): number {
|
||||
return Math.ceil(this.institutions().length / this.institutionsPageSize);
|
||||
}
|
||||
|
||||
institutions(): InstitutionDetail[] {
|
||||
const institutions = new Map<string, InstitutionDetail>();
|
||||
for (const authorship of this.authors()) {
|
||||
|
||||
Reference in New Issue
Block a user