Skip to content

Commit

Permalink
[ENG-4838] Update search-result card to show preprint word (#2036)
Browse files Browse the repository at this point in the history
* Update search-result card to show preprint word for preprint discover page

* Update provider word for preprint secondary metadata

* Use translation map

* Use translation for preprintWord
  • Loading branch information
futa-ikeda authored Oct 23, 2023
1 parent 1fd3177 commit 9f5c1e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
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}} />
<SearchResultCard @result={{item}} @provider={{@provider}} />
{{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 @@ -6,26 +6,41 @@ import { tracked } from '@glimmer/tracking';
import Intl from 'ember-intl/services/intl';

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


const CardLabelTranslationKeys = {
project: 'osf-components.search-result-card.project',
project_component: 'osf-components.search-result-card.project_component',
registration: 'osf-components.search-result-card.registration',
registration_component: 'osf-components.search-result-card.registration_component',
preprint: 'osf-components.search-result-card.preprint',
file: 'osf-components.search-result-card.file',
user: 'osf-components.search-result-card.user',
unknown: 'osf-components.search-result-card.unknown',
};

interface Args {
result: SearchResultModel;
provider?: PreprintProviderModel;
}

export default class SearchResultCard extends Component<Args> {
@service intl!: Intl;
@service store!: Store;

@tracked isOpenSecondaryMetadata = false;
@tracked osfUser?: UserModel;

@action
toggleSecondaryMetadata() {
this.isOpenSecondaryMetadata = !this.isOpenSecondaryMetadata;
}

get cardTypeLabel() {
return this.intl.t(`osf-components.search-result-card.${this.args.result.resourceType}`);
const provider = this.args.provider;
const resourceType = this.args.result.resourceType;
return (provider?.preprintWord && resourceType === 'preprint') ? provider.documentType.singularCapitalized :
this.intl.t(CardLabelTranslationKeys[resourceType]);
}

get secondaryMetadataComponent() {
Expand Down
2 changes: 1 addition & 1 deletion translations/en-us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ osf-components:
date_modified: Date modified
last_edited: Last edited
member_since: Member since
preprint_provider: Preprint provider
preprint_provider: Provider
registration_provider: Registration provider
conflict_of_interest: Conflict of Interest response
no_conflict_of_interest: 'Author asserted no Conflict of Interest'
Expand Down

0 comments on commit 9f5c1e3

Please sign in to comment.