mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
implement form locking for cyland
This commit is contained in:
parent
862cd7986c
commit
495f5600af
@ -28,7 +28,10 @@ let RegisterPieceForm = React.createClass({
|
|||||||
isFineUploaderEditable: React.PropTypes.bool,
|
isFineUploaderEditable: React.PropTypes.bool,
|
||||||
enableLocalHashing: React.PropTypes.bool,
|
enableLocalHashing: React.PropTypes.bool,
|
||||||
children: React.PropTypes.element,
|
children: React.PropTypes.element,
|
||||||
onLoggedOut: React.PropTypes.func
|
onLoggedOut: React.PropTypes.func,
|
||||||
|
|
||||||
|
// For this form to work with SlideContainer, we sometimes have to disable it
|
||||||
|
disabled: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
@ -84,9 +87,10 @@ let RegisterPieceForm = React.createClass({
|
|||||||
let currentUser = this.state.currentUser;
|
let currentUser = this.state.currentUser;
|
||||||
let enableLocalHashing = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
|
let enableLocalHashing = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
|
||||||
enableLocalHashing = enableLocalHashing && this.props.enableLocalHashing;
|
enableLocalHashing = enableLocalHashing && this.props.enableLocalHashing;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
disabled={false}
|
disabled={this.props.disabled}
|
||||||
className="ascribe-form-bordered"
|
className="ascribe-form-bordered"
|
||||||
ref='form'
|
ref='form'
|
||||||
url={ApiUrls.pieces_list}
|
url={ApiUrls.pieces_list}
|
||||||
@ -95,7 +99,7 @@ let RegisterPieceForm = React.createClass({
|
|||||||
buttons={<button
|
buttons={<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn ascribe-btn ascribe-btn-login"
|
className="btn ascribe-btn ascribe-btn-login"
|
||||||
disabled={!this.state.isUploadReady}>
|
disabled={!this.state.isUploadReady || this.props.disabled}>
|
||||||
{this.props.submitMessage}
|
{this.props.submitMessage}
|
||||||
</button>}
|
</button>}
|
||||||
spinner={
|
spinner={
|
||||||
|
@ -19,7 +19,9 @@ import { getLangText } from '../../../../../../utils/lang_utils';
|
|||||||
let CylandAdditionalDataForm = React.createClass({
|
let CylandAdditionalDataForm = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
handleSuccess: React.PropTypes.func.isRequired,
|
handleSuccess: React.PropTypes.func.isRequired,
|
||||||
piece: React.PropTypes.object.isRequired
|
piece: React.PropTypes.object.isRequired,
|
||||||
|
|
||||||
|
disabled: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
@ -67,6 +69,7 @@ let CylandAdditionalDataForm = React.createClass({
|
|||||||
if(this.props.piece && this.props.piece.id) {
|
if(this.props.piece && this.props.piece.id) {
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
|
disabled={this.props.disabled}
|
||||||
className="ascribe-form-bordered"
|
className="ascribe-form-bordered"
|
||||||
ref='form'
|
ref='form'
|
||||||
url={requests.prepareUrl(ApiUrls.piece_extradata, {piece_id: this.props.piece.id})}
|
url={requests.prepareUrl(ApiUrls.piece_extradata, {piece_id: this.props.piece.id})}
|
||||||
@ -76,7 +79,7 @@ let CylandAdditionalDataForm = React.createClass({
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn ascribe-btn ascribe-btn-login"
|
className="btn ascribe-btn ascribe-btn-login"
|
||||||
disabled={!this.state.isUploadReady}>
|
disabled={!this.state.isUploadReady || this.props.disabled}>
|
||||||
{getLangText('Proceed to loan')}
|
{getLangText('Proceed to loan')}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,8 @@ let CylandRegisterPiece = React.createClass({
|
|||||||
WhitelabelStore.getState(),
|
WhitelabelStore.getState(),
|
||||||
{
|
{
|
||||||
selectedLicense: 0,
|
selectedLicense: 0,
|
||||||
isFineUploaderActive: false
|
isFineUploaderActive: false,
|
||||||
|
step: 0
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -99,11 +100,16 @@ let CylandRegisterPiece = React.createClass({
|
|||||||
PieceActions.updatePiece(response.piece);
|
PieceActions.updatePiece(response.piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.incrementStep();
|
||||||
|
|
||||||
this.refs.slidesContainer.nextSlide();
|
this.refs.slidesContainer.nextSlide();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleAdditionalDataSuccess() {
|
handleAdditionalDataSuccess() {
|
||||||
this.refreshPieceList();
|
this.refreshPieceList();
|
||||||
|
|
||||||
|
this.incrementStep();
|
||||||
|
|
||||||
this.refs.slidesContainer.nextSlide();
|
this.refs.slidesContainer.nextSlide();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -117,6 +123,15 @@ let CylandRegisterPiece = React.createClass({
|
|||||||
this.transitionTo('piece', {pieceId: this.state.piece.id});
|
this.transitionTo('piece', {pieceId: this.state.piece.id});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// We need to increase the step to lock the forms that are already filed out
|
||||||
|
incrementStep() {
|
||||||
|
// also increase step
|
||||||
|
let newStep = this.state.step + 1;
|
||||||
|
this.setState({
|
||||||
|
step: newStep
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
refreshPieceList() {
|
refreshPieceList() {
|
||||||
PieceListActions.fetchPieceList(
|
PieceListActions.fetchPieceList(
|
||||||
this.state.page,
|
this.state.page,
|
||||||
@ -155,6 +170,7 @@ let CylandRegisterPiece = React.createClass({
|
|||||||
<Row className="no-margin">
|
<Row className="no-margin">
|
||||||
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
||||||
<RegisterPieceForm
|
<RegisterPieceForm
|
||||||
|
disabled={this.state.step > 0}
|
||||||
enableLocalHashing={false}
|
enableLocalHashing={false}
|
||||||
headerMessage={getLangText('Submit to Cyland Archive')}
|
headerMessage={getLangText('Submit to Cyland Archive')}
|
||||||
submitMessage={getLangText('Submit')}
|
submitMessage={getLangText('Submit')}
|
||||||
@ -182,6 +198,7 @@ let CylandRegisterPiece = React.createClass({
|
|||||||
<Row className="no-margin">
|
<Row className="no-margin">
|
||||||
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
||||||
<CylandAdditionalDataForm
|
<CylandAdditionalDataForm
|
||||||
|
disabled={this.state.step > 1}
|
||||||
handleSuccess={this.handleAdditionalDataSuccess}
|
handleSuccess={this.handleAdditionalDataSuccess}
|
||||||
piece={this.state.piece}/>
|
piece={this.state.piece}/>
|
||||||
</Col>
|
</Col>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user