Skip to content
Snippets Groups Projects
Commit 5dafb4a8 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-7583 : ObjectTypeForm - automatically select an object that is being dragged

parent 8bb84447
No related branches found
No related tags found
No related merge requests found
...@@ -25,11 +25,23 @@ const styles = theme => ({ ...@@ -25,11 +25,23 @@ const styles = theme => ({
class ObjectTypePreview extends React.PureComponent { class ObjectTypePreview extends React.PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = {}
this.handleDragStart = this.handleDragStart.bind(this)
this.handleDragEnd = this.handleDragEnd.bind(this) this.handleDragEnd = this.handleDragEnd.bind(this)
this.handleClick = this.handleClick.bind(this) this.handleClick = this.handleClick.bind(this)
} }
handleDragStart(start) {
this.setState({ dragging: true })
this.props.onSelectionChange(start.type, {
id: start.draggableId
})
}
handleDragEnd(result) { handleDragEnd(result) {
this.setState({ dragging: false })
if (!result.destination) { if (!result.destination) {
return return
} }
...@@ -50,7 +62,9 @@ class ObjectTypePreview extends React.PureComponent { ...@@ -50,7 +62,9 @@ class ObjectTypePreview extends React.PureComponent {
} }
handleClick() { handleClick() {
this.props.onSelectionChange() if (!this.state.dragging) {
this.props.onSelectionChange()
}
} }
render() { render() {
...@@ -62,7 +76,10 @@ class ObjectTypePreview extends React.PureComponent { ...@@ -62,7 +76,10 @@ class ObjectTypePreview extends React.PureComponent {
<div className={classes.container} onClick={this.handleClick}> <div className={classes.container} onClick={this.handleClick}>
<Typography variant='h6'>Form Preview</Typography> <Typography variant='h6'>Form Preview</Typography>
<ObjectTypePreviewCode type={type} /> <ObjectTypePreviewCode type={type} />
<DragDropContext onDragEnd={this.handleDragEnd}> <DragDropContext
onDragStart={this.handleDragStart}
onDragEnd={this.handleDragEnd}
>
<Droppable droppableId='root' type='section'> <Droppable droppableId='root' type='section'>
{provided => ( {provided => (
<div <div
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment