mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Merge pull request #37 from ascribe/AD-1345-remind-users-not-to-leave-long-submission-form
Ad 1345 remind users not to leave long submission form
This commit is contained in:
commit
6888aaa8d9
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
import { History } from 'react-router';
|
||||
import { History, RouteContext } from 'react-router';
|
||||
|
||||
import UserStore from '../../../stores/user_store';
|
||||
import UserActions from '../../../actions/user_actions';
|
||||
@ -37,7 +37,9 @@ export default function AuthProxyHandler({to, when}) {
|
||||
location: object
|
||||
},
|
||||
|
||||
mixins: [History],
|
||||
// We need insert `RouteContext` here in order to be able
|
||||
// to use the `Lifecycle` widget in further down nested components
|
||||
mixins: [History, RouteContext],
|
||||
|
||||
getInitialState() {
|
||||
return UserStore.getState();
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import { History } from 'react-router';
|
||||
import { History, Lifecycle } from 'react-router';
|
||||
|
||||
import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs';
|
||||
|
||||
@ -17,14 +17,16 @@ const SlidesContainer = React.createClass({
|
||||
pending: string,
|
||||
complete: string
|
||||
}),
|
||||
location: object
|
||||
location: object,
|
||||
pageExitWarning: string
|
||||
},
|
||||
|
||||
mixins: [History],
|
||||
mixins: [History, Lifecycle],
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
containerWidth: 0
|
||||
containerWidth: 0,
|
||||
pageExitWarning: null
|
||||
};
|
||||
},
|
||||
|
||||
@ -41,6 +43,10 @@ const SlidesContainer = React.createClass({
|
||||
window.removeEventListener('resize', this.handleContainerResize);
|
||||
},
|
||||
|
||||
routerWillLeave() {
|
||||
return this.props.pageExitWarning;
|
||||
},
|
||||
|
||||
handleContainerResize() {
|
||||
this.setState({
|
||||
// +30 to get rid of the padding of the container which is 15px + 15px left and right
|
||||
|
@ -32,6 +32,7 @@ import ApiUrls from '../../../../../constants/api_urls';
|
||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||
import { getLangText } from '../../../../../utils/lang_utils';
|
||||
|
||||
|
||||
let IkonotvRegisterPiece = React.createClass({
|
||||
propTypes: {
|
||||
handleSuccess: React.PropTypes.func,
|
||||
@ -47,7 +48,8 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
PieceListStore.getState(),
|
||||
PieceStore.getState(),
|
||||
{
|
||||
step: 0
|
||||
step: 0,
|
||||
pageExitWarning: getLangText("If you leave this form now, your work will not be loaned to Ikono TV.")
|
||||
});
|
||||
},
|
||||
|
||||
@ -94,7 +96,6 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
|
||||
|
||||
handleRegisterSuccess(response){
|
||||
|
||||
this.refreshPieceList();
|
||||
|
||||
// also start loading the piece for the next step
|
||||
@ -108,7 +109,6 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
this.incrementStep();
|
||||
this.refs.slidesContainer.nextSlide();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
handleAdditionalDataSuccess() {
|
||||
@ -126,6 +126,8 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
handleLoanSuccess(response) {
|
||||
this.setState({ pageExitWarning: null });
|
||||
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
@ -238,6 +240,8 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
const { pageExitWarning } = this.state;
|
||||
|
||||
return (
|
||||
<SlidesContainer
|
||||
ref="slidesContainer"
|
||||
@ -246,7 +250,8 @@ let IkonotvRegisterPiece = React.createClass({
|
||||
pending: 'glyphicon glyphicon-chevron-right',
|
||||
completed: 'glyphicon glyphicon-lock'
|
||||
}}
|
||||
location={this.props.location}>
|
||||
location={this.props.location}
|
||||
pageExitWarning={pageExitWarning}>
|
||||
<div data-slide-title={getLangText('Register work')}>
|
||||
<Row className="no-margin">
|
||||
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
||||
|
@ -80,7 +80,7 @@
|
||||
"react": "0.13.2",
|
||||
"react-bootstrap": "0.25.1",
|
||||
"react-datepicker": "^0.12.0",
|
||||
"react-router": "^1.0.0-rc3",
|
||||
"react-router": "1.0.0",
|
||||
"react-router-bootstrap": "^0.19.0",
|
||||
"react-star-rating": "~1.3.2",
|
||||
"react-textarea-autosize": "^2.5.2",
|
||||
|
Loading…
Reference in New Issue
Block a user