@@ -5,18 +5,10 @@ import { Button } from 'primeng/button';
55import { Skeleton } from 'primeng/skeleton' ;
66import { Tag } from 'primeng/tag' ;
77
8- import {
9- ChangeDetectionStrategy ,
10- Component ,
11- computed ,
12- CUSTOM_ELEMENTS_SCHEMA ,
13- input ,
14- ViewEncapsulation ,
15- } from '@angular/core' ;
8+ import { ChangeDetectionStrategy , Component , computed , input } from '@angular/core' ;
169import { RouterLink } from '@angular/router' ;
1710
1811import { collectionFilterNames } from '@osf/features/collections/constants' ;
19- import { CEDAR_VIEWER_CONFIG } from '@osf/features/metadata/constants' ;
2012import { CedarMetadataDataTemplateJsonApi , CedarMetadataRecordData } from '@osf/features/metadata/models' ;
2113import { StopPropagationDirective } from '@osf/shared/directives/stop-propagation.directive' ;
2214import { CollectionSubmission } from '@osf/shared/models/collections/collections.model' ;
@@ -41,8 +33,6 @@ import { CollectionStatusSeverityPipe } from '@osf/shared/pipes/collection-statu
4133 templateUrl : './overview-collections.component.html' ,
4234 styleUrl : './overview-collections.component.scss' ,
4335 changeDetection : ChangeDetectionStrategy . OnPush ,
44- schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
45- encapsulation : ViewEncapsulation . None ,
4636} )
4737export class OverviewCollectionsComponent {
4838 projectSubmissions = input < CollectionSubmission [ ] | null > ( null ) ;
@@ -51,8 +41,6 @@ export class OverviewCollectionsComponent {
5141 cedarRecords = input < CedarMetadataRecordData [ ] | null > ( null ) ;
5242 cedarTemplates = input < CedarMetadataDataTemplateJsonApi [ ] | null > ( null ) ;
5343
54- cedarViewerConfig = CEDAR_VIEWER_CONFIG ;
55-
5644 cedarRecordByTemplateId = computed ( ( ) => {
5745 const records = this . cedarRecords ( ) ;
5846 return new Map (
@@ -85,4 +73,40 @@ export class OverviewCollectionsComponent {
8573
8674 return attributes ;
8775 }
76+
77+ getCedarAttributes ( record : CedarMetadataRecordData , template : CedarMetadataDataTemplateJsonApi ) : KeyValueModel [ ] {
78+ const { order, propertyLabels } = template . attributes . template . _ui ;
79+ const metadata = record . attributes . metadata as Record < string , unknown > ;
80+ const attributes : KeyValueModel [ ] = [ ] ;
81+
82+ for ( const key of order ) {
83+ const label = propertyLabels [ key ] ;
84+ const value = this . formatCedarValue ( metadata [ key ] ) ;
85+ if ( label && value ) {
86+ attributes . push ( { key, label, value } ) ;
87+ }
88+ }
89+
90+ return attributes ;
91+ }
92+
93+ private formatCedarValue ( value : unknown ) : string {
94+ if ( value == null ) return '' ;
95+
96+ if ( Array . isArray ( value ) ) {
97+ return value
98+ . map ( ( item ) => this . formatCedarValue ( item ) )
99+ . filter ( Boolean )
100+ . join ( ', ' ) ;
101+ }
102+
103+ if ( typeof value === 'object' ) {
104+ const obj = value as Record < string , unknown > ;
105+ if ( '@value' in obj && obj [ '@value' ] != null ) return String ( obj [ '@value' ] ) ;
106+ if ( 'rdfs:label' in obj && obj [ 'rdfs:label' ] != null ) return String ( obj [ 'rdfs:label' ] ) ;
107+ return '' ;
108+ }
109+
110+ return String ( value ) ;
111+ }
88112}
0 commit comments