From ab1c43a93c19b93c3f4c20687be212ac1682a117 Mon Sep 17 00:00:00 2001 From: dzonidoo Date: Tue, 8 Aug 2023 16:11:55 +0200 Subject: [PATCH] create a language field if u added before inside on content manage profile for coverages --- client/components/Editor/EditorGroup.tsx | 7 +++- .../EventRelatedPlannings/AddNewCoverages.tsx | 5 ++- .../EventRelatedPlannings/CoverageRowForm.tsx | 10 ++++- .../EmbeddedCoverageForm.tsx | 40 ++++++++++--------- .../EventRelatedPlannings.tsx | 5 ++- .../RelatedPlanningItem.tsx | 5 ++- client/components/fields/index.tsx | 4 +- 7 files changed, 52 insertions(+), 24 deletions(-) diff --git a/client/components/Editor/EditorGroup.tsx b/client/components/Editor/EditorGroup.tsx index db0f41931..2addcbcba 100644 --- a/client/components/Editor/EditorGroup.tsx +++ b/client/components/Editor/EditorGroup.tsx @@ -117,6 +117,10 @@ export class EditorGroup extends React.PureComponent implements IEditorR const group = this.props.group; const testId = `editor--group__${group.id}`; const profile = this.getProfile(); + + const editor = planningApi.editor(this.props.editorType); + const coverageProfile = editor.item.planning.getCoverageFields(); + const renderedFields = renderFieldsForPanel( 'editor', profile, @@ -126,7 +130,8 @@ export class EditorGroup extends React.PureComponent implements IEditorR null, 'enabled', this.editorApi.dom.fields, - this.props.schema + this.props.schema, + coverageProfile, ); return group.useToggleBox ? ( diff --git a/client/components/fields/editor/EventRelatedPlannings/AddNewCoverages.tsx b/client/components/fields/editor/EventRelatedPlannings/AddNewCoverages.tsx index 6316f6d09..bd02f282d 100644 --- a/client/components/fields/editor/EventRelatedPlannings/AddNewCoverages.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/AddNewCoverages.tsx @@ -9,7 +9,8 @@ import { IPlanningItem, IPlanningNewsCoverageStatus, IPlanningConfig, - IPlanningContentProfile + IPlanningContentProfile, + ISearchProfile } from '../../../../interfaces'; import {IDesk, IUser} from 'superdesk-api'; @@ -26,6 +27,7 @@ interface IProps { event: IEventItem; item: DeepPartial; profile: IPlanningContentProfile; + coverageProfile?: ISearchProfile; contentTypes: Array; newsCoverageStatus: Array; desks: Array; @@ -259,6 +261,7 @@ class AddNewCoveragesComponent extends React.Component { users={this.props.users} event={this.props.event} profile={this.props.profile} + coverageProfile={this.props.coverageProfile} /> ))} diff --git a/client/components/fields/editor/EventRelatedPlannings/CoverageRowForm.tsx b/client/components/fields/editor/EventRelatedPlannings/CoverageRowForm.tsx index d55d3d44a..9ce52868d 100644 --- a/client/components/fields/editor/EventRelatedPlannings/CoverageRowForm.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/CoverageRowForm.tsx @@ -1,7 +1,13 @@ import * as React from 'react'; import {IDesk, IUser} from 'superdesk-api'; -import {IEventItem, IG2ContentType, IPlanningContentProfile, IPlanningNewsCoverageStatus} from '../../../../interfaces'; +import { + IEventItem, + IG2ContentType, + IPlanningContentProfile, + IPlanningNewsCoverageStatus, + ISearchProfile +} from '../../../../interfaces'; import {planningUtils} from '../../../../utils'; import {getVocabularyItemFieldTranslated} from '../../../../utils/vocabularies'; @@ -37,6 +43,7 @@ interface IProps { users: Array; event: IEventItem; profile: IPlanningContentProfile; + coverageProfile?: ISearchProfile; } function getCoverageIconName(type: IG2ContentType): string { @@ -134,6 +141,7 @@ export class CoverageRowForm extends React.PureComponent { update={this.update} event={this.props.event} profile={this.props.profile} + coverageProfile={this.props.coverageProfile} /> )} diff --git a/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx b/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx index 46ee09151..a394bce86 100644 --- a/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/EmbeddedCoverageForm.tsx @@ -6,7 +6,8 @@ import { IPlanningNewsCoverageStatus, IPlanningConfig, IPlanningContentProfile, - IEventItem + IEventItem, + ISearchProfile } from '../../../../interfaces'; import {ICoverageDetails} from './CoverageRowForm'; import {superdeskApi, planningApi} from '../../../../superdeskApi'; @@ -29,6 +30,7 @@ interface IProps { languages: Array<{value: IVocabularyItem}>; event: IEventItem; profile: IPlanningContentProfile; + coverageProfile?: ISearchProfile; update(updates: Partial): void; } @@ -181,23 +183,25 @@ export class EmbeddedCoverageFormComponent extends React.PureComponent { - + {this.props.coverageProfile.language != null && ( + + )} diff --git a/client/components/fields/editor/EventRelatedPlannings/EventRelatedPlannings.tsx b/client/components/fields/editor/EventRelatedPlannings/EventRelatedPlannings.tsx index e38238943..51aa728e8 100644 --- a/client/components/fields/editor/EventRelatedPlannings/EventRelatedPlannings.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/EventRelatedPlannings.tsx @@ -5,7 +5,8 @@ import { IEventItem, IPlanningCoverageItem, IPlanningItem, - IProfileSchemaTypeList + IProfileSchemaTypeList, + ISearchProfile } from '../../../../interfaces'; import {superdeskApi} from '../../../../superdeskApi'; @@ -19,6 +20,7 @@ import './style.scss'; interface IProps extends IEditorFieldProps { item: IEventItem; schema?: IProfileSchemaTypeList; + coverageProfile?: ISearchProfile; getRef(value: DeepPartial): React.RefObject; addPlanningItem(): void; @@ -85,6 +87,7 @@ export class EditorFieldEventRelatedPlannings extends React.PureComponent )) )} diff --git a/client/components/fields/editor/EventRelatedPlannings/RelatedPlanningItem.tsx b/client/components/fields/editor/EventRelatedPlannings/RelatedPlanningItem.tsx index 934fc51a3..cff0adbf4 100644 --- a/client/components/fields/editor/EventRelatedPlannings/RelatedPlanningItem.tsx +++ b/client/components/fields/editor/EventRelatedPlannings/RelatedPlanningItem.tsx @@ -7,7 +7,8 @@ import { IG2ContentType, IPlanningContentProfile, IPlanningCoverageItem, - IPlanningItem + IPlanningItem, + ISearchProfile } from '../../../../interfaces'; import {superdeskApi} from '../../../../superdeskApi'; @@ -27,6 +28,7 @@ interface IProps { disabled: boolean; editorType: EDITOR_TYPE; profile: IPlanningContentProfile; + coverageProfile?: ISearchProfile; removePlan(item: DeepPartial): void; updatePlanningItem( original: DeepPartial, @@ -149,6 +151,7 @@ export class RelatedPlanningItem extends React.PureComponent { item={item} updatePlanningItem={this.update} profile={this.props.profile} + coverageProfile={this.props.coverageProfile} /> )} diff --git a/client/components/fields/index.tsx b/client/components/fields/index.tsx index 3e6c16dd2..96fdbd8ab 100644 --- a/client/components/fields/index.tsx +++ b/client/components/fields/index.tsx @@ -97,7 +97,8 @@ export function renderFieldsForPanel( groupName?: string, enabledField: string = 'enabled', refs: {[key: string]: React.RefObject} = {}, - schema?: IProfileSchema + schema?: IProfileSchema, + coverageProfile?: ISearchProfile, ) { const fieldComponents = getFieldsForPanel(panelType); const fields: {[key: string]: IRenderFieldItem} = {}; @@ -109,6 +110,7 @@ export function renderFieldsForPanel( ...globalProps, testId: `field-${fieldName}`, ...fieldProps[fieldName], + coverageProfile: coverageProfile, }, name: fieldName, ...profile[fieldName],