Skip to content

Commit 1bb26ba

Browse files
committed
fix(resource-card-secondary-metadata): Fixed resource-card component
1 parent dd07529 commit 1bb26ba

31 files changed

Lines changed: 885 additions & 287 deletions

src/app/shared/components/osf-search/osf-search.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
}
1111

1212
<osf-search-results-container
13+
[provider]="provider()"
1314
[tabOptions]="resourceTabOptions()"
1415
[resources]="resources()"
1516
[areResourcesLoading]="areResourcesLoading()"

src/app/shared/components/osf-search/osf-search.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1818
import { FormControl } from '@angular/forms';
1919
import { ActivatedRoute, Router } from '@angular/router';
2020

21+
import { PreprintProviderDetails } from '@osf/features/preprints/models';
2122
import { ResourceType } from '@shared/enums';
2223
import { StringOrNull } from '@shared/helpers';
2324
import { DiscoverableFilter, TabOption } from '@shared/models';
@@ -94,6 +95,7 @@ export class OsfSearchComponent implements OnInit, OnDestroy {
9495
previous = select(OsfSearchSelectors.getPrevious);
9596
resourceType = select(OsfSearchSelectors.getResourceType);
9697

98+
provider = input<PreprintProviderDetails | null>(null);
9799
searchControlInput = input<FormControl | null>(null);
98100

99101
searchControl!: FormControl;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<div class="flex flex-column gap-2">
2+
@let resourceValue = resource();
3+
@if (resourceValue.description) {
4+
<p>{{ 'resourceCard.labels.description' | translate }} {{ resourceValue.description }}</p>
5+
}
6+
7+
@let limit = 4;
8+
@let nodeFunders = resourceValue.isContainedBy?.funders;
9+
@if (nodeFunders && nodeFunders.length > 0) {
10+
<p>
11+
{{ 'resourceCard.labels.funder' | translate }}
12+
@for (funder of nodeFunders.slice(0, limit); track $index) {
13+
<a class="font-bold" [href]="funder.absoluteUrl" target="_blank">{{ funder.name }}{{ $last ? '' : ', ' }}</a>
14+
}
15+
@if (nodeFunders.length > limit) {
16+
<span>{{ 'resourceCard.andCountMore' | translate: { count: nodeFunders.length - limit } }} </span>
17+
}
18+
</p>
19+
}
20+
21+
@if (resourceValue.resourceNature) {
22+
<p>{{ 'resourceCard.labels.resourceNature' | translate }} {{ resourceValue.resourceNature }}</p>
23+
}
24+
25+
@let nodeLicense = resourceValue.isContainedBy?.license;
26+
@if (nodeLicense) {
27+
<p>
28+
{{ 'resourceCard.labels.license' | translate }}
29+
<a class="font-bold" [attr.href]="nodeLicense!.absoluteUrl || null">{{ nodeLicense!.name }}</a>
30+
</p>
31+
}
32+
33+
@if (resourceValue.absoluteUrl) {
34+
<p>
35+
{{ 'resourceCard.labels.url' | translate }}
36+
<a class="font-bold" [href]="resourceValue.absoluteUrl">{{ resourceValue.absoluteUrl }}</a>
37+
</p>
38+
}
39+
40+
@if (resourceValue.doi.length > 0) {
41+
<p>
42+
{{ 'resourceCard.labels.doi' | translate }}
43+
@for (doi of resourceValue.doi.slice(0, limit); track $index) {
44+
<a class="font-bold" [href]="doi" target="_blank">{{ doi }}{{ $last ? '' : ', ' }}</a>
45+
}
46+
@if (resourceValue.doi.length > limit) {
47+
<span>{{ 'resourceCard.andCountMore' | translate: { count: resourceValue.doi.length - limit } }} </span>
48+
}
49+
</p>
50+
}
51+
</div>

src/app/shared/components/resource-card/components/file-secondary-metadata/file-secondary-metadata.component.scss

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { FileSecondaryMetadataComponent } from './file-secondary-metadata.component';
4+
5+
describe.skip('FileSecondaryMetadataComponent', () => {
6+
let component: FileSecondaryMetadataComponent;
7+
let fixture: ComponentFixture<FileSecondaryMetadataComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [FileSecondaryMetadataComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(FileSecondaryMetadataComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
3+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
4+
5+
import { Resource } from '@shared/models';
6+
7+
@Component({
8+
selector: 'osf-file-secondary-metadata',
9+
imports: [TranslatePipe],
10+
templateUrl: './file-secondary-metadata.component.html',
11+
styleUrl: './file-secondary-metadata.component.scss',
12+
changeDetection: ChangeDetectionStrategy.OnPush,
13+
})
14+
export class FileSecondaryMetadataComponent {
15+
resource = input.required<Resource>();
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<div class="flex flex-column gap-2">
2+
@let resourceValue = resource();
3+
@if (resourceValue.description) {
4+
<p>{{ 'resourceCard.labels.description' | translate }} {{ resourceValue.description }}</p>
5+
}
6+
7+
@if (resourceValue.provider) {
8+
<p>
9+
{{ 'resourceCard.labels.provider' | translate }}
10+
<a class="font-bold" [href]="resourceValue.provider!.absoluteUrl">{{ resourceValue.provider!.name }}</a>
11+
</p>
12+
}
13+
14+
@if (resourceValue.hasDataResource) {
15+
<p>
16+
{{ 'resourceCard.labels.associatedData' | translate }}
17+
<a class="font-bold" [href]="resourceValue.hasDataResource">
18+
{{ resourceValue.hasDataResource }}
19+
</a>
20+
</p>
21+
}
22+
23+
@if (resourceValue.hasPreregisteredAnalysisPlan) {
24+
<p>
25+
{{ 'resourceCard.labels.associatedAnalysisPlan' | translate }}
26+
<a class="font-bold" [href]="resourceValue.hasPreregisteredAnalysisPlan">
27+
{{ resourceValue.hasPreregisteredAnalysisPlan }}
28+
</a>
29+
</p>
30+
}
31+
32+
@if (resourceValue.hasPreregisteredStudyDesign) {
33+
<p>
34+
{{ 'resourceCard.labels.associatedStudyDesign' | translate }}
35+
<a class="font-bold" [href]="resourceValue.hasPreregisteredStudyDesign">
36+
{{ resourceValue.hasPreregisteredStudyDesign }}
37+
</a>
38+
</p>
39+
}
40+
41+
@if (resourceValue.statedConflictOfInterest) {
42+
<p>
43+
{{ 'resourceCard.labels.conflictOfInterestResponse' | translate }}
44+
{{ resourceValue.statedConflictOfInterest }}
45+
</p>
46+
} @else {
47+
<p>
48+
{{ 'resourceCard.labels.conflictOfInterestResponse' | translate }}
49+
{{ 'resourceCard.labels.noCoi' | translate }}
50+
</p>
51+
}
52+
53+
@if (resourceValue.license?.absoluteUrl) {
54+
<p>
55+
{{ 'resourceCard.labels.license' | translate }}
56+
<a class="font-bold" [attr.href]="resourceValue.license!.absoluteUrl || null">{{
57+
resourceValue.license!.name
58+
}}</a>
59+
</p>
60+
}
61+
62+
@if (resourceValue.absoluteUrl) {
63+
<p>
64+
{{ 'resourceCard.labels.url' | translate }}
65+
<a class="font-bold" [href]="resourceValue.absoluteUrl">{{ resourceValue.absoluteUrl }}</a>
66+
</p>
67+
}
68+
69+
@let limit = 4;
70+
@if (resourceValue.doi.length > 0) {
71+
<p>
72+
{{ 'resourceCard.labels.doi' | translate }}
73+
@for (doi of resourceValue.doi.slice(0, limit); track $index) {
74+
<a class="font-bold" [href]="doi" target="_blank">{{ doi }}{{ $last ? '' : ', ' }}</a>
75+
}
76+
@if (resourceValue.doi.length > limit) {
77+
<span>{{ 'resourceCard.andCountMore' | translate: { count: resourceValue.doi.length - limit } }} </span>
78+
}
79+
</p>
80+
}
81+
</div>

src/app/shared/components/resource-card/components/preprint-secondary-metadata/preprint-secondary-metadata.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { PreprintSecondaryMetadataComponent } from './preprint-secondary-metadata.component';
4+
5+
describe.skip('PreprintSecondaryMetadataComponent', () => {
6+
let component: PreprintSecondaryMetadataComponent;
7+
let fixture: ComponentFixture<PreprintSecondaryMetadataComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [PreprintSecondaryMetadataComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(PreprintSecondaryMetadataComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
3+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
4+
5+
import { Resource } from '@shared/models';
6+
7+
@Component({
8+
selector: 'osf-preprint-secondary-metadata',
9+
imports: [TranslatePipe],
10+
templateUrl: './preprint-secondary-metadata.component.html',
11+
styleUrl: './preprint-secondary-metadata.component.scss',
12+
changeDetection: ChangeDetectionStrategy.OnPush,
13+
})
14+
export class PreprintSecondaryMetadataComponent {
15+
resource = input.required<Resource>();
16+
}

0 commit comments

Comments
 (0)