mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-18 20:53:24 +00:00
log errs correctly, setCustomValidity and reportValidity
This commit is contained in:
@@ -65,10 +65,17 @@ const MetadataEditor = createClass({
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
if(Object.values(this.state.errs ?? {}).filter(Boolean).length === 0){
|
if(Object.values(this.state.errs ?? {}).filter(Boolean).length === 0){
|
||||||
|
e.target.setCustomValidity('');
|
||||||
this.props.onChange({
|
this.props.onChange({
|
||||||
...this.props.metadata,
|
...this.props.metadata,
|
||||||
[name] : e.target.value
|
[name] : e.target.value
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
const errMessage = this.state.errs[name].map((err)=>{
|
||||||
|
return `- ${err}`;
|
||||||
|
}).join('\n');
|
||||||
|
e.target.setCustomValidity(errMessage);
|
||||||
|
e.target.reportValidity();
|
||||||
};
|
};
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -241,25 +248,30 @@ const MetadataEditor = createClass({
|
|||||||
</div>;
|
</div>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// renderErrors : function(){
|
||||||
|
// if(Object.values(this.state.errs ?? {}).filter(Boolean).length > 0) return;
|
||||||
|
// return <span className='validation-error'></span>
|
||||||
|
// },
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
return <div className='metadataEditor'>
|
return <div className='metadataEditor'>
|
||||||
<div className='field title'>
|
<div className='field title'>
|
||||||
<label>title</label>
|
<label>title</label>
|
||||||
<input type='text' className='value'
|
<input type='text' className='value'
|
||||||
value={this.props.metadata.title}
|
defaultValue={this.props.metadata.title}
|
||||||
onChange={(e)=>this.handleFieldChange('title', e)} />
|
onChange={(e)=>this.handleFieldChange('title', e)} />
|
||||||
</div>
|
</div>
|
||||||
<div className='field-group'>
|
<div className='field-group'>
|
||||||
<div className='field-column'>
|
<div className='field-column'>
|
||||||
<div className='field description'>
|
<div className='field description'>
|
||||||
<label>description</label>
|
<label>description</label>
|
||||||
<textarea value={this.props.metadata.description} className='value'
|
<textarea defaultValue={this.props.metadata.description} className='value'
|
||||||
onChange={(e)=>this.handleFieldChange('description', e)} />
|
onChange={(e)=>this.handleFieldChange('description', e)} />
|
||||||
</div>
|
</div>
|
||||||
<div className='field thumbnail'>
|
<div className='field thumbnail'>
|
||||||
<label>thumbnail</label>
|
<label>thumbnail</label>
|
||||||
<input type='text'
|
<input type='text'
|
||||||
value={this.props.metadata.thumbnail}
|
defaultValue={this.props.metadata.thumbnail}
|
||||||
placeholder='my.thumbnail.url'
|
placeholder='my.thumbnail.url'
|
||||||
className='value'
|
className='value'
|
||||||
onChange={(e)=>this.handleFieldChange('thumbnail', e)} />
|
onChange={(e)=>this.handleFieldChange('thumbnail', e)} />
|
||||||
|
|||||||
Reference in New Issue
Block a user