Setup tag forward to the state

main
Dmitry Kalinin 6 years ago
parent 6acda049a8
commit f468c4035f

@ -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,

@ -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 {
</Row>
<Row type='flex' justify='space-around'>
<Col span={24}>
<Button onClick={onSetup}>
<Button onClick={() => onSetup(selectedLabeID)}>
Tag
</Button>
</Col>

@ -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<Props, State> {
});
};
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<Props, State> {
labels,
} = this.props;
this.onSetup = this.onSetup.bind(this);
return (
<SetupTagPopoverComponent
labels={labels}

@ -418,6 +418,29 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
},
};
}
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

Loading…
Cancel
Save