Skip to content

Conversation

@binh-dam-ibigroup
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented Feb 2, 2021

This PR makes the following changes to the trip settings:

  • The screen scrolls to trip name/days if the user is submitting the form and there is a validation error on one of these fields.
  • The trip notification settings controls are reorganized per mockup document.
  • A single field in the UI sets both the departureVarianceMinutesThreshold and arrivalVarianceMinutesThreshold.

onChange={this._handleIsActiveChange}
value
<h4>Notify me via {notificationChannelLabels[notificationChannel]} when:</h4>
<SettingsListWithAlign>
Copy link
Member

@landonreed landonreed Feb 4, 2021

Choose a reason for hiding this comment

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

After seeing this in action, let's make all these settings flush with the left edge (i.e., no indentation). Same goes for the below item in Advanced Settings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in 4801a00.

}
}
this._updateNewTripItineraryExistence(prevProps)
this._scrollToTripDataIfInvalid()
Copy link
Member

@landonreed landonreed Feb 4, 2021

Choose a reason for hiding this comment

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

I somewhat expected formik to have something to handle this. Perhaps this approach could be leveraged (it uses hooks, so maybe not)? jaredpalmer/formik#146 (comment). This is not blocking by any means. What you have already makes sense... just exploring.

Also, similar to how we highlight the stop viewer row on scroll, it might be good to highlight/fade the invalid items too (probably in the alert-danger bg color).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The scrolling is not built-in, so there are code snippets and even a library. Library is cleaner. 4801a00
Errors were already highlighted in standard Bootstrap red.

<FormGroup validationState={tripNameValidationState}>
<ControlLabel>Please provide a name for this trip:</ControlLabel>
<ControlLabel>
{/* Put a ref in a native DOM element for access to scroll function. */}
Copy link
Member

Choose a reason for hiding this comment

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

This comment feels a little awkward. Maybe:

Put a ref in this native DOM element to scroll to if trip name is invalid.

{title && <PageHeading>{title}</PageHeading>}
{title && (
<PageHeading>
<Button bsStyle='primary' className='pull-right' type='submit'>Save</Button>
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a huge fan of the Save button up here (at least for now). I think we want the user to take the action of scrolling through the form to view/confirm the settings before saving.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was an experiment... It's reverted by 8dc5971.

name='leadTimeInMinutes'
>
<option value={15}>15 min</option>
<option value={30}>30 min (default)</option>
Copy link
Member

Choose a reason for hiding this comment

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

Because it's not the first option, 30 minutes is not selected by default. For this select and the others, we may want to add a selected prop? I'm not too familiar with how Formik handles <select/> inputs though, so I'm open to alternative suggestions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Forgot about that, glad you pointed it out.

Copy link
Collaborator Author

@binh-dam-ibigroup binh-dam-ibigroup Feb 5, 2021

Choose a reason for hiding this comment

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

That was trickier. The default value was already populated correctly in the trip object, but the I passed the wrong component for styling, so it's fixed now in 4801a00.

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

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

Looks good! Just a couple of styling tweaks and an issue with the dropdown selects (selected prop might be needed).

@landonreed landonreed removed their assignment Feb 12, 2021
<li>
<Select
label='There are delays or disruptions of more than'
name='departureVarianceMinutesThreshold'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just noticing there is no field for arrivalVarianceMinutesThreshold. Should there be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@evansiroky In b30a2ef I split the target threshold field depending on whether the trip is arriveBy.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... I'm somewhat of the mind that we should just set both thresholds to the same value (chosen by the single select component here) regardless of whether the trip is arriveBy/departAt. If I had a trip that was set to arrive by 9am. I would still really like to know if the first leg is running early by 15 minutes (an extreme case, but still feasible). Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am in favor of using a single selector, so @landonreed's idea may be better overall?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Per team discussion, I implemented single UI field that sets the value for both the departure and arrival delay thresholds in 2dd1821.

@evansiroky
Copy link
Contributor

Assigning back to Binh to fix merge conflicts and also update per our weekly technical meeting.

Copy link
Member

@landonreed landonreed left a comment

Choose a reason for hiding this comment

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

Just a couple of minor comments.

import { Col, Row } from 'react-bootstrap'
import { connect } from 'react-redux'

import * as uiActions from '../../actions/ui'
Copy link
Member

Choose a reason for hiding this comment

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

Why are trips needed here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's leftover orphan code, removed in 814d9df.

<option value={60}>1 hour</option>
</Select>
before it begins until it ends.
before it begins, until it ends.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the inclusion of this comma. I would say we should probably remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed in 814d9df.

clonedMonitoredTrip.delayThreshold = Math.min(
monitoredTrip.arrivalVarianceMinutesThreshold,
monitoredTrip.departureVarianceMinutesThreshold
)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe all of this logic (cloning and setting delay field) should happen in a method prepareTripForEditing? Alternatively, if there's a way to just set both of these values using Formik (rather than manipulating the object), that might be preferable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in 814d9df.

@landonreed landonreed removed their assignment Mar 4, 2021
@binh-dam-ibigroup binh-dam-ibigroup merged commit d10926c into dev Mar 12, 2021
@binh-dam-ibigroup binh-dam-ibigroup deleted the improve-trip-name-validation branch March 12, 2021 15:08
@evansiroky evansiroky mentioned this pull request Mar 31, 2021
@github-actions
Copy link
Contributor

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants