Skip to content

Commit

Permalink
Update Preprint label to Paper for yale law school
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda authored and bp-cos committed Dec 7, 2023
1 parent 9dc1473 commit 0f67de3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
9 changes: 8 additions & 1 deletion lib/osf-components/addon/components/search-page/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ export default class SearchPage extends Component<SearchArgs> {
return this.sortOptions.find(option => option.value === this.sort);// || this.sortOptions[0];
}

get preprintLabel() {
if (this.args.institution?.id === 'yls') {
return this.intl.t('documentType.paper.pluralCapitalized');
}
return this.intl.t('search.resource-type.preprints');
}

// Resource type
defaultResourceTypeOptions: ResourceTypeOption[] = [
{
Expand All @@ -173,7 +180,7 @@ export default class SearchPage extends Component<SearchArgs> {
value: ResourceTypeFilterValue.Registrations,
},
{
display: this.intl.t('search.resource-type.preprints'),
display: this.preprintLabel,
value: ResourceTypeFilterValue.Preprints,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ as |layout|>
<LoadingIndicator @size='large' @dark={{true}} />
{{else}}
{{#each this.searchResults as |item|}}
<SearchResultCard @result={{item}} @provider={{@provider}} />
<SearchResultCard @result={{item}} @provider={{@provider}} @institution={{@institution}} />
{{else}}
<div local-class='no-results'>
<p data-test-search-page-no-results>{{t 'search.no-results'}}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Intl from 'ember-intl/services/intl';

import SearchResultModel from 'ember-osf-web/models/search-result';
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
import InstitutionModel from 'ember-osf-web/models/institution';


const CardLabelTranslationKeys = {
Expand All @@ -23,6 +24,7 @@ const CardLabelTranslationKeys = {
interface Args {
result: SearchResultModel;
provider?: PreprintProviderModel;
institution?: InstitutionModel;
}

export default class SearchResultCard extends Component<Args> {
Expand All @@ -37,10 +39,17 @@ export default class SearchResultCard extends Component<Args> {
}

get cardTypeLabel() {
const provider = this.args.provider;
const { provider, institution } = this.args;
const resourceType = this.args.result.resourceType;
return (provider?.preprintWord && resourceType === 'preprint') ? provider.documentType.singularCapitalized :
this.intl.t(CardLabelTranslationKeys[resourceType]);
if (resourceType === 'preprint') {
if (institution?.id === 'yls') {
return this.intl.t('documentType.paper.singularCapitalized');
}
if (provider?.preprintWord) {
return provider.documentType.singularCapitalized;
}
}
return this.intl.t(CardLabelTranslationKeys[resourceType]);
}

get secondaryMetadataComponent() {
Expand Down
2 changes: 2 additions & 0 deletions mirage/factories/institution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default Factory.extend<Institution & InstitutionTraits>({
},
iri: faker.internet.url,
rorIri: faker.internet.url,
iris: [faker.internet.url],

withMetrics: trait<Institution>({
afterCreate(institution, server) {
const userMetrics = server.createList('institution-user', 15);
Expand Down

0 comments on commit 0f67de3

Please sign in to comment.