mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 16:24:42 +02:00
Sets loading state in the form when the user presses SAVE
This commit is contained in:
parent
48e0aabeef
commit
23f9fb7833
@ -17,11 +17,15 @@ class ArticleAddModal extends React.Component {
|
|||||||
position: React.PropTypes.number.isRequired
|
position: React.PropTypes.number.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
|
state = {
|
||||||
|
loading: false
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="article-add-modal">
|
<div className="article-add-modal">
|
||||||
<Header title={i18n('ADD_ARTICLE')} description={i18n('ADD_ARTICLE_DESCRIPTION', {category: this.props.topicName})} />
|
<Header title={i18n('ADD_ARTICLE')} description={i18n('ADD_ARTICLE_DESCRIPTION', {category: this.props.topicName})} />
|
||||||
<Form onSubmit={this.onAddNewArticleFormSubmit.bind(this)}>
|
<Form onSubmit={this.onAddNewArticleFormSubmit.bind(this)} loading={this.state.loading}>
|
||||||
<FormField name="title" label={i18n('TITLE')} field="input" fieldProps={{size: 'large'}} validation="TITLE" required/>
|
<FormField name="title" label={i18n('TITLE')} field="input" fieldProps={{size: 'large'}} validation="TITLE" required/>
|
||||||
<FormField name="content" label={i18n('CONTENT')} field="textarea" validation="TEXT_AREA" required/>
|
<FormField name="content" label={i18n('CONTENT')} field="textarea" validation="TEXT_AREA" required/>
|
||||||
<SubmitButton type="secondary">{i18n('ADD_ARTICLE')}</SubmitButton>
|
<SubmitButton type="secondary">{i18n('ADD_ARTICLE')}</SubmitButton>
|
||||||
@ -35,6 +39,10 @@ class ArticleAddModal extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onAddNewArticleFormSubmit(form) {
|
onAddNewArticleFormSubmit(form) {
|
||||||
|
this.setState({
|
||||||
|
loading: true
|
||||||
|
});
|
||||||
|
|
||||||
API.call({
|
API.call({
|
||||||
path: '/article/add',
|
path: '/article/add',
|
||||||
data: {
|
data: {
|
||||||
@ -49,6 +57,10 @@ class ArticleAddModal extends React.Component {
|
|||||||
if(this.props.onChange) {
|
if(this.props.onChange) {
|
||||||
this.props.onChange();
|
this.props.onChange();
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.setState({
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user