1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00

make cyland submission stateful

This commit is contained in:
Tim Daubenschütz 2015-08-19 16:02:10 +02:00
parent 0b4b3fa727
commit d5e8181855
3 changed files with 18 additions and 19 deletions

View File

@ -36,12 +36,19 @@ let CylandSubmitButton = React.createClass({
},
render() {
let piece = this.props.piece;
let startFrom = 1;
if(piece && piece.extra_data && Object.keys(piece.extra_data).length > 0) {
startFrom = 2;
}
return (
<ButtonLink
to="register_piece"
query={{
'slide_num': 0,
'start_from': 1,
'start_from': startFrom,
'piece_id': this.props.piece.id
}}
className={classNames('btn', 'btn-default', 'btn-xs', this.props.className)}>

View File

@ -64,17 +64,6 @@ let CylandAdditionalDataForm = React.createClass({
},
render() {
let artistBio = '';
let conceptualOverview = '';
if (Object.keys(this.props.piece).length !== 0 && Object.keys(this.props.piece.extra_data).length !== 0) {
let extraData = this.props.piece.extra_data;
artistBio = extraData.artist_bio;
conceptualOverview = extraData.conceptual_overview;
}
if(this.props.piece && this.props.piece.id) {
return (
<Form
@ -107,7 +96,6 @@ let CylandAdditionalDataForm = React.createClass({
rows={1}
editable={true}
placeholder={getLangText('Enter the artist\'s biography...')}
defaultValue={artistBio}
required="required"/>
</Property>
<Property
@ -118,7 +106,6 @@ let CylandAdditionalDataForm = React.createClass({
rows={1}
editable={true}
placeholder={getLangText('Enter a conceptual overview...')}
defaultValue={conceptualOverview}
required="required"/>
</Property>
<FurtherDetailsFileuploader

View File

@ -92,6 +92,8 @@ let CylandRegisterPiece = React.createClass({
handleRegisterSuccess(response){
this.refreshPieceList();
// also start loading the piece for the next step
if(response && response.piece) {
PieceActions.updatePiece(response.piece);
@ -101,6 +103,7 @@ let CylandRegisterPiece = React.createClass({
},
handleAdditionalDataSuccess() {
this.refreshPieceList();
this.refs.slidesContainer.nextSlide();
},
@ -108,8 +111,13 @@ let CylandRegisterPiece = React.createClass({
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
// once the user was able to register + loan a piece successfully, we need to make sure to keep
// the piece list up to date
this.refreshPieceList();
PieceActions.fetchOne(this.state.piece.id);
this.transitionTo('piece', {pieceId: this.state.piece.id});
},
refreshPieceList() {
PieceListActions.fetchPieceList(
this.state.page,
this.state.pageSize,
@ -118,9 +126,6 @@ let CylandRegisterPiece = React.createClass({
this.state.orderAsc,
this.state.filterBy
);
PieceActions.fetchOne(this.state.piece.id);
this.transitionTo('piece', {pieceId: this.state.piece.id});
},
changeSlide() {