changed author and institution chips as well
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<mat-chip
|
||||
class="author-chip"
|
||||
[appComponentTooltip]="AuthorTooltipComponent"
|
||||
[tooltipInputs]="{ authorId: rawOaAuthorId() }"
|
||||
[tooltipInputs]="{ author: _author(), authorId: rawOaAuthorId() }"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
|
||||
@@ -23,7 +23,8 @@ import { AppAuthorCardComponent } from '../app-author-card/app-author-card.compo
|
||||
export class AppAuthorTooltipComponent {
|
||||
private readonly authorsService = inject(AuthorsV2Service);
|
||||
|
||||
authorId = input.required<string>();
|
||||
authorId = input<string | null | undefined>(undefined);
|
||||
author = input<Author | null | undefined>(undefined);
|
||||
|
||||
_author = signal<Author | undefined>(undefined);
|
||||
|
||||
@@ -31,15 +32,33 @@ export class AppAuthorTooltipComponent {
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const authorId = this.authorId();
|
||||
if (!authorId) {
|
||||
this._author.set(undefined);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.authorsService.getAuthorById(authorId).subscribe((author) => {
|
||||
this._author.set(author);
|
||||
const authorObj = this.author();
|
||||
const authorId = this.authorId() ?? authorObj?.id;
|
||||
|
||||
if (authorObj) {
|
||||
this._author.set(authorObj);
|
||||
this._isLoading.set(false);
|
||||
});
|
||||
}
|
||||
|
||||
if (authorId) {
|
||||
const cleanId = authorId.replace('https://openalex.org/', '');
|
||||
this._isLoading.set(true);
|
||||
this.authorsService.getAuthorById(cleanId).subscribe({
|
||||
next: (fetchedAuthor) => {
|
||||
this._author.set({
|
||||
...authorObj,
|
||||
...fetchedAuthor,
|
||||
});
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
});
|
||||
} else if (!authorObj) {
|
||||
this._author.set(undefined);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<mat-chip
|
||||
class="institution-chip"
|
||||
[appComponentTooltip]="AppInstitutionTooltipComponent"
|
||||
[tooltipInputs]="{ institutionId: rawOaInstitutionId() }"
|
||||
[tooltipInputs]="{
|
||||
institution: _institution(),
|
||||
institutionId: rawOaInstitutionId(),
|
||||
}"
|
||||
(keydown)="_onChipClick($event)"
|
||||
(click)="_onChipClick($event)">
|
||||
<span class="chip-content">
|
||||
|
||||
+27
-10
@@ -11,7 +11,8 @@ import { AppInstitutionCardComponent } from '../app-institution-card/app-institu
|
||||
export class AppInstitutionTooltipComponent {
|
||||
private readonly institutionsService = inject(InstitutionsV2Service);
|
||||
|
||||
institutionId = input.required<string>();
|
||||
institutionId = input<string | null | undefined>(undefined);
|
||||
institution = input<Institution | null | undefined>(undefined);
|
||||
|
||||
_institution = signal<Institution | undefined>(undefined);
|
||||
|
||||
@@ -19,17 +20,33 @@ export class AppInstitutionTooltipComponent {
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const institutionId = this.institutionId();
|
||||
if (!institutionId) {
|
||||
this._institution.set(undefined);
|
||||
const institutionObj = this.institution();
|
||||
const institutionId = this.institutionId() ?? institutionObj?.id;
|
||||
|
||||
if (institutionObj) {
|
||||
this._institution.set(institutionObj);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
this._isLoading.set(true);
|
||||
this.institutionsService
|
||||
.getInstitutionById2(institutionId)
|
||||
.subscribe((institution) => {
|
||||
this._institution.set(institution);
|
||||
this._isLoading.set(false);
|
||||
|
||||
if (institutionId) {
|
||||
const cleanId = institutionId.replace('https://openalex.org/', '');
|
||||
this._isLoading.set(true);
|
||||
this.institutionsService.getInstitutionById2(cleanId).subscribe({
|
||||
next: (fetchedInst) => {
|
||||
this._institution.set({
|
||||
...institutionObj,
|
||||
...fetchedInst,
|
||||
});
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
error: () => {
|
||||
this._isLoading.set(false);
|
||||
},
|
||||
});
|
||||
} else if (!institutionObj) {
|
||||
this._institution.set(undefined);
|
||||
this._isLoading.set(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user