Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Dec 19, 2024
1 parent 978a0f7 commit fb4eeab
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion client/components/ContentProfiles/FieldTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,15 @@ export class FieldTab extends React.Component<IProps, IState> {
{this.state.selectedField == null ? null : (
<FieldEditor
key={this.state.selectedField?.name}
item={this.state.selectedField}
item={(() => {
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)}
Expand Down
2 changes: 1 addition & 1 deletion client/components/fields/editor/base/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Checkbox} from 'superdesk-ui-framework/react';
export class EditorFieldCheckbox extends React.PureComponent<IEditorFieldProps> {
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 (
<Row testId={this.props.testId}>
Expand Down
4 changes: 4 additions & 0 deletions client/components/fields/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion client/components/fields/resources/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,6 @@ export interface ISearchFilter extends IBaseRestApiResponse {
export interface IEditorFieldProps {
item: any;
field: string;
valueOverwrite?: boolean;
label?: string;
required?: boolean;
disabled?: boolean;
Expand Down

0 comments on commit fb4eeab

Please sign in to comment.