Skip to content

Commit 7c50f20

Browse files
author
vikasrohit
committed
Github issue #225 Must validate the white spaces (Blank spaces)
-- fixed along with lint error fixes
1 parent e6ac6dc commit 7c50f20

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/projects/detail/components/FeatureSelector/CustomFeatureForm.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CustomFeatureForm extends Component {
6565
id: data.title.toLowerCase().replace(/\s/g, '_'),
6666
categoryId: 'custom',
6767
notes: ''
68-
}, featureData, data))
68+
}, featureData, { title : data.title.trim() }))
6969
// assumes addFeature to be a synchronous call, otherwise it could lead to inconsistent UI state
7070
// e.g. if async addFeature fails, it would close the edit mode
7171
// this call is needed here because debounce call (for notes change) is closing the edit mode if
@@ -79,6 +79,8 @@ class CustomFeatureForm extends Component {
7979
// because forms' onChange event gets fire with only form data when we lose focus from the form
8080
// alternative to this check is to put the change handler on textarea instead of form
8181
if (featureData) {// feature is already added
82+
// trim the notes (as of now only notes field is auto updated)
83+
data.notes = data.notes.trim()
8284
this.props.updateFeature(_.merge({}, featureData, data))
8385
}
8486
}
@@ -117,7 +119,7 @@ class CustomFeatureForm extends Component {
117119
<TCFormFields.TextInput
118120
name="title"
119121
label="Feature name"
120-
validations="minLength:1" required
122+
validations="isRequired" required
121123
validationError="Feature name is required"
122124
wrapperClass="row"
123125
value={ _.get(data, 'title', '') }

src/projects/detail/components/FeatureSelector/DefaultFeatureForm.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class DefaultFeatureForm extends Component {
5050

5151
onChange(data) {
5252
const { featureData } = this.props
53+
// trim the notes (as of now only notes field is auto updated)
54+
data.notes = data.notes.trim()
5355
this.props.updateFeature(_.merge({}, featureData, data))
5456
}
5557

src/projects/detail/components/FeatureSelector/FeaturePicker.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ class FeaturePicker extends Component {
214214
this.removeFeature = this.removeFeature.bind(this)
215215
this.toggleFeature = this.toggleFeature.bind(this)
216216
this.selectFeature = this.selectFeature.bind(this)
217-
this.toggleFeature = this.toggleFeature.bind(this)
218217
this.updateSelectedFeature = this.updateSelectedFeature.bind(this)
219218
this.renderCustomFeatureForm = this.renderCustomFeatureForm.bind(this)
220219
this.renderDefaultFeatureForm = this.renderDefaultFeatureForm.bind(this)
@@ -233,11 +232,6 @@ class FeaturePicker extends Component {
233232
})
234233
}
235234

236-
toggleFeature(featureId) {
237-
const idx = _.findIndex(this.state.activeFeatureList, f => f.id === featureId)
238-
idx > -1 ? this.removeFeature(featureId) : this.addFeature(featureId)
239-
}
240-
241235
renderCustomFeatureForm() {
242236
this.setState({
243237
selectedFeatureId: null,

0 commit comments

Comments
 (0)