@@ -27,8 +27,8 @@ type Props = {
2727 * Component that renders fields for a single feed transformation
2828 * (e.g., ReplaceFileFromStringTransformation).
2929 */
30- export default class FeedTransformation extends Component < Props , { csvData : ?string } > {
31- state = { csvData : null }
30+ export default class FeedTransformation extends Component < Props , { csvData : ?string , fieldName : ? string } > {
31+ state = { csvData : null , fieldName : null }
3232
3333 _getFieldsForType = ( type : string ) => {
3434 const { feedSource, transformation} = this . props
@@ -55,7 +55,7 @@ export default class FeedTransformation extends Component<Props, {csvData: ?stri
5555 />
5656 )
5757 break
58- case 'ReplaceFileFromStringTransformation' :
58+ case 'ReplaceFileFromStringTransformation' : {
5959 const inputIsUnchanged = this . state . csvData === null
6060 const csvData = inputIsUnchanged
6161 ? transformation . csvData
@@ -96,6 +96,41 @@ export default class FeedTransformation extends Component<Props, {csvData: ?stri
9696 </ div >
9797 )
9898 break
99+ }
100+ case 'NormalizeFieldTransformation' : {
101+ const inputIsUnchanged = this . state . fieldName === null
102+ const fieldName = inputIsUnchanged
103+ ? transformation . fieldName
104+ : this . state . fieldName
105+ fields . push (
106+ < div >
107+ < label htmlFor = 'fieldName' >
108+ Field to normalize:
109+ < input
110+ id = 'fieldName'
111+ onChange = { this . _onChangeFieldToNormalize }
112+ value = { fieldName } />
113+ </ label >
114+ < div style = { { marginBottom : '10px' } } >
115+ < Button
116+ bsSize = 'xsmall'
117+ disabled = { inputIsUnchanged }
118+ style = { { marginRight : '5px' } }
119+ onClick = { this . _onSaveFieldToNormalize } >
120+ Save CSV
121+ </ Button >
122+ </ div >
123+
124+ This transform will:
125+ < ul >
126+ < li > Capitalize bus stop names (for bus stops in all-caps),</ li >
127+ < li > Replace '+' and '&' with 'and', '@' with 'at',</ li >
128+ < li > Remove contents within parentheses.</ li >
129+ </ ul >
130+ </ div >
131+ )
132+ break
133+ }
99134 default :
100135 break
101136 }
@@ -141,6 +176,16 @@ export default class FeedTransformation extends Component<Props, {csvData: ?stri
141176 this . props . onChange ( { csvData} , this . props . index )
142177 }
143178
179+ _onChangeFieldToNormalize = ( evt : SyntheticInputEvent < HTMLInputElement > ) => {
180+ this . setState ( { fieldName : evt . target . value } )
181+ }
182+
183+ _onSaveFieldToNormalize = ( ) => {
184+ const fieldName = this . state . fieldName || null
185+ this . setState ( { fieldName : null } )
186+ this . props . onChange ( { fieldName} , this . props . index )
187+ }
188+
144189 _onRemoveTransformation = ( ) => {
145190 this . props . onRemove ( this . props . index )
146191 }
0 commit comments