1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01:00

Add spinner to submission for and make submittable on default with providing error messages

This commit is contained in:
Tim Daubenschütz 2015-11-12 13:21:10 +01:00
parent 1a67cd66f5
commit d1b931715d
2 changed files with 37 additions and 21 deletions

View File

@ -9,6 +9,7 @@ import InputTextAreaToggable from '../../../../../ascribe_forms/input_textarea_t
import UploadButton from '../../../../../ascribe_uploader/ascribe_upload_button/upload_button'; import UploadButton from '../../../../../ascribe_uploader/ascribe_upload_button/upload_button';
import InputFineuploader from '../../../../../ascribe_forms/input_fineuploader'; import InputFineuploader from '../../../../../ascribe_forms/input_fineuploader';
import AscribeSpinner from '../../../../../ascribe_spinner';
import GlobalNotificationModel from '../../../../../../models/global_notification_model'; import GlobalNotificationModel from '../../../../../../models/global_notification_model';
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions'; import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
@ -36,13 +37,14 @@ const PRRegisterPieceForm = React.createClass({
getInitialState(){ getInitialState(){
return { return {
digitalWorkKeyReady: false, digitalWorkKeyReady: true,
thumbnailKeyReady: false, thumbnailKeyReady: true,
// we set this to true, as it is not required // we set this to true, as it is not required
supportingMaterialsReady: true, supportingMaterialsReady: true,
proofOfPaymentReady: false, proofOfPaymentReady: true,
piece: null piece: null,
submitted: false
}; };
}, },
@ -55,11 +57,10 @@ const PRRegisterPieceForm = React.createClass({
if(!this.validateForms()) { if(!this.validateForms()) {
return; return;
} else { } else {
// disable the submission button right after the user
// clicks on it to avoid double submission
this.setState({ this.setState({
digitalWorkKeyReady: false, submitted: true
thumbnailKeyReady: false,
supportingMaterialsReady: false,
proofOfPaymentReady: false
}); });
} }
@ -91,7 +92,7 @@ const PRRegisterPieceForm = React.createClass({
proofOfPayment.refs.input.createBlobRoutine(); proofOfPayment.refs.input.createBlobRoutine();
}); });
setCookie(currentUser.email, piece.id); //setCookie(currentUser.email, piece.id);
return requests.post(ApiUrls.piece_extradata, { return requests.post(ApiUrls.piece_extradata, {
body: { body: {
@ -149,12 +150,34 @@ const PRRegisterPieceForm = React.createClass({
}; };
}, },
render() { getSubmitButton() {
const { location } = this.props;
const { digitalWorkKeyReady, const { digitalWorkKeyReady,
thumbnailKeyReady, thumbnailKeyReady,
supportingMaterialsReady, supportingMaterialsReady,
proofOfPaymentReady } = this.state; proofOfPaymentReady,
submitted } = this.state;
if(submitted) {
return (
<span disabled className="btn btn-default btn-wide btn-spinner">
<AscribeSpinner color="dark-blue" size="md" />
</span>
);
} else {
return (
<button
type="submit"
className="btn btn-default btn-wide"
disabled={!(digitalWorkKeyReady && thumbnailKeyReady && proofOfPaymentReady && supportingMaterialsReady)}
onClick={this.submit}>
{getLangText('Submit to Portfolio Review')}
</button>
);
}
},
render() {
const { location } = this.props;
return ( return (
<div className="register-piece--form"> <div className="register-piece--form">
@ -328,18 +351,11 @@ const PRRegisterPieceForm = React.createClass({
className="ascribe-property-collapsible-toggle" className="ascribe-property-collapsible-toggle"
style={{paddingBottom: 0}}> style={{paddingBottom: 0}}>
<span> <span>
<input type="checkbox" value="true" />
{getLangText('By submitting this form, you agree to the Terms of Service of Portfolio Review.')} {getLangText('By submitting this form, you agree to the Terms of Service of Portfolio Review.')}
</span> </span>
</Property> </Property>
</Form> </Form>
<button {this.getSubmitButton()}
type="submit"
className="btn btn-default btn-wide"
disabled={!(digitalWorkKeyReady && thumbnailKeyReady && proofOfPaymentReady && supportingMaterialsReady)}
onClick={this.submit}>
{getLangText('Submit to Portfolio Review')}
</button>
</div> </div>
); );
} }

View File

@ -24,7 +24,7 @@ $pr--button-color: $pr--nav-fg-prim-color;
} }
.ascribe-property { .ascribe-property {
> p > span, > p > span:not(> .span),
> textarea, > textarea,
> input { > input {
color: $pr--nav-fg-prim-color; color: $pr--nav-fg-prim-color;