1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Declutter piece list if no pieces are found

This commit is contained in:
vrde 2015-07-13 21:51:05 +02:00
parent 69b3c8e3dd
commit 1aa2863b80
6 changed files with 36 additions and 16 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

@ -56,6 +56,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.props.query.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 +91,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 +121,7 @@ let PieceList = React.createClass({
); );
})} })}
</AccordionList> </AccordionList>
<Pagination {this.getPagination()}
currentPage={currentPage}
totalPages={totalPages}
goToPage={this.paginationGoToPage} />
</div> </div>
); );
} }

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

@ -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,8 @@ 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 RegisterPiece from '../../../components/register_piece';
import PieceList from '../../../components/piece_list';
import App from './app'; import App from './app';
import AppConstants from '../../../constants/application_constants'; import AppConstants from '../../../constants/application_constants';
@ -23,6 +25,7 @@ function getRoutes(commonRoutes) {
<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={RegisterPiece} />
<Route name="pieces" path="collection" handler={PieceList} />
</Route> </Route>
); );
} }