Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/works my orcid #1120

Merged
merged 9 commits into from
Sep 15, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ <h2 class="orc-font-body-small">Form content</h2>
<ul>
<ng-content select="#side-bar-url-3"></ng-content>
</ul>
<ul>
<ng-content select="#side-bar-url-4"></ng-content>
</ul>
</div>
</div>
1 change: 1 addition & 0 deletions src/app/cdk/panel/panel/panel.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<div *ngIf="selectable">
<mat-checkbox
class="text-wrap"
*ngIf="selectable && !isPublicRecord"
(change)="checked($event)"
[ngModel]="selected"
Expand Down
6 changes: 6 additions & 0 deletions src/app/cdk/panel/panel/panel.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,9 @@ div.hide:hover {
margin-top: 4px;
}
}

mat-checkbox.text-wrap {
::ng-deep label.mat-checkbox-layout {
white-space: normal;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { DEFAULT_PAGE_SIZE } from 'src/app/constants'
})
export class RecordResearchResourceService {
researchResourcesSubject = new ReplaySubject<ResearchResourcesEndpoint>(1)
$research: ReplaySubject<ResearchResourcesEndpoint>

headers = new HttpHeaders({
'Access-Control-Allow-Origin': '*',
Expand Down Expand Up @@ -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<ResearchResourcesEndpoint>(
environment.API_WEB +
Expand All @@ -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) => {
Expand All @@ -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<ResearchResourcesEndpoint> {
return this.getResearchResourcePage(event).pipe(take(1))
}

getResearchResourceById(putCode: string): Observable<ResearchResource> {
Expand Down
6 changes: 4 additions & 2 deletions src/app/core/record-works/record-works.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ export class RecordWorksService {
}
}

changeUserRecordContext(event: UserRecordOptions): void {
this.getWorks(event).pipe(take(1)).subscribe()
changeUserRecordContext(
userRecordOptions: UserRecordOptions
): Observable<WorksEndpoint> {
return this.getWorks(userRecordOptions).pipe(take(1))
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class ResearchResourceStacksGroupComponent implements OnInit {
} = {}

ngOrcidResearchResources = $localize`:@@researchResources.researchResources:Research resources`
offset: number
isMobile: boolean

paginationTotalAmountOfResearchResources: number
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Loading