Skip to content

Commit

Permalink
Merge branch 'dev' into stricter-itinerary-order
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup authored Nov 14, 2023
2 parents 020be36 + 204e799 commit 530bf3c
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 67 deletions.
4 changes: 4 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ itinerary:
# One fare will always be shown by default
defaultFareType: { mediumId: null, riderCategoryId: null }

# List of OTP2 errors to not display. Can be a list
# mutedErrors:
# - NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW

# The following settings must be set to these values to use the new
# "Metro" UI. The settings can be used without the Metro UI, but
# this may have unexpected effects.
Expand Down
1 change: 1 addition & 0 deletions lib/actions/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function resetForm(full = false) {
// If fully resetting form, also clear the active search, from/to
// locations, and query params.
dispatch(clearActiveSearch())
dispatch(settingQueryParam({ departArrive: 'NOW' }))
dispatch(setLocation({ location: null, locationType: 'from' }))
dispatch(setLocation({ location: null, locationType: 'to' }))
// Get query params. Delete everything except sessionId.
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getFirstStopId } from '../util/itinerary'
import { routingQuery } from './api'
import { setQueryParam } from './form'

const SERVICE_BREAK = '03:00'
const SERVICE_BREAK = '03:30'
const NINETY_SECONDS = 90000

function updateParamsAndPlan(params) {
Expand Down
39 changes: 10 additions & 29 deletions lib/components/admin/mailables-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class SelectedMailable extends Component {
updateField(index, 'largeFormat', evt.target.checked)
}

_changeSmallFormat = (evt) => {
const { index, updateField } = this.props
updateField(index, 'smallFormat', evt.target.checked)
}

_changeQuantity = (evt) => {
const { index, updateField } = this.props
updateField(index, 'quantity', evt.target.value)
Expand All @@ -62,8 +57,7 @@ class SelectedMailable extends Component {

render() {
const { index, mailable } = this.props
const largeId = `largeFormat-${index}`
const smallId = `smallFormat-${index}`
const id = `largeFormat-${index}`
return (
<SelectedMailableContainer>
<MailableLabel mailable={mailable} />
Expand All @@ -76,26 +70,15 @@ class SelectedMailable extends Component {
type="number"
value={mailable.quantity}
/>
<div style={{ marginTop: '5px' }}>
<input
checked={mailable.smallFormat}
id={smallId}
onChange={this._changeSmallFormat}
type="checkbox"
/>
<label htmlFor={smallId} style={{ marginLeft: '5px' }}>
Small format?
</label>
</div>
{mailable.largePrint && (
<div style={{ marginTop: '5px' }}>
<input
checked={mailable.largeFormat}
id={largeId}
id={id}
onChange={this._changeLargeFormat}
type="checkbox"
value={mailable.largeFormat}
/>
<label htmlFor={largeId} style={{ marginLeft: '5px' }}>
<label htmlFor={id} style={{ marginLeft: '5px' }}>
Large format?
</label>
</div>
Expand All @@ -122,11 +105,9 @@ class MailablesWindow extends Component {
}

_addMailable = (mailable) => {
if (!this.state.mailables.find((m) => m.name === mailable.name)) {
const mailables = [...this.state.mailables]
mailables.push({ ...mailable, quantity: 1, smallFormat: true })
this.setState({ mailables })
}
const mailables = [...this.state.mailables]
mailables.push({ ...mailable, quantity: 1 })
this.setState({ mailables })
}

_removeMailable = (mailable) => {
Expand Down Expand Up @@ -156,9 +137,9 @@ class MailablesWindow extends Component {
const { mailables: selectedMailables } = this.state
const { items } = mailablesConfig
if (!callTaker.mailables.visible) return null
const selectableMailables = items.filter(
(m) => !selectedMailables.find((mailable) => mailable.name === m.name)
)
// If items should not be addable twice, then this line can be amended
const selectableMailables = items

return (
<DraggableWindow
footer={
Expand Down
4 changes: 1 addition & 3 deletions lib/components/admin/query-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class QueryRecordLayout extends Component {
onClick={this._viewQuery}
>
<CallRecordIcon type="search" />
{time}
<br />
{params.from.name} to {params.to.name}
{params.from.name} to {params.to.name} at {time}
</CallRecordButton>
</li>
)
Expand Down
2 changes: 2 additions & 0 deletions lib/components/narrative/default/itinerary.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@
.otp .option.default-itin > .header .title > .summary > .mode-block {
height: 18px;
width: 18px;
color: #eee;
fill: #eee;
}

.otp .option.default-itin > .header .title > .summary > .arrow-block {
Expand Down
32 changes: 24 additions & 8 deletions lib/components/narrative/metro/metro-error-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { connect } from 'react-redux'
import { ExclamationCircle } from '@styled-icons/fa-solid/ExclamationCircle'
import { FormattedMessage, useIntl } from 'react-intl'
import React from 'react'
import styled from 'styled-components'

import { AppReduxState } from '../../../util/state-types'
import { Icon } from '../../util/styledIcon'

type Error = Record<string, string[]>
Expand Down Expand Up @@ -38,25 +40,34 @@ const Container = styled.li`
}
`

const ErrorRenderer = ({ errors }: { errors: Error }): JSX.Element => {
const ErrorRenderer = ({
errors,
mutedErrors
}: {
errors: Error
mutedErrors?: string[]
}): JSX.Element => {
const intl = useIntl()

return (
<List>
{Object.keys(errors).map((error: string) => {
// The search window is hardcoded in otp-rr and can't be changed by the user.
// Do not tell them what's happening as they can't act on the issue.
if (error === 'NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW') {
return null
}

// Don't show errors that have been muted in the config
if (mutedErrors?.includes(error)) return null

const localizedInputFieldList = Array.from(errors[error])?.map(
(inputField) =>
intl.formatMessage({
id: `components.OTP2ErrorRenderer.inputFields.${inputField}`
})
)

// The search window is hardcoded in otp-rr and can't be changed by the user.
// Do not tell them what's happening as they can't act on the issue.
if (error === 'NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW') {
return null
}

return (
<Container key={error}>
<Icon Icon={ExclamationCircle} size="3x" />
Expand All @@ -81,5 +92,10 @@ const ErrorRenderer = ({ errors }: { errors: Error }): JSX.Element => {
)
}

export default ErrorRenderer
const mapStateToProps = (state: AppReduxState) => {
const { itinerary } = state.otp.config
return { mutedErrors: itinerary?.mutedErrors }
}
export default connect(mapStateToProps)(ErrorRenderer)

export type { Error }
1 change: 1 addition & 0 deletions lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export interface ItineraryConfig {
groupTransitModes?: boolean
hideSkeletons?: boolean
mergeItineraries?: boolean
mutedErrors?: string[]
onlyShowCountdownForRealtime?: boolean
renderRouteNamesInBlocks?: boolean
showFirstResultByDefault?: boolean
Expand Down
23 changes: 7 additions & 16 deletions lib/util/mailables.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,13 @@ async function writePDF(formData, imageData, otpConfig) {

const tableData = {
headers: ['Item', 'Quantity'],
rows: mailables
.map((mailable) => {
let { largeFormat, largePrint, name, quantity, smallFormat } = mailable
const rows = []

if (smallFormat) {
rows.push([name, quantity])
}

if (largePrint && largeFormat) {
name += ' (LARGE PRINT)'
rows.push([name, quantity])
}
return rows
})
.flat()
rows: mailables.map((mailable) => {
let { largeFormat, largePrint, name, quantity } = mailable
if (largePrint && largeFormat) {
name += ' (LARGE PRINT)'
}
return [name, quantity]
})
}

doc.table(tableData, {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@bugsnag/plugin-react": "^7.17.0",
"@floating-ui/react": "^0.19.2",
"@opentripplanner/base-map": "^3.0.15",
"@opentripplanner/core-utils": "^11.1.2",
"@opentripplanner/core-utils": "^11.1.3",
"@opentripplanner/endpoints-overlay": "^2.0.10",
"@opentripplanner/from-to-location-picker": "^2.1.10",
"@opentripplanner/geocoder": "^1.4.2",
Expand All @@ -57,7 +57,7 @@
"@opentripplanner/stops-overlay": "^5.1.2",
"@opentripplanner/transit-vehicle-overlay": "^4.0.7",
"@opentripplanner/transitive-overlay": "^3.0.16",
"@opentripplanner/trip-details": "^5.0.5",
"@opentripplanner/trip-details": "^5.0.6",
"@opentripplanner/trip-form": "^3.3.6",
"@opentripplanner/trip-viewer-overlay": "^2.0.7",
"@opentripplanner/vehicle-rental-overlay": "^2.1.3",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2459,10 +2459,10 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/core-utils@^11.1.2":
version "11.1.2"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.1.2.tgz#a99d1fa4fb1f587d58fae8fcfd70a3bfe4eed424"
integrity sha512-Rn1tBm5F+nt/A4/0cpq6cyNTprSsxfFslujMoZ4P4r6fZ7YTx0d25di+MZ/CZgSlCzHJIiGAfi8DsfJ7yStcTA==
"@opentripplanner/core-utils@^11.1.3":
version "11.1.3"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.1.3.tgz#6309e1298fbfc6dd01f16b22a5b2bc7ba5639454"
integrity sha512-O05TSCpzS9K9ery5Fjm+OalbpEpedV6SaCHjyIMqP5XW67lK+fJi4dYHlkr4/IBL7eDQ84op2vMeM/tBSJXsZg==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
Expand Down Expand Up @@ -2693,10 +2693,10 @@
"@turf/midpoint" "^6.5.0"
lodash.isequal "^4.5.0"

"@opentripplanner/trip-details@^5.0.5":
version "5.0.5"
resolved "https://registry.yarnpkg.com/@opentripplanner/trip-details/-/trip-details-5.0.5.tgz#17e841ba9cfda9cddbe6cff2ffef964131d64049"
integrity sha512-EgxcWxAZNTZAS3ISDdeB5E0qEld/7rhj7wag4DQe9YKby9mPXo0ab28+j7MJ0ErQxqjUrsN/2JR2UBC3ybbxsQ==
"@opentripplanner/trip-details@^5.0.6":
version "5.0.6"
resolved "https://registry.yarnpkg.com/@opentripplanner/trip-details/-/trip-details-5.0.6.tgz#0f7043e0f112fddca4a10b15293298e7f1f5f421"
integrity sha512-t8CFJidFThQZ7zWKqDbilpctULAT/OfS17O14cSo1Ui4TgMfaMDoCWaRK66d93KffhMm4z6J+KLV5PGjtRZptA==
dependencies:
"@opentripplanner/core-utils" "^11.0.2"
"@styled-icons/fa-solid" "^10.34.0"
Expand Down

0 comments on commit 530bf3c

Please sign in to comment.