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

[Webcomponents]: Fix bug where gn-record-view stays empty #26

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<gn-ui-metadata-contact [metadata]="record"></gn-ui-metadata-contact>

<div *ngIf="getDownloads(record?.onlineResources)?.length > 0">
<div class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center">
<div
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
>
<span translate>record.metadata.download</span>
<gn-ui-previous-next-buttons
*ngIf="downloads?.pagesCount > 1"
Expand All @@ -39,7 +41,9 @@
</div>

<div *ngIf="getLinks(record?.onlineResources)?.length > 0">
<div class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center">
<div
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
>
<span translate>record.metadata.links</span>
<gn-ui-previous-next-buttons
*ngIf="links?.pagesCount > 1"
Expand All @@ -56,7 +60,9 @@
</div>

<div *ngIf="getAPIs(record?.onlineResources)?.length > 0">
<div class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center">
<div
class="font-title text-lg mt-4 mb-2 flex flex-row gap-4 items-center"
>
<span translate>record.metadata.api</span>
<gn-ui-previous-next-buttons
*ngIf="apis?.pagesCount > 1"
Expand All @@ -67,6 +73,7 @@
<gn-ui-api-card
*ngFor="let otherLink of getAPIs(record?.onlineResources)"
[link]="otherLink"
[currentLink]="otherLink"
></gn-ui-api-card>
</gn-ui-block-list>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,41 @@ import {
encapsulation: ViewEncapsulation.ShadowDom,
providers: [SearchFacade],
})

export class GnRecordViewComponent extends BaseComponent implements OnInit {
@Input() recordId!: string;
record$: Observable<CatalogRecord | null>;
downloads$: Observable<OnlineResource[]>;
links$: Observable<OnlineResource[]>;
apis$: Observable<OnlineResource[]>;
@Input() recordId!: string
record$: Observable<CatalogRecord | null>
downloads$: Observable<OnlineResource[]>
links$: Observable<OnlineResource[]>
apis$: Observable<OnlineResource[]>

constructor(injector: Injector) {
super(injector);
super(injector)
}

ngOnInit() {
super.ngOnInit();
this.record$ = this.recordsRepository.getRecord(this.recordId);
super.ngOnInit()
this.record$ = this.recordsRepository.getRecord(this.recordId)

this.downloads$ = this.record$.pipe(
map((record) => this.getDownloads(record?.onlineResources || []))
);
)
this.links$ = this.record$.pipe(
map((record) => this.getLinks(record?.onlineResources || []))
);
)
this.apis$ = this.record$.pipe(
map((record) => this.getAPIs(record?.onlineResources || []))
);
)
}

getDownloads(onlineResources: OnlineResource[]): OnlineResource[] {
return onlineResources.filter((resource) => resource.type === 'download');
return onlineResources.filter((resource) => resource.type === 'download')
}

getLinks(onlineResources: OnlineResource[]): OnlineResource[] {
return onlineResources.filter((resource) => resource.type === 'link');
return onlineResources.filter((resource) => resource.type === 'link')
}

getAPIs(onlineResources: OnlineResource[]): OnlineResource[] {
return onlineResources.filter((resource) => resource.type === 'service');
return onlineResources.filter((resource) => resource.type === 'service')
}
}
Loading