1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Fix formatting and use destructuring

This commit is contained in:
Brett Sun 2015-12-18 15:12:29 +01:00
parent 989fd8ea5c
commit 7d91832d74

View File

@ -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 = <AscribeSpinner size="sm" color="dark-blue" />;
// 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 (
<div className={this.props.className}>
<div className={className}>
<AccordionListItemTable
parentId={this.props.parentId}
parentId={parentId}
itemList={editionsForPiece}
columnList={columnList}
show={show}
@ -188,7 +189,14 @@ let AccordionListItemTableEditions = React.createClass({
<AccordionListItemTableToggle
className="ascribe-accordion-list-table-toggle"
onClick={this.loadFurtherEditions}
message={show && showExpandOption ? <span>{this.state.showMoreLoading ? loadingSpinner : <span className="glyphicon glyphicon-option-horizontal" aria-hidden="true" style={{top: 3}} />} Show me more</span> : null} />
message={show && showExpandOption ? (
<span>
{showMoreLoading ? <AscribeSpinner size="sm" color="dark-blue" />
: <span className="glyphicon glyphicon-option-horizontal" aria-hidden="true" style={{top: 3}} />}
{getLangText('Show me more')}
</span>
) : null
} />
</div>
);
} else {