diff --git a/src/app/cdk/modal/modal-side-bar/modal-side-bar.component.html b/src/app/cdk/modal/modal-side-bar/modal-side-bar.component.html index 6f1115b1cf..f001df9bac 100644 --- a/src/app/cdk/modal/modal-side-bar/modal-side-bar.component.html +++ b/src/app/cdk/modal/modal-side-bar/modal-side-bar.component.html @@ -14,5 +14,8 @@

Form content

+ diff --git a/src/app/cdk/panel/panel/panel.component.html b/src/app/cdk/panel/panel/panel.component.html index 201b312176..eaac57009c 100644 --- a/src/app/cdk/panel/panel/panel.component.html +++ b/src/app/cdk/panel/panel/panel.component.html @@ -23,6 +23,7 @@
(1) + $research: ReplaySubject headers = new HttpHeaders({ 'Access-Control-Allow-Origin': '*', @@ -65,6 +66,12 @@ export class RecordResearchResourceService { ) .subscribe() } else { + if (!this.$research) { + this.$research = new ReplaySubject(1) + } else if (!options.forceReload) { + return this.$research + } + this._http .get( environment.API_WEB + @@ -78,6 +85,7 @@ export class RecordResearchResourceService { options.pageSize ) .pipe( + retry(3), catchError((error) => this._errorHandler.handleError(error)), catchError(() => of({ groups: [] } as ResearchResourcesEndpoint)), map((data) => { @@ -88,23 +96,18 @@ export class RecordResearchResourceService { return data }), tap((value) => { - this.researchResourcesSubject.next(value) + this.$research.next(value) }) ) .subscribe() } - return this.researchResourcesSubject.asObservable() + return this.$research.asObservable() } - changeUserRecordContext(event: UserRecordOptions): void { - this.getResearchResourcePage(event).pipe(take(1)).subscribe() - } - - loadMore(offset: number, publicRecordId?: string) { - this.getResearchResourcePage({ - offset, - publicRecordId, - }) + changeUserRecordContext( + event: UserRecordOptions + ): Observable { + return this.getResearchResourcePage(event).pipe(take(1)) } getResearchResourceById(putCode: string): Observable { diff --git a/src/app/core/record-works/record-works.service.ts b/src/app/core/record-works/record-works.service.ts index e3028f57e7..a948d673ae 100644 --- a/src/app/core/record-works/record-works.service.ts +++ b/src/app/core/record-works/record-works.service.ts @@ -130,8 +130,10 @@ export class RecordWorksService { } } - changeUserRecordContext(event: UserRecordOptions): void { - this.getWorks(event).pipe(take(1)).subscribe() + changeUserRecordContext( + userRecordOptions: UserRecordOptions + ): Observable { + return this.getWorks(userRecordOptions).pipe(take(1)) } /** diff --git a/src/app/record/components/research-resource-stacks-group/research-resource-stacks-group.component.ts b/src/app/record/components/research-resource-stacks-group/research-resource-stacks-group.component.ts index 65f6e124e8..988b349f89 100644 --- a/src/app/record/components/research-resource-stacks-group/research-resource-stacks-group.component.ts +++ b/src/app/record/components/research-resource-stacks-group/research-resource-stacks-group.component.ts @@ -55,7 +55,6 @@ export class ResearchResourceStacksGroupComponent implements OnInit { } = {} ngOrcidResearchResources = $localize`:@@researchResources.researchResources:Research resources` - offset: number isMobile: boolean paginationTotalAmountOfResearchResources: number @@ -89,15 +88,12 @@ export class ResearchResourceStacksGroupComponent implements OnInit { private getRecord() { this._record - .getRecord({ - publicRecordId: this.isPublicRecord || undefined, - }) + .getRecord({ publicRecordId: this.isPublicRecord }) .pipe(takeUntil(this.$destroy)) .subscribe((userRecord) => { if (!isEmpty(userRecord?.researchResources)) { this.paginationLoading = false this.researchResources = userRecord.researchResources - this.offset = userRecord.researchResources.offset this.total.emit(this.researchResources.groups.length) this.paginationTotalAmountOfResearchResources = userRecord.researchResources.totalGroups @@ -109,23 +105,34 @@ export class ResearchResourceStacksGroupComponent implements OnInit { } pageEvent(event: PageEvent) { + this.paginationLoading = true this.userRecordContext.offset = event.pageIndex * event.pageSize this.userRecordContext.pageSize = event.pageSize this.userRecordContext.publicRecordId = this.isPublicRecord - this._recordResearchResourceService.changeUserRecordContext( - this.userRecordContext - ) - this.paginationLoading = true + this.loadResearchResources() } sortEvent(event: SortData) { + this.paginationLoading = true this.userRecordContext.publicRecordId = this.isPublicRecord this.userRecordContext.sort = event.type this.userRecordContext.sortAsc = event.direction === 'asc' - this._recordResearchResourceService.changeUserRecordContext( - this.userRecordContext - ) - this.paginationLoading = true + this.loadResearchResources() + } + + loadResearchResources(): void { + if ( + this.researchResources.totalGroups > + this.researchResources.groups.length || + this.paginationPageSize !== this.defaultPageSize + ) { + this.userRecordContext.forceReload = true + } + this._recordResearchResourceService + .changeUserRecordContext(this.userRecordContext) + .subscribe(() => { + this.paginationLoading = false + }) } expandedClicked(expanded: boolean) { diff --git a/src/app/record/components/work-modal/work-modal.component.html b/src/app/record/components/work-modal/work-modal.component.html index 750d05d9cb..322e2bc336 100644 --- a/src/app/record/components/work-modal/work-modal.component.html +++ b/src/app/record/components/work-modal/work-modal.component.html @@ -96,7 +96,7 @@
- + * - +
-
-
- - add translated title -
- - + add_circle_outline + + + Add translated title + + + Hide translation title + + +
@@ -224,7 +219,7 @@
-
- + Select a citation type @@ -460,21 +442,13 @@
-