File tree Expand file tree Collapse file tree
components/search-results-container Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,8 +110,12 @@ <h4 class="result-count">
110110 } @else {
111111 < div class ="flex flex-column gap-4 ">
112112 @if (resources().length > 0) {
113- @for (item of resources(); track $index) {
114- < osf-resource-card [resource] ="item " [provider] ="provider() " />
113+ @for (item of resources(); track item.absoluteUrl) {
114+ < osf-resource-card
115+ [resource] ="item "
116+ [provider] ="provider() "
117+ [attr.data-test-search-result-card] ="item.id || item.absoluteUrl "
118+ />
115119 }
116120
117121 < div class ="flex column-gap-2 w-full justify-content-center pt-2 ">
Original file line number Diff line number Diff line change @@ -69,9 +69,7 @@ export class SearchResultsContainerComponent {
6969 readonly searchSortingOptions = searchSortingOptions ;
7070 readonly ResourceType = ResourceType ;
7171
72- readonly hasSelectedOptions = computed ( ( ) => {
73- return Object . values ( this . selectedOptions ( ) ) . length > 0 ;
74- } ) ;
72+ readonly hasSelectedOptions = computed ( ( ) => Object . values ( this . selectedOptions ( ) ) . length > 0 ) ;
7573
7674 readonly hasFilters = computed ( ( ) => this . filters ( ) . length > 0 ) ;
7775 filtersComponent = contentChild < TemplateRef < unknown > > ( 'filtersComponent' ) ;
Original file line number Diff line number Diff line change @@ -31,8 +31,12 @@ export function MapResources(indexCardSearchResponseJsonApi: IndexCardSearchResp
3131 const searchResultItem = searchResultItems . find (
3232 ( searchResult ) => searchResult . relationships . indexCard . data . id === indexCard . id
3333 ) ! ;
34+
35+ const absoluteUrl = resourceMetadata [ '@id' ] ;
36+
3437 resources . push ( {
35- absoluteUrl : resourceMetadata [ '@id' ] ,
38+ id : absoluteUrl . split ( '/' ) . filter ( Boolean ) . pop ( ) ?? '' ,
39+ absoluteUrl,
3640 resourceType : ResourceType [ resourceMetadata . resourceType [ 0 ] [ '@id' ] as keyof typeof ResourceType ] ,
3741 name : resourceMetadata . name ?. [ 0 ] ?. [ '@value' ] ,
3842 title : replaceBadEncodedChars ( resourceMetadata . title ?. [ 0 ] ?. [ '@value' ] ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { StringOrNull } from '@osf/shared/helpers/types.helper';
44import { DiscoverableFilter } from './discoverable-filter.model' ;
55
66export interface ResourceModel {
7+ id ?: string ;
78 absoluteUrl : string ;
89 resourceType : ResourceType ;
910 name ?: string ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { ResourceType } from '@shared/enums/resource-type.enum';
33import { ResourceModel } from '@shared/models/search/resource.model' ;
44
55export const MOCK_RESOURCE : ResourceModel = {
6+ id : 'resource-123' ,
67 absoluteUrl : 'https://api.osf.io/v2/resources/resource-123' ,
78 resourceType : ResourceType . Registration ,
89 title : 'Test Resource' ,
@@ -44,6 +45,7 @@ export const MOCK_RESOURCE: ResourceModel = {
4445} ;
4546
4647export const MOCK_AGENT_RESOURCE : ResourceModel = {
48+ id : 'user-123' ,
4749 absoluteUrl : 'https://api.osf.io/v2/users/user-123' ,
4850 resourceType : ResourceType . Agent ,
4951 title : 'Test User' ,
You can’t perform that action at this time.
0 commit comments