From e536704fe5bcaf62c22eaebdfdc28b3add3238fb Mon Sep 17 00:00:00 2001 From: Conrad Date: Mon, 29 Jan 2018 12:34:17 -0500 Subject: [PATCH] Display project type in bgroup --- src/containers/BGroup/BGroup.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index 75cfb04c..ffe1022c 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -369,9 +369,9 @@ class BGroup extends Component { // Handle this one differently because it's a list if (row[filter.id]) { return row[filter.id].reduce((acc, val) => ( - acc || val.toLowerCase().indexOf( + val && (acc || val.toLowerCase().indexOf( filter.value.toLowerCase() - ) !== -1 + ) !== -1) ), false); } return false; @@ -501,6 +501,28 @@ class BGroup extends Component { filterable: false, style: { textAlign: 'center' }, accessor: 'num_projects', + }, { + Header: 'Project Types', + filterMethod: (filter, row) => { + // Handle this one differently because it's a list + if (row[filter.id]) { + + return row[filter.id].reduce((acc, val) => ( + val && (acc || val.toLowerCase().indexOf( + filter.value.toLowerCase() + ) !== -1) + ), false); + } + return false; + }, + accessor: 'project_types', + Cell: row => (row.value ? ( + + ) : null), }, ], }]; @@ -516,8 +538,10 @@ class BGroup extends Component { const projects = this.state.buildingIdProject[val.building_id]; if (projects) { val.num_projects = projects.length; + val.project_types = projects.map(proj => (proj.project_type)); } else { val.num_projects = 0; + val.project_types = []; } const utilityStatus = this.state.utilityAccountsStatus[val.building_id]; if (utilityStatus) { @@ -597,6 +621,7 @@ class BGroup extends Component { return (
  • { i.state } + {' '} - { i.project_type } {' '} - {i.name}
  • ); -- GitLab