From fb4eeab7c54014bcf679e8f39b8a65e4643e4d05 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 19 Dec 2024 13:26:32 +0200 Subject: [PATCH] Improvements --- client/components/ContentProfiles/FieldTab/index.tsx | 10 +++++++++- client/components/fields/editor/base/checkbox.tsx | 2 +- client/components/fields/editor/index.tsx | 4 ++++ client/components/fields/resources/profiles.ts | 1 - client/interfaces.ts | 1 - 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/components/ContentProfiles/FieldTab/index.tsx b/client/components/ContentProfiles/FieldTab/index.tsx index 9385eedf9..6859dd63f 100644 --- a/client/components/ContentProfiles/FieldTab/index.tsx +++ b/client/components/ContentProfiles/FieldTab/index.tsx @@ -263,7 +263,15 @@ export class FieldTab extends React.Component { {this.state.selectedField == null ? null : ( { + const profileRes = cloneDeep(this.state.selectedField); + + if (profileRes.schema?.required === true) { + profileRes.schema.show_in_embedded_editor = true; + } + + return profileRes; + })()} profile={this.props.profile} isDirty={this.isEditorDirty()} disableMinMax={this.props.disableMinMaxFields?.includes(this.state.selectedField.name)} diff --git a/client/components/fields/editor/base/checkbox.tsx b/client/components/fields/editor/base/checkbox.tsx index 3ec68e8d4..5afda70fb 100644 --- a/client/components/fields/editor/base/checkbox.tsx +++ b/client/components/fields/editor/base/checkbox.tsx @@ -8,7 +8,7 @@ import {Checkbox} from 'superdesk-ui-framework/react'; export class EditorFieldCheckbox extends React.PureComponent { render() { const field = this.props.field; - const value = this.props.valueOverwrite ?? get(this.props.item, field, this.props.defaultValue); + const value = get(this.props.item, field, this.props.defaultValue); return ( diff --git a/client/components/fields/editor/index.tsx b/client/components/fields/editor/index.tsx index 52aecf12b..7b911a885 100644 --- a/client/components/fields/editor/index.tsx +++ b/client/components/fields/editor/index.tsx @@ -54,6 +54,10 @@ import {EditorFieldScheduledUpdates} from './ScheduledUpdates'; import {EditorFieldCustomVocabularies} from './CustomVocabularies'; import {EditorFieldAssignedCoverageComponent} from './AssignedCoverage'; +/** + * This is the single source of truth for field definitions, allows for registering + * other fields from a different through `registerEditorField` + */ export const FIELD_TO_EDITOR_COMPONENT = { anpa_category: EditorFieldCategories, featured: EditorFieldFeatured, diff --git a/client/components/fields/resources/profiles.ts b/client/components/fields/resources/profiles.ts index 54467f424..a496e09aa 100644 --- a/client/components/fields/resources/profiles.ts +++ b/client/components/fields/resources/profiles.ts @@ -31,7 +31,6 @@ registerEditorField( label: superdeskApi.localization.gettext('Show in embedded form'), field: 'schema.show_in_embedded_editor', disabled: props.item.schema.required, - valueOverwrite: props.item.schema.required === true ? true : undefined, }), null, true diff --git a/client/interfaces.ts b/client/interfaces.ts index a74a179b2..3aa16fd2f 100644 --- a/client/interfaces.ts +++ b/client/interfaces.ts @@ -1546,7 +1546,6 @@ export interface ISearchFilter extends IBaseRestApiResponse { export interface IEditorFieldProps { item: any; field: string; - valueOverwrite?: boolean; label?: string; required?: boolean; disabled?: boolean;