diff --git a/client/components/Events/EventItem.tsx b/client/components/Events/EventItem.tsx index 7371a3c13..f61570239 100644 --- a/client/components/Events/EventItem.tsx +++ b/client/components/Events/EventItem.tsx @@ -22,6 +22,7 @@ import {renderFields} from '../fields'; import {CreatedUpdatedColumn} from '../UI/List/CreatedUpdatedColumn'; import {EventDateTimeColumn} from './EventDateTimeColumn'; import * as actions from '../../actions'; +import {getUserInterfaceLanguageFromCV} from '../../utils/users'; interface IState { hover: boolean; @@ -157,6 +158,7 @@ class EventItemComponent extends React.Component { active, refNode, listViewType, + filterLanguage } = this.props; if (!item) { @@ -178,6 +180,7 @@ class EventItemComponent extends React.Component { const isExpired = isItemExpired(item); const secondaryFields = get(listFields, 'event.secondary_fields', EVENTS.LIST.SECONDARY_FIELDS); + const language = filterLanguage || item.language || getUserInterfaceLanguageFromCV(); return ( { {renderFields(get(listFields, 'event.primary_fields', - EVENTS.LIST.PRIMARY_FIELDS), item, this.props)} + EVENTS.LIST.PRIMARY_FIELDS), item, {}, language)} diff --git a/client/components/Planning/PlanningItem.tsx b/client/components/Planning/PlanningItem.tsx index cb34c22e0..b651f19e3 100644 --- a/client/components/Planning/PlanningItem.tsx +++ b/client/components/Planning/PlanningItem.tsx @@ -32,6 +32,7 @@ import { } from '../../utils'; import {renderFields} from '../fields'; import * as actions from '../../actions'; +import {getUserInterfaceLanguageFromCV} from '../../utils/users'; interface IState { hover: boolean; @@ -185,6 +186,7 @@ class PlanningItemComponent extends React.Component { agendas, contacts, listViewType, + filterLanguage } = this.props; if (!item) { @@ -198,6 +200,7 @@ class PlanningItemComponent extends React.Component { const isExpired = isItemExpired(item); const secondaryFields = get(listFields, 'planning.secondary_fields', PLANNING.LIST.SECONDARY_FIELDS); const {querySelectorParent} = superdeskApi.utilities; + const language = filterLanguage || item.language || getUserInterfaceLanguageFromCV(); return ( { {renderFields(get(listFields, 'planning.primary_fields', - PLANNING.LIST.PRIMARY_FIELDS), item, this.props)} + PLANNING.LIST.PRIMARY_FIELDS), item, {}, language)} {event && ( diff --git a/client/components/fields/headline.tsx b/client/components/fields/headline.tsx index 909b8e076..cd341cb19 100644 --- a/client/components/fields/headline.tsx +++ b/client/components/fields/headline.tsx @@ -2,8 +2,8 @@ import PropTypes from 'prop-types'; import {getTranslatedValue} from '.'; import {IFieldsProps} from '../../interfaces'; -export const headline = ({item, filterLanguage}: IFieldsProps) => getTranslatedValue( - filterLanguage, item, 'headline') || item.headline || null; +export const headline = ({item, language}: IFieldsProps) => getTranslatedValue( + language, item, 'headline') || item.headline || null; headline.propTypes = { item: PropTypes.shape({ diff --git a/client/components/fields/index.tsx b/client/components/fields/index.tsx index 334205e76..09bdca993 100644 --- a/client/components/fields/index.tsx +++ b/client/components/fields/index.tsx @@ -3,7 +3,6 @@ import {sortBy} from 'lodash'; import {IEventOrPlanningItem, IProfileSchema, IRenderPanelType, ISearchProfile, PREVIEW_PANEL} from '../../interfaces'; import {superdeskApi} from '../../superdeskApi'; -import {getUserInterfaceLanguageFromCV} from '../../utils/users'; import {name} from './name'; import {slugline} from './slugline'; @@ -45,9 +44,12 @@ export function registerField(id, component) { * @param {Object} item * @param {Object} props */ -export function renderFields(fields, item, props = {filterLanguage: ''}) { - const language = getUserInterfaceLanguageFromCV(); - +export function renderFields( + fields:Array|string, + item:IEventOrPlanningItem, + props:Object = {}, + language:string = "" +) { return (Array.isArray(fields) ? fields : [fields]).map((id) => { const Component = registeredFields[id]; diff --git a/client/components/fields/name.tsx b/client/components/fields/name.tsx index f29299164..b99753214 100644 --- a/client/components/fields/name.tsx +++ b/client/components/fields/name.tsx @@ -2,12 +2,12 @@ import PropTypes from 'prop-types'; import {getTranslatedValue} from '.'; import {IFieldsProps} from '../../interfaces'; -export const name = ({item, filterLanguage}: IFieldsProps) => getTranslatedValue(filterLanguage, item, 'name') || +export const name = ({item, language}: IFieldsProps) => getTranslatedValue(language, item, 'name') || item.name || null; name.propTypes = { item: PropTypes.shape({ name: PropTypes.string, }).isRequired, - filterLanguage: PropTypes.string, + language: PropTypes.string, }; diff --git a/client/components/fields/slugline.tsx b/client/components/fields/slugline.tsx index 5e5bb3317..6e9ab5b16 100644 --- a/client/components/fields/slugline.tsx +++ b/client/components/fields/slugline.tsx @@ -5,13 +5,13 @@ import {get} from 'lodash'; import {getTranslatedValue} from '.'; import {IFieldsProps} from '../../interfaces'; -export const slugline = ({item, filterLanguage}: IFieldsProps) => { +export const slugline = ({item, language}: IFieldsProps) => { if (!get(item, 'slugline', '')) { return null; } return ( - {getTranslatedValue(filterLanguage, item, 'slugline') || + {getTranslatedValue(language, item, 'slugline') || item.slugline} ); }; diff --git a/client/interfaces.ts b/client/interfaces.ts index ce6be1e1f..13d159f3f 100644 --- a/client/interfaces.ts +++ b/client/interfaces.ts @@ -1583,7 +1583,7 @@ export interface IContentTemplate extends IBaseRestApiResponse { export interface IFieldsProps { item: IEventOrPlanningItem; - filterLanguage?: string; + language?: string; } interface IMainStateSearch {