mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Better robustness for slides container and register form for cyland
This commit is contained in:
parent
dab7503601
commit
713eea03cc
@ -29,8 +29,6 @@ const SlidesContainer = React.createClass({
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
this.handleContainerResize();
|
||||
|
||||
// we're using an event listener on window here,
|
||||
// as it was not possible to listen to the resize events of a dom node
|
||||
window.addEventListener('resize', this.handleContainerResize);
|
||||
@ -51,16 +49,15 @@ const SlidesContainer = React.createClass({
|
||||
},
|
||||
|
||||
// When the start_from parameter is used, this.setSlideNum can not simply be used anymore.
|
||||
nextSlide() {
|
||||
const slideNum = parseInt(this.props.location.query.slide_num, 10);
|
||||
nextSlide(additionalQueryParams) {
|
||||
const slideNum = parseInt(this.props.location.query.slide_num, 10) || 0;
|
||||
let nextSlide = slideNum + 1;
|
||||
this.setSlideNum(nextSlide);
|
||||
this.setSlideNum(nextSlide, additionalQueryParams);
|
||||
},
|
||||
|
||||
setSlideNum(nextSlideNum) {
|
||||
let queryParams = this.props.location.query;
|
||||
setSlideNum(nextSlideNum, additionalQueryParams = {}) {
|
||||
let queryParams = Object.assign(this.props.location.query, additionalQueryParams);
|
||||
queryParams.slide_num = nextSlideNum;
|
||||
|
||||
this.history.pushState(null, this.props.location.pathname, queryParams);
|
||||
},
|
||||
|
||||
@ -107,7 +104,7 @@ const SlidesContainer = React.createClass({
|
||||
return (
|
||||
<SlidesContainerBreadcrumbs
|
||||
breadcrumbs={breadcrumbs}
|
||||
slideNum={parseInt(this.props.location.query.slide_num, 10)}
|
||||
slideNum={parseInt(this.props.location.query.slide_num, 10) || 0}
|
||||
numOfSlides={breadcrumbs.length}
|
||||
containerWidth={this.state.containerWidth}
|
||||
glyphiconClassNames={this.props.glyphiconClassNames}/>
|
||||
@ -142,7 +139,7 @@ const SlidesContainer = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
let spacing = this.state.containerWidth * parseInt(this.props.location.query.slide_num, 10);
|
||||
let spacing = this.state.containerWidth * parseInt(this.props.location.query.slide_num, 10) || 0;
|
||||
let translateXValue = 'translateX(' + (-1) * spacing + 'px)';
|
||||
|
||||
/*
|
||||
|
@ -38,28 +38,18 @@ let CylandSubmitButton = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
let piece = this.props.piece;
|
||||
let startFrom = 1;
|
||||
|
||||
// In the Cyland register page a user has to complete three steps.
|
||||
// Since every one of those steps is atomic a user should always be able to continue
|
||||
// where he left of.
|
||||
// This is why we start the process form slide 1/2 if the user has already finished
|
||||
// it in another session.
|
||||
if(piece && piece.extra_data && Object.keys(piece.extra_data).length > 0) {
|
||||
startFrom = 2;
|
||||
}
|
||||
const { piece, className } = this.props;
|
||||
|
||||
return (
|
||||
<LinkContainer
|
||||
to="/register_piece"
|
||||
query={{
|
||||
'slide_num': 0,
|
||||
'start_from': startFrom,
|
||||
'piece_id': this.props.piece.id
|
||||
'start_from': 1,
|
||||
'piece_id': piece.id
|
||||
}}>
|
||||
<Button
|
||||
className={classNames('btn', 'btn-default', 'btn-xs', this.props.className)}>
|
||||
className={classNames('btn', 'btn-default', 'btn-xs', className)}>
|
||||
{getLangText('Submit to Cyland')}
|
||||
</Button>
|
||||
</LinkContainer>
|
||||
|
@ -36,17 +36,17 @@ let CylandAdditionalDataForm = React.createClass({
|
||||
};
|
||||
},
|
||||
|
||||
handleSuccess() {
|
||||
let notification = new GlobalNotificationModel('Further details successfully updated', 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
isUploadReady: true
|
||||
};
|
||||
},
|
||||
|
||||
handleSuccess() {
|
||||
let notification = new GlobalNotificationModel('Further details successfully updated', 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
},
|
||||
|
||||
getFormData() {
|
||||
let extradata = {};
|
||||
let formRefs = this.refs.form.refs;
|
||||
|
@ -104,12 +104,13 @@ let CylandRegisterPiece = React.createClass({
|
||||
|
||||
// also start loading the piece for the next step
|
||||
if(response && response.piece) {
|
||||
PieceActions.updatePiece({});
|
||||
PieceActions.updatePiece(response.piece);
|
||||
}
|
||||
|
||||
this.incrementStep();
|
||||
|
||||
this.refs.slidesContainer.nextSlide();
|
||||
this.refs.slidesContainer.nextSlide({ piece_id: response.piece.id });
|
||||
},
|
||||
|
||||
handleAdditionalDataSuccess() {
|
||||
|
Loading…
Reference in New Issue
Block a user