1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +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 {
start() {
console.log('start');
let subdomain = window.location.host.split('.')[0];
requests.get('whitelabel_settings', {'subdomain': subdomain})
.then(this.loadSubdomain.bind(this))
@ -45,11 +46,13 @@ class AppGateway {
this.load('prize');
}
loadDefault() {
loadDefault(error) {
console.log('Loading default app, error'. error);
this.load('default');
}
load(type) {
console.log('loading', type);
Router.run(getRoutes(type), Router.HistoryLocation, (App) => {
React.render(
<App />,

View File

@ -22,7 +22,7 @@ let AccordionList = React.createClass({
} else if(this.props.count === 0) {
return (
<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>
</div>
);

View File

@ -56,6 +56,30 @@ let PieceList = React.createClass({
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) {
PieceListActions.fetchPieceList(1, this.state.pageSize, searchTerm, this.state.orderBy, this.state.orderAsc);
this.transitionTo(this.getPathname(), {page: 1});
@ -67,15 +91,11 @@ let PieceList = React.createClass({
},
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'} />);
return (
<div>
<PieceListToolbar
className="ascribe-piece-list-toolbar"
searchFor={this.searchFor} />
{this.getPieceListToolbar()}
<PieceListBulkModal className="ascribe-piece-list-bulk-modal" />
<AccordionList
className="ascribe-accordion-list"
@ -101,10 +121,7 @@ let PieceList = React.createClass({
);
})}
</AccordionList>
<Pagination
currentPage={currentPage}
totalPages={totalPages}
goToPage={this.paginationGoToPage} />
{this.getPagination()}
</div>
);
}

View File

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

View File

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

View File

@ -7,6 +7,8 @@ import Landing from './components/landing';
import LoginContainer from './components/login_container';
import SignupContainer from './components/signup_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 AppConstants from '../../../constants/application_constants';
@ -23,6 +25,7 @@ function getRoutes(commonRoutes) {
<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="pieces" path="collection" handler={PieceList} />
</Route>
);
}