From 7d91832d7486e65417aa3c2a2b80991b437597b1 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Fri, 18 Dec 2015 15:12:29 +0100 Subject: [PATCH] Fix formatting and use destructuring --- .../accordion_list_item_table_editions.js | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js index 23cfb239..761134e3 100644 --- a/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js +++ b/js/components/ascribe_accordion_list/accordion_list_item_table_editions.js @@ -82,6 +82,10 @@ let AccordionListItemTableEditions = React.createClass({ editionList.orderBy, editionList.orderAsc, editionList.filterBy); }, render() { + const { className, parentId } = this.props; + const { editionList, isEditionListOpenForPieceId, showMoreLoading } = this.state; + const editionsForPiece = editionList[parentId]; + let selectedEditionsCount = 0; let allEditionsCount = 0; let orderBy; @@ -89,37 +93,34 @@ let AccordionListItemTableEditions = React.createClass({ let show = false; let showExpandOption = false; - let editionsForPiece = this.state.editionList[this.props.parentId]; - let loadingSpinner = ; - // here we need to check if all editions of a specific // piece are already defined. Otherwise .length will throw an error and we'll not // be notified about it. - if(editionsForPiece) { + if (editionsForPiece) { selectedEditionsCount = this.filterSelectedEditions().length; allEditionsCount = editionsForPiece.length; orderBy = editionsForPiece.orderBy; orderAsc = editionsForPiece.orderAsc; } - if(this.props.parentId in this.state.isEditionListOpenForPieceId) { - show = this.state.isEditionListOpenForPieceId[this.props.parentId].show; + if (parentId in isEditionListOpenForPieceId) { + show = isEditionListOpenForPieceId[parentId].show; } // if the number of editions in the array is equal to the maximum number of editions, // then the "Show me more" dialog should be hidden from the user's view - if(editionsForPiece && editionsForPiece.count > editionsForPiece.length) { + if (editionsForPiece && editionsForPiece.count > editionsForPiece.length) { showExpandOption = true; } let transition = new TransitionModel('editions', 'editionId', 'bitcoin_id', (e) => e.stopPropagation() ); - let columnList = [ + const columnList = [ new ColumnModel( (item) => { return { 'editionId': item.id, - 'pieceId': this.props.parentId, + 'pieceId': parentId, 'selectItem': this.selectItem, 'selected': item.selected }; }, @@ -173,11 +174,11 @@ let AccordionListItemTableEditions = React.createClass({ ) ]; - if(show && editionsForPiece && editionsForPiece.length > 0) { + if (show && editionsForPiece && editionsForPiece.length) { return ( -
+
{this.state.showMoreLoading ? loadingSpinner : : null} /> + message={show && showExpandOption ? ( + + {showMoreLoading ? + : + ) : null + } />
); } else {