diff --git a/cvat-ui/src/actions/annotation-actions.ts b/cvat-ui/src/actions/annotation-actions.ts index bc49fb02..b3d0eabf 100644 --- a/cvat-ui/src/actions/annotation-actions.ts +++ b/cvat-ui/src/actions/annotation-actions.ts @@ -85,6 +85,7 @@ export enum AnnotationActionTypes { EDIT_SHAPE = 'EDIT_SHAPE', DRAW_SHAPE = 'DRAW_SHAPE', SHAPE_DRAWN = 'SHAPE_DRAWN', + SETUP_TAG = 'SETUP_TAG', RESET_CANVAS = 'RESET_CANVAS', UPDATE_ANNOTATIONS_SUCCESS = 'UPDATE_ANNOTATIONS_SUCCESS', UPDATE_ANNOTATIONS_FAILED = 'UPDATE_ANNOTATIONS_FAILED', @@ -855,6 +856,20 @@ export function drawShape( }; } +export function setupTag( + labelID: number, + objectType: ObjectType, +): AnyAction { + return { + type: AnnotationActionTypes.SETUP_TAG, + payload: { + labelID, + objectType, + activeControl: ActiveControl.SETUP_TAG, + }, + }; +} + export function shapeDrawn(): AnyAction { return { type: AnnotationActionTypes.SHAPE_DRAWN, diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx index 810b5b5e..3edaa2aa 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx @@ -17,7 +17,9 @@ interface Props { labels: any[]; selectedLabeID: number; onChangeLabel(value: string): void; - onSetup(): void; + onSetup( + labelID: number, + ): void; } function setupTagPopover(props: Props): JSX.Element { @@ -61,7 +63,7 @@ function setupTagPopover(props: Props): JSX.Element { - diff --git a/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx b/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx index c6d42bf3..5714bc0a 100644 --- a/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx +++ b/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover.tsx @@ -7,13 +7,19 @@ import { connect } from 'react-redux'; import { CombinedState, + ObjectType, } from 'reducers/interfaces'; +import { + setupTag +} from 'actions/annotation-actions'; import { Canvas } from 'cvat-canvas'; import SetupTagPopoverComponent from 'components/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover'; interface DispatchToProps { - onTagSetup(): void; + onTagSetup( + labelID: number, + ): void; } interface StateToProps { @@ -23,8 +29,10 @@ interface StateToProps { function mapDispatchToProps(dispatch: any): DispatchToProps { return { - onTagSetup(): void { - dispatch(); + onTagSetup( + labelID: number, + ): void { + dispatch(setupTag(labelID, ObjectType.TAG)); }, }; } @@ -47,7 +55,7 @@ function mapStateToProps(state: CombinedState): StateToProps { }; } -type Props = StateToProps; +type Props = StateToProps & DispatchToProps; interface State { selectedLabelID: number; @@ -69,10 +77,11 @@ class DrawShapePopoverContainer extends React.PureComponent { }); }; - private onSetup(): void { - const { canvasInstance } = this.props; + private onSetup(labelID: number): void { + const { canvasInstance, onTagSetup } = this.props; canvasInstance.cancel(); + onTagSetup(labelID); } public render(): JSX.Element { @@ -84,6 +93,8 @@ class DrawShapePopoverContainer extends React.PureComponent { labels, } = this.props; + this.onSetup = this.onSetup.bind(this); + return ( { }, }; } + case AnnotationActionTypes.SETUP_TAG: { + const { + labelID, + objectType, + activeControl, + } = action.payload; + + return { + ...state, + annotations: { + ...state.annotations, + }, + canvas: { + ...state.canvas, + activeControl, + }, + drawing: { + ...defaultState.drawing, + activeLabelID: labelID, + activeObjectType: objectType, + }, + }; + } case AnnotationActionTypes.MERGE_OBJECTS: { const { enabled } = action.payload; const activeControl = enabled