1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 00:28:00 +02:00

Fix bug that threw an error when passing nullish prop to PieceListFilterDisplay

This commit is contained in:
Tim Daubenschütz 2015-12-02 12:23:38 +01:00
parent b4ddec3427
commit 85340a9126
3 changed files with 4 additions and 5 deletions

View File

@ -133,7 +133,7 @@ let PieceList = React.createClass({
const defaultFilterBy = {}; const defaultFilterBy = {};
if (filterParams && typeof filterParams.forEach === 'function') { if (filterParams && typeof filterParams.forEach === 'function') {
filterParams.forEach(({ label, items }) => { filterParams.forEach(({ items }) => {
items.forEach((item) => { items.forEach((item) => {
if (typeof item === 'object' && item.defaultValue) { if (typeof item === 'object' && item.defaultValue) {
defaultFilterBy[item.key] = true; defaultFilterBy[item.key] = true;
@ -211,7 +211,7 @@ let PieceList = React.createClass({
}, },
loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) { loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) {
let orderBy = this.state.orderBy ? this.state.orderBy : this.props.orderBy; const orderBy = this.state.orderBy || this.props.orderBy;
return PieceListActions.fetchPieceList(page, this.state.pageSize, search, return PieceListActions.fetchPieceList(page, this.state.pageSize, search,
orderBy, this.state.orderAsc, filterBy); orderBy, this.state.orderAsc, filterBy);
@ -259,7 +259,6 @@ let PieceList = React.createClass({
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view'); const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
setDocumentTitle(getLangText('Collection')); setDocumentTitle(getLangText('Collection'));
return ( return (
<div> <div>
<PieceListToolbar <PieceListToolbar

View File

@ -97,12 +97,12 @@ let PieceListFilterDisplay = React.createClass({
render() { render() {
let { filterBy } = this.props; let { filterBy } = this.props;
let filtersWithLabel = this.transformFilterParamsItemsToBools();
// do not show the FilterDisplay if there are no filters applied // do not show the FilterDisplay if there are no filters applied
if(filterBy && Object.keys(filterBy).length === 0) { if(filterBy && Object.keys(filterBy).length === 0) {
return null; return null;
} else { } else {
const filtersWithLabel = this.transformFilterParamsItemsToBools();
return ( return (
<div className="row"> <div className="row">
<div className="ascribe-piece-list-filter-display col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2"> <div className="ascribe-piece-list-filter-display col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2">

View File

@ -50,7 +50,7 @@ let MarketPieceList = React.createClass({
render() { render() {
const { currentUser, whitelabel } = this.state; const { currentUser, whitelabel } = this.state;
let filterParams = undefined; let filterParams = null;
let canLoadPieceList = false; let canLoadPieceList = false;
if (currentUser.email && whitelabel.user) { if (currentUser.email && whitelabel.user) {