Skip to content

Commit

Permalink
add open badges list to registration search results
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Aug 9, 2023
1 parent 80689e9 commit f0e604d
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 37 deletions.
20 changes: 20 additions & 0 deletions app/models/search-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ export default class SearchResultModel extends Model {
}
return 'unknown';
}

get hasDataResource() {
return this.resourceMetadata.hasDataResource;
}

get hasAnalyticCodeResource() {
return this.resourceMetadata.hasAnalyticCodeResource;
}

get hasMaterialsResource() {
return this.resourceMetadata.hasMaterialsResource;
}

get hasPapersResource() {
return this.resourceMetadata.hasPapersResource;
}

get hasSupplementalResource() {
return this.resourceMetadata.hasSupplementalResource;
}
}

declare module 'ember-data/types/registries/model' {
Expand Down
1 change: 1 addition & 0 deletions lib/osf-components/addon/components/node-card/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
@hasPapers={{@node.hasPapers}}
@hasSupplements={{@node.hasSupplements}}
@registration={{@node.id}}
@verticalLayout={{true}}
/>
</div>
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
font-weight: 700;
margin-top: 0;
}

.horizontal-layout {
display: flex;
gap: 10px;
}
112 changes: 75 additions & 37 deletions lib/osf-components/addon/components/open-badges-list/template.hbs
Original file line number Diff line number Diff line change
@@ -1,37 +1,75 @@
<div data-test-badge-list local-class='badgeList'>
{{#unless this.isMobile}}
<h5 data-test-badge-list-title local-class='title'>
{{t 'osf-components.open-badges-list.title'}}
</h5>
{{/unless}}
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasData}}
@resourceType='data'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasAnalyticCode}}
@resourceType='analytic_code'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasMaterials}}
@resourceType='materials'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasPapers}}
@resourceType='papers'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasSupplements}}
@resourceType='supplements'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
</div>
{{#if @verticalLayout}}
<div data-test-badge-list local-class='badgeList'>
{{#unless this.isMobile}}
<h5 data-test-badge-list-title local-class='title'>
{{t 'osf-components.open-badges-list.title'}}
</h5>
{{/unless}}
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasData}}
@resourceType='data'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasAnalyticCode}}
@resourceType='analytic_code'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasMaterials}}
@resourceType='materials'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasPapers}}
@resourceType='papers'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasSupplements}}
@resourceType='supplements'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
</div>
{{else}}
<h5 data-test-badge-list-title local-class='title'>
{{t 'osf-components.open-badges-list.title'}}
</h5>
<div local-class='horizontal-layout'>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasData}}
@resourceType='data'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasAnalyticCode}}
@resourceType='analytic_code'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasMaterials}}
@resourceType='materials'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasPapers}}
@resourceType='papers'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
<OpenBadgesList::OpenBadgeCard
@hasResource={{@hasSupplements}}
@resourceType='supplements'
@isMobile={{this.isMobile}}
@registration={{@registration}}
/>
</div>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
<span>{{t 'osf-components.search-result-card.context'}}: {{@result.context}}</span>
</div>
{{/if}}
{{#if (or (eq @result.resourceType 'registration') (eq @result.resourceType 'registration_component'))}}
<OpenBadgesList
@hasData={{@result.hasDataResource}}
@hasMaterials={{@result.hasMaterialsResource}}
@hasAnalyticCode={{@result.hasAnalyticCodeResource}}
@hasPapers={{@result.hasPapersResource}}
@hasSupplements={{@result.hasSupplementsResource}}
@registration={{'abcde'}}
@verticalLayout={{false}}
/>
{{/if}}
</div>
<CpPanel @open={{this.isOpenSecondaryMetadata}} as |panel|>
<panel.body>
Expand Down

0 comments on commit f0e604d

Please sign in to comment.