@@ -10,7 +10,7 @@ class SimilarSeriesForm extends React.PureComponent {
1010 super ( props ) ;
1111 this . state = {
1212 seriesId : props . seriesId ,
13- similarSeriesId : '' ,
13+ similarSeriesIds : [ ] ,
1414 isDisabled : false ,
1515 hasServerError : false ,
1616 validationErrors : [ ]
@@ -22,26 +22,30 @@ class SimilarSeriesForm extends React.PureComponent {
2222 handleChange ( event ) {
2323 event . preventDefault ( ) ;
2424 this . setState ( {
25- similarSeriesId : event . target . value
25+ similarSeriesIds : event . target . value
2626 } ) ;
2727 }
2828
2929 handleSubmit ( event ) {
3030 event . preventDefault ( ) ;
3131
32+ const similarSeriesIds = CatalogUtils . expandNumbers ( this . state . similarSeriesIds )
33+ . split ( ',' )
34+ . map ( number => parseInt ( number , 10 ) )
35+ . filter ( number => ! isNaN ( number ) ) ;
36+
3237 this . setState ( {
38+ similarSeriesIds : similarSeriesIds ,
3339 isDisabled : true ,
3440 hasServerError : false ,
3541 validationErrors : [ ]
3642 } ) ;
3743
38- const similarSeriesId = parseInt ( this . state . similarSeriesId , 10 ) || this . state . similarSeriesId ;
39-
4044 axios . post (
4145 this . props . url ,
4246 {
4347 'seriesId' : this . state . seriesId ,
44- 'similarSeriesId ' : similarSeriesId
48+ 'similarSeriesIds ' : similarSeriesIds
4549 } ,
4650 {
4751 headers : {
@@ -59,8 +63,8 @@ class SimilarSeriesForm extends React.PureComponent {
5963 if ( data . fieldErrors . seriesId ) {
6064 fieldErrors . push ( ...data . fieldErrors . seriesId ) ;
6165 }
62- if ( data . fieldErrors . similarSeriesId ) {
63- fieldErrors . push ( ...data . fieldErrors . similarSeriesId ) ;
66+ if ( data . fieldErrors . similarSeriesIds ) {
67+ fieldErrors . push ( ...data . fieldErrors . similarSeriesIds ) ;
6468 }
6569 this . setState ( { isDisabled : false , validationErrors : fieldErrors } ) ;
6670 return ;
@@ -81,7 +85,7 @@ class SimilarSeriesForm extends React.PureComponent {
8185 l10n = { this . props . l10n }
8286 handleChange = { this . handleChange }
8387 handleSubmit = { this . handleSubmit }
84- similarSeriesId = { this . state . similarSeriesId }
88+ similarSeriesIds = { this . state . similarSeriesIds }
8589 isDisabled = { this . state . isDisabled }
8690 hasServerError = { this . state . hasServerError }
8791 validationErrors = { this . state . validationErrors }
@@ -92,7 +96,7 @@ class SimilarSeriesForm extends React.PureComponent {
9296
9397class SimilarSeriesFormView extends React . PureComponent {
9498 render ( ) {
95- const { similarSeriesId , hasServerError, isDisabled, validationErrors, handleChange, handleSubmit} = this . props ;
99+ const { similarSeriesIds , hasServerError, isDisabled, validationErrors, handleChange, handleSubmit} = this . props ;
96100 const hasValidationErrors = validationErrors . length > 0 ;
97101
98102 return (
@@ -112,8 +116,8 @@ class SimilarSeriesFormView extends React.PureComponent {
112116 type = "text"
113117 className = "form-control"
114118 required = "required"
115- placeholder = { this . props . l10n [ 't_similar_series_id ' ] || 'Similar series ID' }
116- value = { similarSeriesId }
119+ placeholder = { this . props . l10n [ 't_similar_series_ids ' ] || 'Similar series ID(s) ' }
120+ value = { similarSeriesIds }
117121 onChange = { handleChange }
118122 disabled = { isDisabled } />
119123 </ div >
0 commit comments