From 490bf2f2bb0128a41ae4eba4394707413b7e761d Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Wed, 18 Dec 2024 15:43:23 +0200 Subject: [PATCH] Implement value dependency --- client/components/fields/editor/base/checkbox.tsx | 2 +- client/components/fields/resources/profiles.ts | 4 +++- client/interfaces.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/components/fields/editor/base/checkbox.tsx b/client/components/fields/editor/base/checkbox.tsx index 5afda70fb..3ec68e8d4 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 = get(this.props.item, field, this.props.defaultValue); + const value = this.props.valueOverwrite ?? get(this.props.item, field, this.props.defaultValue); return ( diff --git a/client/components/fields/resources/profiles.ts b/client/components/fields/resources/profiles.ts index f7d6ca3a4..54467f424 100644 --- a/client/components/fields/resources/profiles.ts +++ b/client/components/fields/resources/profiles.ts @@ -27,9 +27,11 @@ registerEditorField( registerEditorField( 'schema.show_in_embedded_editor', EditorFieldCheckbox, - () => ({ + (props) => ({ 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 3aa16fd2f..a74a179b2 100644 --- a/client/interfaces.ts +++ b/client/interfaces.ts @@ -1546,6 +1546,7 @@ export interface ISearchFilter extends IBaseRestApiResponse { export interface IEditorFieldProps { item: any; field: string; + valueOverwrite?: boolean; label?: string; required?: boolean; disabled?: boolean;