publication overview: show institution filter as person-card chip with flag
This commit is contained in:
@@ -141,8 +141,26 @@
|
||||
</span>
|
||||
}
|
||||
@for (institution of selectedInstitutions; track institution.id) {
|
||||
<span class="filter-chip">
|
||||
Institution: {{ institution.display_name }}
|
||||
@let instCountry = selectedInstitutionCountry(institution);
|
||||
<span class="active-institution-filter">
|
||||
<span class="filter-institution-chip">
|
||||
<mat-icon class="institution-icon">apartment</mat-icon>
|
||||
<span class="institution-name">{{
|
||||
institution.display_name
|
||||
}}</span>
|
||||
@if (instCountry) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' + instCountry.toLowerCase() + '.svg'
|
||||
"
|
||||
height="10" />
|
||||
<span class="country-code">{{
|
||||
instCountry.toUpperCase()
|
||||
}}</span>
|
||||
}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="remove-chip-btn"
|
||||
|
||||
@@ -175,6 +175,54 @@ h2 {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.active-institution-filter {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.filter-institution-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
max-width: 220px;
|
||||
padding: 2px 6px;
|
||||
border: 1px solid var(--sg-primary-border, var(--sg-border));
|
||||
border-radius: 4px;
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-primary);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: normal;
|
||||
|
||||
.institution-icon {
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
margin-right: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.institution-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.flag-img {
|
||||
flex-shrink: 0;
|
||||
margin-left: 6px;
|
||||
border: 1px solid;
|
||||
}
|
||||
|
||||
.country-code {
|
||||
flex-shrink: 0;
|
||||
margin-left: 2px;
|
||||
font-size: 9px;
|
||||
}
|
||||
}
|
||||
|
||||
app-topic-chip.active-filter-topic-chip {
|
||||
max-width: min(320px, 48vw);
|
||||
}
|
||||
@@ -191,7 +239,8 @@ app-topic-chip.active-filter-topic-chip {
|
||||
}
|
||||
|
||||
.filter-chip button,
|
||||
.active-topic-filter button {
|
||||
.active-topic-filter button,
|
||||
.active-institution-filter button {
|
||||
display: flex;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
@@ -205,7 +254,8 @@ app-topic-chip.active-filter-topic-chip {
|
||||
}
|
||||
|
||||
.filter-chip button mat-icon,
|
||||
.active-topic-filter button mat-icon {
|
||||
.active-topic-filter button mat-icon,
|
||||
.active-institution-filter button mat-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
font-size: 12px;
|
||||
|
||||
@@ -334,6 +334,22 @@ export class PersonPublicationsComponent implements OnInit {
|
||||
return !!id && this.selectedInstitutions.some((item) => item.id === id);
|
||||
}
|
||||
|
||||
selectedInstitutionCountry(
|
||||
institution: InstitutionAutocompleteOption,
|
||||
): string | null {
|
||||
if (!institution.id) return null;
|
||||
for (const publication of this.publications) {
|
||||
for (const authorship of publication.authorships ?? []) {
|
||||
for (const inst of authorship.institutions ?? []) {
|
||||
if (inst.id === institution.id && inst.country_code) {
|
||||
return inst.country_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
toggleYearFilter(year: number): void {
|
||||
const control = this.filterForm.controls.publicationYears;
|
||||
const current = control.value;
|
||||
|
||||
Reference in New Issue
Block a user