Updating class with setState
Этот коммит содержится в:
@@ -11,14 +11,16 @@ export default class SettingsUpload extends React.Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
clientError: this.props.clientError,
|
clientError: this.props.clientError,
|
||||||
serverError: this.props.serverError
|
serverError: this.props.serverError,
|
||||||
|
importClass: ' disabled'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps() {
|
componentWillReceiveProps() {
|
||||||
this.setState({
|
this.setState({
|
||||||
clientError: this.props.clientError,
|
clientError: this.props.clientError,
|
||||||
serverError: this.props.serverError
|
serverError: this.props.serverError,
|
||||||
|
importClass: ' disabled'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +28,8 @@ export default class SettingsUpload extends React.Component {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.setState({
|
this.setState({
|
||||||
clientError: '',
|
clientError: '',
|
||||||
serverError: ''
|
serverError: '',
|
||||||
|
importClass: ' disabled'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,13 +44,15 @@ export default class SettingsUpload extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFileSelect(e) {
|
onFileSelect(e) {
|
||||||
|
this.setState({
|
||||||
|
importClass: ''
|
||||||
|
});
|
||||||
var filename = $(e.target).val();
|
var filename = $(e.target).val();
|
||||||
if (filename.substring(3, 11) === 'fakepath') {
|
if (filename.substring(3, 11) === 'fakepath') {
|
||||||
filename = filename.substring(12);
|
filename = filename.substring(12);
|
||||||
}
|
}
|
||||||
$(e.target).closest('li').find('.file-status').addClass('hide');
|
$(e.target).closest('li').find('.file-status').addClass('hide');
|
||||||
$(e.target).closest('li').find('.file-name').removeClass('hide').html(filename);
|
$(e.target).closest('li').find('.file-name').removeClass('hide').html(filename);
|
||||||
$(React.findDOMNode(this.refs.importButton)).removeClass('disabled');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -63,6 +68,10 @@ export default class SettingsUpload extends React.Component {
|
|||||||
<div className='file-status'>{this.state.serverError}</div>
|
<div className='file-status'>{this.state.serverError}</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
var importClass = '';
|
||||||
|
if (this.state.importClass) {
|
||||||
|
importClass = ' disabled';
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<ul className='section-max'>
|
<ul className='section-max'>
|
||||||
<li className='col-sm-12 section-title'>{this.props.title}</li>
|
<li className='col-sm-12 section-title'>{this.props.title}</li>
|
||||||
@@ -71,7 +80,7 @@ export default class SettingsUpload extends React.Component {
|
|||||||
<ul className='setting-list'>
|
<ul className='setting-list'>
|
||||||
<li className='setting-list-item'>
|
<li className='setting-list-item'>
|
||||||
<span className='btn btn-sm btn-primary btn-file sel-btn'>
|
<span className='btn btn-sm btn-primary btn-file sel-btn'>
|
||||||
Select file
|
{'Select file'}
|
||||||
<input
|
<input
|
||||||
ref='uploadinput'
|
ref='uploadinput'
|
||||||
accept={this.props.fileTypesAccepted}
|
accept={this.props.fileTypesAccepted}
|
||||||
@@ -80,11 +89,10 @@ export default class SettingsUpload extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<a
|
<a
|
||||||
ref='importButton'
|
className={'btn btn-sm btn-primary' + importClass}
|
||||||
className={'btn btn-sm btn-primary disabled'}
|
|
||||||
onClick={this.doSubmit}
|
onClick={this.doSubmit}
|
||||||
>
|
>
|
||||||
Import
|
{'Import'}
|
||||||
</a>
|
</a>
|
||||||
<div className='file-status file-name hide'></div>
|
<div className='file-status file-name hide'></div>
|
||||||
{serverError}
|
{serverError}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user