Skip to content

Commit

Permalink
Implement value dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Dec 18, 2024
1 parent fbba6ad commit 490bf2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
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 = get(this.props.item, field, this.props.defaultValue);
const value = this.props.valueOverwrite ?? get(this.props.item, field, this.props.defaultValue);

return (
<Row testId={this.props.testId}>
Expand Down
4 changes: 3 additions & 1 deletion client/components/fields/resources/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ 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 490bf2f

Please sign in to comment.