Skip to content

Commit

Permalink
Added support for boolean parameters in annotations actions (#8798)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Dec 10, 2024
1 parent 15fd273 commit 17016de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.d/20241209_110126_sekachev.bs_support_boolean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Added

- Support for boolean parameters in annotations actions
(<https://github.com/cvat-ai/cvat/pull/8798>)
1 change: 1 addition & 0 deletions cvat-core/src/annotations-actions/base-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Job, Task } from '../session';
export enum ActionParameterType {
SELECT = 'select',
NUMBER = 'number',
CHECKBOX = 'checkbox',
}

// For SELECT values should be a list of possible options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import { getCVATStore } from 'cvat-store';
import {
BaseCollectionAction, BaseAction, Job, getCore,
ObjectState,
ActionParameterType,
} from 'cvat-core-wrapper';
import { Canvas } from 'cvat-canvas-wrapper';
import { fetchAnnotationsAsync } from 'actions/annotation-actions';
import { clamp } from 'utils/math';
import { Switch } from 'antd/lib';

const core = getCore();

Expand Down Expand Up @@ -248,7 +250,7 @@ function ActionParameterComponent(props: ActionParameterProps & { onChange: (val

const computedValues = typeof values === 'function' ? values({ instance: job }) : values;

if (type === 'select') {
if (type === ActionParameterType.SELECT) {
return (
<Select value={value} onChange={setValue}>
{computedValues.map((_value: string) => (
Expand All @@ -258,8 +260,18 @@ function ActionParameterComponent(props: ActionParameterProps & { onChange: (val
);
}

const [min, max, step] = computedValues.map((val) => +val);
if (type === ActionParameterType.CHECKBOX) {
return (
<Switch
checked={value.toLowerCase() === 'true'}
onChange={(val: boolean) => {
setValue(String(val));
}}
/>
);
}

const [min, max, step] = computedValues.map((val) => +val);
return (
<InputNumber
value={+value}
Expand Down

0 comments on commit 17016de

Please sign in to comment.