1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01: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 = {};
if (filterParams && typeof filterParams.forEach === 'function') {
filterParams.forEach(({ label, items }) => {
filterParams.forEach(({ items }) => {
items.forEach((item) => {
if (typeof item === 'object' && item.defaultValue) {
defaultFilterBy[item.key] = true;
@ -211,7 +211,7 @@ let PieceList = React.createClass({
},
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,
orderBy, this.state.orderAsc, filterBy);
@ -259,7 +259,6 @@ let PieceList = React.createClass({
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
setDocumentTitle(getLangText('Collection'));
return (
<div>
<PieceListToolbar

View File

@ -97,12 +97,12 @@ let PieceListFilterDisplay = React.createClass({
render() {
let { filterBy } = this.props;
let filtersWithLabel = this.transformFilterParamsItemsToBools();
// do not show the FilterDisplay if there are no filters applied
if(filterBy && Object.keys(filterBy).length === 0) {
return null;
} else {
const filtersWithLabel = this.transformFilterParamsItemsToBools();
return (
<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">

View File

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