Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Conversation

@grenti
Copy link
Contributor

@grenti grenti commented Aug 10, 2018

Card

affects: @rentpath/react-ui-core

  • took out logic for Google Map Polyline and Polygon api from disableDraw
  • put it in endDraw
  • called endDraw in disableDraw, handleMouseUp

Copy link
Collaborator

@tadjohnston tadjohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use git cz please.

@grenti
Copy link
Contributor Author

grenti commented Aug 10, 2018

Will do - we realized we didn’t use it earlier and so I was going to update the pr with tests and git after I remove WIP.


if (polygonCoords.length) this.finishDraw(polygonCoords)

this.endDraw()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add tests to make sure these two get fired here.

const { enabled, shapes } = this.state

if (!enabled && (Object.keys(shapes).length > 0)) {
this.setState({ shapes: existingShapes })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we combine this setState with the one below so we don't have a double render?

@grenti grenti force-pushed the dh/673931956/allow-multiple-shapes-react-ui branch from 8a9128c to 4b296e4 Compare August 14, 2018 20:42
handleClick() {
this.setState({ enabled: !this.state.enabled })
const existingShapes = this.props.shapes
const { enabled, shapes: _ } = this.state
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ usually denotes you aren't using that prop. Cant' we just rename it to something else? I'd prefer the code below to be readable.

const existingShapes = this.props.shapes
const { enabled, shapes: _ } = this.state

const shapes = !enabled && Object.keys(_).length > 0 && _ !== existingShapes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.keys(_).length > 0 should just be Object.keys(_).length

Copy link
Collaborator

@tadjohnston tadjohnston Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't think we should really be using both props and state to write conditionals. What happens if props.shapes changes is that going to be an issue? There isn't just 1 single source of truth here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm going to take out the state shape logic - I think it was intended to store the shapes and now since we are trying to reconcile both it's getting out of hand. I'll just reset the state on click back to the props passed in.

this.setState({
shapes: shape && { 0: shape },
enabled: false,
shapes: shape && { ...shapes, [shapeId]: shape },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you were removing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the logic from handleClick that updated the shapes in state. The way the component is written we have to use the state to keep all the shapes that have been drawn in the Multi-shape scenario. We can refactor this component to handle multi-shapes but since we're trying to get this released on Thursday I was trying to be as conservative as possible.

Copy link
Collaborator

@tadjohnston tadjohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, still need to squash and use one git cz style commit 😄

@grenti
Copy link
Contributor Author

grenti commented Aug 15, 2018

Ok I'll squash - I was still making changes based on our conversation but we do need to get this merged so we can publish and use for ag.js changes going in tomorrow.

…ed before drawing multiple shap

affects: @rentpath/react-ui-core

* updated FreeDrawLayer to accomodate multiple shapes
  * took out logic for Google Map Polyline and Polygon api from disableDraw
  * put it in endDraw
  * called endDraw in disableDraw, handleMouseUp
  * Updated FreeDrawExample to show multi-shape use case
@grenti grenti force-pushed the dh/673931956/allow-multiple-shapes-react-ui branch from 0763c40 to 9ea5ade Compare August 15, 2018 18:51
@grenti grenti merged commit 4b83d5f into master Aug 15, 2018
@grenti grenti deleted the dh/673931956/allow-multiple-shapes-react-ui branch August 15, 2018 21:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants