mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
separate cc register form
This commit is contained in:
parent
ac45283968
commit
8612f73e96
@ -103,6 +103,7 @@ let Form = React.createClass({
|
|||||||
if ('getFormData' in this.props){
|
if ('getFormData' in this.props){
|
||||||
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
|
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
|
||||||
}
|
}
|
||||||
|
console.log(data);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ let RegisterPiece = React.createClass( {
|
|||||||
|
|
||||||
getInitialState(){
|
getInitialState(){
|
||||||
return mergeOptions(
|
return mergeOptions(
|
||||||
LicenseStore.getState(),
|
|
||||||
UserStore.getState(),
|
UserStore.getState(),
|
||||||
WhitelabelStore.getState(),
|
WhitelabelStore.getState(),
|
||||||
PieceListStore.getState(),
|
PieceListStore.getState(),
|
||||||
@ -65,16 +64,13 @@ let RegisterPiece = React.createClass( {
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
LicenseActions.fetchLicense();
|
|
||||||
WhitelabelActions.fetchWhitelabel();
|
WhitelabelActions.fetchWhitelabel();
|
||||||
LicenseStore.listen(this.onChange);
|
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
WhitelabelStore.listen(this.onChange);
|
WhitelabelStore.listen(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
LicenseStore.unlisten(this.onChange);
|
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
UserStore.unlisten(this.onChange);
|
UserStore.unlisten(this.onChange);
|
||||||
WhitelabelStore.unlisten(this.onChange);
|
WhitelabelStore.unlisten(this.onChange);
|
||||||
@ -109,37 +105,6 @@ let RegisterPiece = React.createClass( {
|
|||||||
this.transitionTo('piece', {pieceId: response.piece.id});
|
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() {
|
getSpecifyEditions() {
|
||||||
if(this.state.whitelabel && this.state.whitelabel.acl_create_editions || Object.keys(this.state.whitelabel).length === 0) {
|
if(this.state.whitelabel && this.state.whitelabel.acl_create_editions || Object.keys(this.state.whitelabel).length === 0) {
|
||||||
return (
|
return (
|
||||||
@ -192,7 +157,6 @@ let RegisterPiece = React.createClass( {
|
|||||||
handleSuccess={this.handleSuccess}
|
handleSuccess={this.handleSuccess}
|
||||||
onLoggedOut={this.onLoggedOut}>
|
onLoggedOut={this.onLoggedOut}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
{this.getLicenses()}
|
|
||||||
{this.getSpecifyEditions()}
|
{this.getSpecifyEditions()}
|
||||||
</RegisterPieceForm>
|
</RegisterPieceForm>
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -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;
|
@ -1,11 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import WalletAppConstants from './wallet_application_constants';
|
// gets subdomain as a parameter
|
||||||
|
function getPrizeApiUrls() {
|
||||||
function getPrizeApiUrls(subdomain) {
|
return {};
|
||||||
return {
|
|
||||||
'pieces_list': WalletAppConstants.walletApiEndpoint + subdomain + '/pieces/'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getPrizeApiUrls;
|
export default getPrizeApiUrls;
|
@ -3,17 +3,19 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Router from 'react-router';
|
import Router from 'react-router';
|
||||||
|
|
||||||
|
// general components
|
||||||
import LoginContainer from '../../../components/login_container';
|
import LoginContainer from '../../../components/login_container';
|
||||||
import LogoutContainer from '../../../components/logout_container';
|
import LogoutContainer from '../../../components/logout_container';
|
||||||
import SignupContainer from '../../../components/signup_container';
|
import SignupContainer from '../../../components/signup_container';
|
||||||
import PasswordResetContainer from '../../../components/password_reset_container';
|
import PasswordResetContainer from '../../../components/password_reset_container';
|
||||||
import CylandRegisterPiece from './components/cyland/cyland_register_piece';
|
|
||||||
import PieceList from '../../../components/piece_list';
|
import PieceList from '../../../components/piece_list';
|
||||||
import PieceContainer from '../../../components/ascribe_detail/piece_container';
|
import PieceContainer from '../../../components/ascribe_detail/piece_container';
|
||||||
import EditionContainer from '../../../components/ascribe_detail/edition_container';
|
import EditionContainer from '../../../components/ascribe_detail/edition_container';
|
||||||
import SettingsContainer from '../../../components/settings_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 WalletApp from './wallet_app';
|
||||||
import AppConstants from '../../../constants/application_constants';
|
import AppConstants from '../../../constants/application_constants';
|
||||||
@ -46,7 +48,7 @@ let ROUTES = {
|
|||||||
<Route name="logout" path="logout" handler={LogoutContainer} />
|
<Route name="logout" path="logout" handler={LogoutContainer} />
|
||||||
<Route name="signup" path="signup" handler={SignupContainer} />
|
<Route name="signup" path="signup" handler={SignupContainer} />
|
||||||
<Route name="password_reset" path="password_reset" handler={PasswordResetContainer} />
|
<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="pieces" path="collection" handler={PieceList} />
|
||||||
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
|
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
|
||||||
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
|
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
|
||||||
|
Loading…
Reference in New Issue
Block a user