Skip to content

Commit

Permalink
Revert "refactor(TripSeriesModal): Inline methods"
Browse files Browse the repository at this point in the history
This reverts commit 79dbcf2.
  • Loading branch information
AdrianaCeric committed Dec 7, 2023
1 parent 79dbcf2 commit 19dc66e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lib/editor/components/timetable/TripSeriesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const TripSeriesModal = (props: Props) => {

const messages = getComponentMessages('TripSeriesModal')

const handleIncrementStartUpdate = (evt: SyntheticInputEvent<HTMLInputElement>) => setState((prevState) => ({ ...prevState, autoTripIdStart: +evt.target.value }))
const handleBlockIdStartUpdate = (evt: SyntheticInputEvent<HTMLInputElement>) => {
// Check the input to make sure it's within the valid range.
let input = +evt.target.value
Expand All @@ -58,6 +59,15 @@ const TripSeriesModal = (props: Props) => {
setState((prevState) => ({ ...prevState, autoBlockIdStart: input }))
}

const handleTripPrefixUpdate = (evt: SyntheticInputEvent<HTMLInputElement>) => setState((prevState) => ({ ...prevState, autoTripIdPrefix: evt.target.value }))
const handleBlockPrefixUpdate = (evt: SyntheticInputEvent<HTMLInputElement>) => setState((prevState) => ({ ...prevState, autoBlockIdPrefix: evt.target.value }))

const handleTripIncrementUpdate = (evt: SyntheticInputEvent<HTMLInputElement>) => setState((prevState) => ({ ...prevState, autoTripIdIncrement: +evt.target.value }))
const handleBlockIncrementUpdate = (evt: SyntheticInputEvent<HTMLInputElement>) => setState((prevState) => ({ ...prevState, autoBlockIdIncrement: +evt.target.value }))

const handleAutoTripIDCheckBox = () => setState((prevState) => ({ ...prevState, useAutoTripIds: !prevState.useAutoTripIds }))
const handleAutoBlockIDCheckBox = () => setState((prevState) => ({ ...prevState, useAutoBlockIds: !prevState.useAutoBlockIds }))

const _onClose = () => {
const { onClose } = props
setState(initialState)
Expand Down Expand Up @@ -156,30 +166,30 @@ const TripSeriesModal = (props: Props) => {
</div>
<hr />
<div>
<Checkbox checked={useAutoTripIds} onChange={() => setState((prevState) => ({ ...prevState, useAutoTripIds: !prevState.useAutoTripIds }))}>
<Checkbox checked={useAutoTripIds} onChange={handleAutoTripIDCheckBox}>
{messages('automaticallyUpdateTripIds')}
</Checkbox>
{useAutoTripIds && (
<>
<div style={{alignItems: 'center', display: 'flex'}}>
<>
<FormControl
onChange={(evt) => setState((prevState) => ({ ...prevState, autoTripIdPrefix: evt.target.value }))}
onChange={handleTripPrefixUpdate}
placeholder={messages('prefixPlaceholder')}
style={{width: '30%', marginRight: '5px'}}
type='text'
value={autoTripIdPrefix}
/>
-
<FormControl
onChange={(evt) => setState((prevState) => ({ ...prevState, autoTripIdStart: +evt.target.value }))}
onChange={handleIncrementStartUpdate}
placeholder={messages('incrementStartPlaceholder')}
style={{width: '40%', marginLeft: '5px', marginRight: '5px'}}
type='number'
/>
{messages('incrementBy')}
<FormControl
onChange={(evt) => setState((prevState) => ({ ...prevState, autoTripIdIncrement: +evt.target.value }))}
onChange={handleTripIncrementUpdate}
placeholder={messages('incrementAmountPlaceholder')}
style={{width: '15%', marginLeft: '5px'}}
type='number'
Expand All @@ -192,20 +202,20 @@ const TripSeriesModal = (props: Props) => {
)}
</div>
<div>
<Checkbox checked={useAutoBlockIds} onChange={() => setState((prevState) => ({ ...prevState, useAutoBlockIds: !prevState.useAutoBlockIds }))}>{messages('automaticallyUpdateBlockIds')}</Checkbox>
<Checkbox checked={useAutoBlockIds} onChange={handleAutoBlockIDCheckBox}>{messages('automaticallyUpdateBlockIds')}</Checkbox>
{useAutoBlockIds && (
<>
<div style={{alignItems: 'center', display: 'flex'}}>
<FormControl
onChange={(evt) => setState((prevState) => ({ ...prevState, autoBlockIdPrefix: evt.target.value }))}
onChange={handleBlockPrefixUpdate}
placeholder={messages('blockIdPrefixPlaceholder')}
style={{width: '20%', marginRight: '5px'}}
type='text'
value={autoBlockIdPrefix}
/>
{messages('alternateEvery')}
<FormControl
onChange={(evt) => setState((prevState) => ({ ...prevState, autoBlockIdIncrement: +evt.target.value }))}
onChange={handleBlockIncrementUpdate}
placeholder={messages('blockIncrementPlaceholder')}
style={{width: '15%', marginLeft: '5px', marginRight: '5px'}}
type='number'
Expand Down

0 comments on commit 19dc66e

Please sign in to comment.