Skip to content

Commit

Permalink
fix: fix records staying empty
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Jan 17, 2025
1 parent 8f69734 commit 42d9009
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
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')
}
}

0 comments on commit 42d9009

Please sign in to comment.