Skip to content

Commit

Permalink
create a language field if u added before inside on content manage pr…
Browse files Browse the repository at this point in the history
…ofile for coverages (#1838)
  • Loading branch information
dzonidoo authored Aug 17, 2023
1 parent c453929 commit 013f768
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 24 deletions.
7 changes: 6 additions & 1 deletion client/components/Editor/EditorGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export class EditorGroup extends React.PureComponent<IProps> 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,
Expand All @@ -126,7 +130,8 @@ export class EditorGroup extends React.PureComponent<IProps> implements IEditorR
null,
'enabled',
this.editorApi.dom.fields,
this.props.schema
this.props.schema,
coverageProfile,
);

return group.useToggleBox ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
IPlanningItem,
IPlanningNewsCoverageStatus,
IPlanningConfig,
IPlanningContentProfile
IPlanningContentProfile,
ISearchProfile
} from '../../../../interfaces';
import {IDesk, IUser} from 'superdesk-api';

Expand All @@ -26,6 +27,7 @@ interface IProps {
event: IEventItem;
item: DeepPartial<IPlanningItem>;
profile: IPlanningContentProfile;
coverageProfile?: ISearchProfile;
contentTypes: Array<IG2ContentType>;
newsCoverageStatus: Array<IPlanningNewsCoverageStatus>;
desks: Array<IDesk>;
Expand Down Expand Up @@ -259,6 +261,7 @@ class AddNewCoveragesComponent extends React.Component<IProps, IState> {
users={this.props.users}
event={this.props.event}
profile={this.props.profile}
coverageProfile={this.props.coverageProfile}
/>
))}
</Group>
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -37,6 +43,7 @@ interface IProps {
users: Array<IUser>;
event: IEventItem;
profile: IPlanningContentProfile;
coverageProfile?: ISearchProfile;
}

function getCoverageIconName(type: IG2ContentType): string {
Expand Down Expand Up @@ -134,6 +141,7 @@ export class CoverageRowForm extends React.PureComponent<IProps> {
update={this.update}
event={this.props.event}
profile={this.props.profile}
coverageProfile={this.props.coverageProfile}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
IPlanningNewsCoverageStatus,
IPlanningConfig,
IPlanningContentProfile,
IEventItem
IEventItem,
ISearchProfile
} from '../../../../interfaces';
import {ICoverageDetails} from './CoverageRowForm';
import {superdeskApi, planningApi} from '../../../../superdeskApi';
Expand All @@ -29,6 +30,7 @@ interface IProps {
languages: Array<{value: IVocabularyItem}>;
event: IEventItem;
profile: IPlanningContentProfile;
coverageProfile?: ISearchProfile;

update(updates: Partial<ICoverageDetails>): void;
}
Expand Down Expand Up @@ -181,23 +183,25 @@ export class EmbeddedCoverageFormComponent extends React.PureComponent<IProps> {
</List.Row>
<List.Row>
<Row>
<Select
label={gettext('Language:')}
value={language}
onChange={(item) => this.onLanguageChange(item)}
>
<Option />
{allLanguages.map(
(language) => (
<Option
key={language.value.qcode}
value={language.value.qcode}
>
{language.value.name}
</Option>
)
)}
</Select>
{this.props.coverageProfile.language != null && (
<Select
label={gettext('Language:')}
value={language}
onChange={(item) => this.onLanguageChange(item)}
>
<Option />
{allLanguages.map(
(language) => (
<Option
key={language.value.qcode}
value={language.value.qcode}
>
{language.value.name}
</Option>
)
)}
</Select>
)}
</Row>
</List.Row>
<List.Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
IEventItem,
IPlanningCoverageItem,
IPlanningItem,
IProfileSchemaTypeList
IProfileSchemaTypeList,
ISearchProfile
} from '../../../../interfaces';
import {superdeskApi} from '../../../../superdeskApi';

Expand All @@ -19,6 +20,7 @@ import './style.scss';
interface IProps extends IEditorFieldProps {
item: IEventItem;
schema?: IProfileSchemaTypeList;
coverageProfile?: ISearchProfile;

getRef(value: DeepPartial<IPlanningItem>): React.RefObject<PlanningMetaData | RelatedPlanningItem>;
addPlanningItem(): void;
Expand Down Expand Up @@ -85,6 +87,7 @@ export class EditorFieldEventRelatedPlannings extends React.PureComponent<IProps
disabled={false}
editorType={this.props.editorType}
profile={this.props.profile}
coverageProfile={this.props.coverageProfile}
/>
))
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
IG2ContentType,
IPlanningContentProfile,
IPlanningCoverageItem,
IPlanningItem
IPlanningItem,
ISearchProfile
} from '../../../../interfaces';
import {superdeskApi} from '../../../../superdeskApi';

Expand All @@ -27,6 +28,7 @@ interface IProps {
disabled: boolean;
editorType: EDITOR_TYPE;
profile: IPlanningContentProfile;
coverageProfile?: ISearchProfile;
removePlan(item: DeepPartial<IPlanningItem>): void;
updatePlanningItem(
original: DeepPartial<IPlanningItem>,
Expand Down Expand Up @@ -149,6 +151,7 @@ export class RelatedPlanningItem extends React.PureComponent<IProps> {
item={item}
updatePlanningItem={this.update}
profile={this.props.profile}
coverageProfile={this.props.coverageProfile}
/>
</Row>
)}
Expand Down
4 changes: 3 additions & 1 deletion client/components/fields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export function renderFieldsForPanel(
groupName?: string,
enabledField: string = 'enabled',
refs: {[key: string]: React.RefObject<any>} = {},
schema?: IProfileSchema
schema?: IProfileSchema,
coverageProfile?: ISearchProfile,
) {
const fieldComponents = getFieldsForPanel(panelType);
const fields: {[key: string]: IRenderFieldItem} = {};
Expand All @@ -109,6 +110,7 @@ export function renderFieldsForPanel(
...globalProps,
testId: `field-${fieldName}`,
...fieldProps[fieldName],
coverageProfile: coverageProfile,
},
name: fieldName,
...profile[fieldName],
Expand Down

0 comments on commit 013f768

Please sign in to comment.