1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-14 21:10:27 +01:00

Merge remote-tracking branch 'remotes/origin/master' into AD-419-decouple-piece-registration-from-

This commit is contained in:
diminator 2015-07-13 23:59:07 +02:00
commit 1b3f614c80
11 changed files with 160 additions and 32 deletions

View File

@ -33,6 +33,7 @@ requests.defaults({
class AppGateway { class AppGateway {
start() { start() {
console.log('start');
let subdomain = window.location.host.split('.')[0]; let subdomain = window.location.host.split('.')[0];
requests.get('whitelabel_settings', {'subdomain': subdomain}) requests.get('whitelabel_settings', {'subdomain': subdomain})
.then(this.loadSubdomain.bind(this)) .then(this.loadSubdomain.bind(this))
@ -45,11 +46,13 @@ class AppGateway {
this.load('prize'); this.load('prize');
} }
loadDefault() { loadDefault(error) {
console.log('Loading default app, error'. error);
this.load('default'); this.load('default');
} }
load(type) { load(type) {
console.log('loading', type);
Router.run(getRoutes(type), Router.HistoryLocation, (App) => { Router.run(getRoutes(type), Router.HistoryLocation, (App) => {
React.render( React.render(
<App />, <App />,

View File

@ -22,7 +22,7 @@ let AccordionList = React.createClass({
} else if(this.props.count === 0) { } else if(this.props.count === 0) {
return ( return (
<div> <div>
<p className="text-center">{getLangText('We could not find any works related to you%s', '...')}</p> <p className="text-center">{getLangText('We could not find any works related to you...')}</p>
<p className="text-center">{getLangText('To register one, click')} <a href="register_piece">{getLangText('here')}</a>!</p> <p className="text-center">{getLangText('To register one, click')} <a href="register_piece">{getLangText('here')}</a>!</p>
</div> </div>
); );

View File

@ -13,9 +13,6 @@ import CreateEditionsForm from '../ascribe_forms/create_editions_form';
import PieceListActions from '../../actions/piece_list_actions'; import PieceListActions from '../../actions/piece_list_actions';
import EditionListActions from '../../actions/edition_list_actions'; import EditionListActions from '../../actions/edition_list_actions';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
import { getLangText } from '../../utils/lang_utils'; import { getLangText } from '../../utils/lang_utils';
let Link = Router.Link; let Link = Router.Link;

View File

@ -18,11 +18,20 @@ import { getLangText } from '../../utils/lang_utils';
let RegisterPieceForm = React.createClass({ let RegisterPieceForm = React.createClass({
propTypes: { propTypes: {
headerMessage: React.PropTypes.string,
submitMessage: React.PropTypes.string,
handleSuccess: React.PropTypes.func, handleSuccess: React.PropTypes.func,
isFineUploaderEditable: React.PropTypes.bool, isFineUploaderEditable: React.PropTypes.bool,
children: React.PropTypes.element children: React.PropTypes.element
}, },
getDefaultProps() {
return {
headerMessage: getLangText('Register your work'),
submitMessage: getLangText('Register work')
};
},
getInitialState(){ getInitialState(){
return { return {
digitalWorkKey: null, digitalWorkKey: null,
@ -69,7 +78,7 @@ let RegisterPieceForm = React.createClass({
type="submit" type="submit"
className="btn ascribe-btn ascribe-btn-login" className="btn ascribe-btn ascribe-btn-login"
disabled={!this.state.isUploadReady}> disabled={!this.state.isUploadReady}>
{getLangText('Register work')} {this.props.submitMessage}
</button>} </button>}
spinner={ spinner={
<span className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner"> <span className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
@ -77,7 +86,7 @@ let RegisterPieceForm = React.createClass({
</span> </span>
}> }>
<FormPropertyHeader> <FormPropertyHeader>
<h3>{getLangText('Register your work')}</h3> <h3>{this.props.headerMessage}</h3>
</FormPropertyHeader> </FormPropertyHeader>
<Property <Property
ignoreFocus={true}> ignoreFocus={true}>

View File

@ -20,7 +20,7 @@ import AppConstants from '../constants/application_constants';
let PieceList = React.createClass({ let PieceList = React.createClass({
propTypes: { propTypes: {
query: React.PropTypes.object redirectTo: React.PropTypes.string
}, },
mixins: [Router.Navigation, Router.State], mixins: [Router.Navigation, Router.State],
@ -30,7 +30,7 @@ let PieceList = React.createClass({
}, },
componentDidMount() { componentDidMount() {
let page = this.props.query.page || 1; let page = this.getQuery().page || 1;
PieceListStore.listen(this.onChange); PieceListStore.listen(this.onChange);
if (this.state.pieceList.length === 0){ if (this.state.pieceList.length === 0){
PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc) PieceListActions.fetchPieceList(page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc)
@ -38,6 +38,12 @@ let PieceList = React.createClass({
} }
}, },
componentDidUpdate() {
if (this.props.redirectTo && this.state.pieceListCount === 0) {
this.transitionTo(this.props.redirectTo);
}
},
componentWillUnmount() { componentWillUnmount() {
PieceListStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange);
}, },
@ -56,6 +62,30 @@ let PieceList = React.createClass({
this.state.orderAsc); this.state.orderAsc);
}, },
getPieceListToolbar() {
if(this.state.pieceListCount > 10) {
return (
<PieceListToolbar
className="ascribe-piece-list-toolbar"
searchFor={this.searchFor} />
);
}
},
getPagination() {
let currentPage = parseInt(this.getQuery().page, 10) || 1;
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize);
if (this.state.pieceListCount > 10) {
return (
<Pagination
currentPage={currentPage}
totalPages={totalPages}
goToPage={this.paginationGoToPage} />
);
}
},
searchFor(searchTerm) { searchFor(searchTerm) {
PieceListActions.fetchPieceList(1, this.state.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc); PieceListActions.fetchPieceList(1, this.state.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc);
this.transitionTo(this.getPathname(), {page: 1}); this.transitionTo(this.getPathname(), {page: 1});
@ -67,15 +97,11 @@ let PieceList = React.createClass({
}, },
render() { render() {
let currentPage = parseInt(this.props.query.page, 10) || 1;
let totalPages = Math.ceil(this.state.pieceListCount / this.state.pageSize);
let loadingElement = (<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />); let loadingElement = (<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />);
return ( return (
<div> <div>
<PieceListToolbar {this.getPieceListToolbar()}
className="ascribe-piece-list-toolbar"
searchFor={this.searchFor} />
<PieceListBulkModal className="ascribe-piece-list-bulk-modal" /> <PieceListBulkModal className="ascribe-piece-list-bulk-modal" />
<AccordionList <AccordionList
className="ascribe-accordion-list" className="ascribe-accordion-list"
@ -101,10 +127,7 @@ let PieceList = React.createClass({
); );
})} })}
</AccordionList> </AccordionList>
<Pagination {this.getPagination()}
currentPage={currentPage}
totalPages={totalPages}
goToPage={this.paginationGoToPage} />
</div> </div>
); );
} }

View File

@ -29,9 +29,26 @@ import SlidesContainer from './ascribe_slides_container/slides_container';
import { mergeOptions } from '../utils/general_utils'; import { mergeOptions } from '../utils/general_utils';
import { getLangText } from '../utils/lang_utils'; import { getLangText } from '../utils/lang_utils';
let RegisterPiece = React.createClass( { let RegisterPiece = React.createClass( {
propTypes: {
headerMessage: React.PropTypes.string,
submitMessage: React.PropTypes.string,
canSpecifyEditions: React.PropTypes.bool,
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element])
},
mixins: [Router.Navigation], mixins: [Router.Navigation],
getDefaultProps() {
return {
canSpecifyEditions: true
};
},
getInitialState(){ getInitialState(){
return mergeOptions( return mergeOptions(
LicenseStore.getState(), LicenseStore.getState(),
@ -118,6 +135,21 @@ let RegisterPiece = React.createClass( {
return null; return null;
}, },
getSpecifyEditions() {
if (this.props.canSpecifyEditions) {
return (
<PropertyCollapsible
checkboxLabel={getLangText('Specify editions')}>
<span>{getLangText('Editions')}</span>
<input
type="number"
placeholder="(e.g. 32)"
min={0}/>
</PropertyCollapsible>
);
}
},
changeSlide() { changeSlide() {
// only transition to the login store, if user is not logged in // only transition to the login store, if user is not logged in
// ergo the currentUser object is not properly defined // ergo the currentUser object is not properly defined
@ -135,16 +167,11 @@ let RegisterPiece = React.createClass( {
<Row className="no-margin"> <Row className="no-margin">
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}> <Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm <RegisterPieceForm
{...this.props}
isFineUploaderEditable={this.state.isFineUploaderEditable} isFineUploaderEditable={this.state.isFineUploaderEditable}
handleSuccess={this.handleSuccess}> handleSuccess={this.handleSuccess}>
<PropertyCollapsible {this.getSpecifyEditions()}
checkboxLabel={getLangText('Specify editions')}> {this.props.children}
<span>{getLangText('Editions')}</span>
<input
type="number"
placeholder="(e.g. 32)"
min={0}/>
</PropertyCollapsible>
{this.getLicenses()} {this.getLicenses()}
</RegisterPieceForm> </RegisterPieceForm>
</Col> </Col>

View File

@ -16,9 +16,7 @@ let PrizeApp = React.createClass({
render() { render() {
let header = null; let header = null;
if (this.isActive('pieces')) { if (this.isActive('pieces')) {
header = ( header = null;
<Header />
);
} }
return ( return (

View File

@ -0,0 +1,15 @@
'use strict';
import React from 'react';
import PieceList from '../../../piece_list';
let PrizePieceList = React.createClass({
render() {
return (
<PieceList redirectTo="register_piece" />
);
}
});
export default PrizePieceList;

View File

@ -0,0 +1,50 @@
'use strict';
import React from 'react';
import RegisterPiece from '../../../register_piece';
import Property from '../../../ascribe_forms/property';
import InputTextAreaToggable from '../../../ascribe_forms/input_textarea_toggable';
import InputCheckbox from '../../../ascribe_forms/input_checkbox';
import { getLangText } from '../../../../utils/lang_utils';
let PrizeRegisterPiece = React.createClass({
render() {
return (
<RegisterPiece
headerMessage={getLangText('Submit to the prize')}
submitMessage={getLangText('Submit')}
canSpecifyEditions={false} >
<Property
name='artist_statement'
label={getLangText('Artist statement')}
editable={true}>
<InputTextAreaToggable
rows={1}
editable={true}
placeholder={getLangText('Enter your statement')}
required="required"/>
</Property>
<Property
name='work_description'
label={getLangText('Work description')}
editable={true}>
<InputTextAreaToggable
rows={1}
editable={true}
placeholder={getLangText('Enter the description for your work')}
required="required"/>
</Property>
<Property
name="terms"
className="ascribe-settings-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox/>
</Property>
</RegisterPiece>
);
}
});
export default PrizeRegisterPiece;

View File

@ -23,9 +23,8 @@ let SignupContainer = React.createClass({
if (this.state.submitted){ if (this.state.submitted){
return ( return (
<div className="ascribe-login-wrapper"> <div className="ascribe-login-wrapper">
<br/>
<div className="ascribe-login-text ascribe-login-header"> <div className="ascribe-login-text ascribe-login-header">
{this.state.message} {this.state.message}
</div> </div>
</div> </div>
); );

View File

@ -7,6 +7,10 @@ import Landing from './components/landing';
import LoginContainer from './components/login_container'; import LoginContainer from './components/login_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 PrizeRegisterPiece from './components/register_piece';
import PrizePieceList from './components/piece_list';
import PieceContainer from '../../ascribe_detail/piece_container';
import EditionContainer from '../../ascribe_detail/edition_container';
import App from './app'; import App from './app';
import AppConstants from '../../../constants/application_constants'; import AppConstants from '../../../constants/application_constants';
@ -22,7 +26,10 @@ function getRoutes(commonRoutes) {
<Route name="login" path="login" handler={LoginContainer} /> <Route name="login" path="login" handler={LoginContainer} />
<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={PrizeRegisterPiece} />
<Route name="pieces" path="collection" handler={PrizePieceList} />
<Route name="piece" path="pieces/:pieceId" handler={PieceContainer} />
<Route name="edition" path="editions/:editionId" handler={EditionContainer} />
</Route> </Route>
); );
} }