From 9f5c1e3192fb4b1d5742b2125df1c5d6817f4c9c Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:32:25 -0400 Subject: [PATCH] [ENG-4838] Update search-result card to show preprint word (#2036) * 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 --- .../addon/components/search-page/template.hbs | 2 +- .../search-result-card/component.ts | 21 ++++++++++++++++--- translations/en-us.yml | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/osf-components/addon/components/search-page/template.hbs b/lib/osf-components/addon/components/search-page/template.hbs index 1c69cadb328..bd08792e367 100644 --- a/lib/osf-components/addon/components/search-page/template.hbs +++ b/lib/osf-components/addon/components/search-page/template.hbs @@ -227,7 +227,7 @@ as |layout|> {{else}} {{#each this.searchResults as |item|}} - + {{else}}

{{t 'search.no-results'}}

diff --git a/lib/osf-components/addon/components/search-result-card/component.ts b/lib/osf-components/addon/components/search-result-card/component.ts index a0af4a4941d..dab8376a399 100644 --- a/lib/osf-components/addon/components/search-result-card/component.ts +++ b/lib/osf-components/addon/components/search-result-card/component.ts @@ -6,10 +6,23 @@ 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 { @@ -17,7 +30,6 @@ export default class SearchResultCard extends Component { @service store!: Store; @tracked isOpenSecondaryMetadata = false; - @tracked osfUser?: UserModel; @action toggleSecondaryMetadata() { @@ -25,7 +37,10 @@ export default class SearchResultCard extends Component { } 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() { diff --git a/translations/en-us.yml b/translations/en-us.yml index d6a4b1533e5..54294828069 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -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'