separate cc register form

This commit is contained in:
Tim Daubenschütz 2015-08-12 09:30:24 +02:00
parent ac45283968
commit 8612f73e96
5 changed files with 94 additions and 45 deletions

View File

@ -103,6 +103,7 @@ let Form = React.createClass({
if ('getFormData' in this.props){
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
}
console.log(data);
return data;
},

View File

@ -54,7 +54,6 @@ let RegisterPiece = React.createClass( {
getInitialState(){
return mergeOptions(
LicenseStore.getState(),
UserStore.getState(),
WhitelabelStore.getState(),
PieceListStore.getState(),
@ -65,16 +64,13 @@ let RegisterPiece = React.createClass( {
},
componentDidMount() {
LicenseActions.fetchLicense();
WhitelabelActions.fetchWhitelabel();
LicenseStore.listen(this.onChange);
PieceListStore.listen(this.onChange);
UserStore.listen(this.onChange);
WhitelabelStore.listen(this.onChange);
},
componentWillUnmount() {
LicenseStore.unlisten(this.onChange);
PieceListStore.unlisten(this.onChange);
UserStore.unlisten(this.onChange);
WhitelabelStore.unlisten(this.onChange);
@ -109,37 +105,6 @@ let RegisterPiece = React.createClass( {
this.transitionTo('piece', {pieceId: response.piece.id});
},
onLicenseChange(event){
//console.log(this.state.licenses[event.target.selectedIndex].url);
this.setState({selectedLicense: event.target.selectedIndex});
},
getLicenses() {
if (this.state.licenses && this.state.licenses.length > 1) {
return (
<Property
name='license'
label={getLangText('Copyright license%s', '...')}
onChange={this.onLicenseChange}
footer={
<a className="pull-right" href={this.state.licenses[this.state.selectedLicense].url} target="_blank">{getLangText('Learn more')}
</a>}>
<select name="license">
{this.state.licenses.map((license, i) => {
return (
<option
name={i}
key={i}
value={ license.code }>
{ license.code.toUpperCase() }: { license.name }
</option>
);
})}
</select>
</Property>);
}
return null;
},
getSpecifyEditions() {
if(this.state.whitelabel && this.state.whitelabel.acl_create_editions || Object.keys(this.state.whitelabel).length === 0) {
return (
@ -192,7 +157,6 @@ let RegisterPiece = React.createClass( {
handleSuccess={this.handleSuccess}
onLoggedOut={this.onLoggedOut}>
{this.props.children}
{this.getLicenses()}
{this.getSpecifyEditions()}
</RegisterPieceForm>
</Col>

View File

@ -0,0 +1,85 @@
'use strict';
import React from 'react';
import RegisterPiece from '../../../../register_piece';
import Property from '../../../../ascribe_forms/property';
import LicenseActions from '../../../../../actions/license_actions';
import LicenseStore from '../../../../../stores/license_store';
import { getLangText } from '../../../../../utils/lang_utils';
import { mergeOptions } from '../../../../../utils/general_utils';
let CCRegisterPiece = React.createClass({
getInitialState() {
return mergeOptions(
LicenseStore.getState(),
{
selectedLicense: 0
}
);
},
componentDidMount() {
LicenseStore.listen(this.onChange);
LicenseActions.fetchLicense();
},
componentWillUnmount() {
LicenseStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
onLicenseChange(event){
this.setState({selectedLicense: event.target.selectedIndex});
},
getLicenses() {
if (this.state.licenses && this.state.licenses.length > 1) {
return (
<Property
name='license'
label={getLangText('Copyright license%s', '...')}
onChange={this.onLicenseChange}
footer={
<a
className="pull-right"
href={this.state.licenses[this.state.selectedLicense].url}
target="_blank">
{getLangText('Learn more')}
</a>
}>
<select name="license">
{this.state.licenses.map((license, i) => {
return (
<option
name={i}
key={i}
value={ license.code }>
{ license.code.toUpperCase() }: { license.name }
</option>
);
})}
</select>
</Property>);
}
return null;
},
render() {
return (
<RegisterPiece
enableLocalHashing={false}
headerMessage={getLangText('Submit to Creative Commons')}
submitMessage={getLangText('Submit')}>
{this.getLicenses()}
</RegisterPiece>
);
}
});
export default CCRegisterPiece;

View File

@ -1,11 +1,8 @@
'use strict';
import WalletAppConstants from './wallet_application_constants';
function getPrizeApiUrls(subdomain) {
return {
'pieces_list': WalletAppConstants.walletApiEndpoint + subdomain + '/pieces/'
};
// gets subdomain as a parameter
function getPrizeApiUrls() {
return {};
}
export default getPrizeApiUrls;

View File

@ -3,17 +3,19 @@
import React from 'react';
import Router from 'react-router';
// general components
import LoginContainer from '../../../components/login_container';
import LogoutContainer from '../../../components/logout_container';
import SignupContainer from '../../../components/signup_container';
import PasswordResetContainer from '../../../components/password_reset_container';
import CylandRegisterPiece from './components/cyland/cyland_register_piece';
import PieceList from '../../../components/piece_list';
import PieceContainer from '../../../components/ascribe_detail/piece_container';
import EditionContainer from '../../../components/ascribe_detail/edition_container';
import SettingsContainer from '../../../components/settings_container';
import RegisterPiece from '../../../components/register_piece';
// specific components
import CylandRegisterPiece from './components/cyland/cyland_register_piece';
import CCRegisterPiece from './components/cc/cc_register_piece';
import WalletApp from './wallet_app';
import AppConstants from '../../../constants/application_constants';
@ -46,7 +48,7 @@ let ROUTES = {
<Route name="logout" path="logout" handler={LogoutContainer} />
<Route name="signup" path="signup" handler={SignupContainer} />
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
<Route name="register_piece" path="register_piece" handler={RegisterPiece} />
<Route name="register_piece" path="register_piece" handler={CCRegisterPiece} />
<Route name="pieces" path="collection" handler={PieceList} />
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />