mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Fix formatting and use destructuring
This commit is contained in:
parent
989fd8ea5c
commit
7d91832d74
@ -82,6 +82,10 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
editionList.orderBy, editionList.orderAsc, editionList.filterBy);
|
editionList.orderBy, editionList.orderAsc, editionList.filterBy);
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
|
const { className, parentId } = this.props;
|
||||||
|
const { editionList, isEditionListOpenForPieceId, showMoreLoading } = this.state;
|
||||||
|
const editionsForPiece = editionList[parentId];
|
||||||
|
|
||||||
let selectedEditionsCount = 0;
|
let selectedEditionsCount = 0;
|
||||||
let allEditionsCount = 0;
|
let allEditionsCount = 0;
|
||||||
let orderBy;
|
let orderBy;
|
||||||
@ -89,37 +93,34 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
let show = false;
|
let show = false;
|
||||||
let showExpandOption = 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
|
// 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
|
// piece are already defined. Otherwise .length will throw an error and we'll not
|
||||||
// be notified about it.
|
// be notified about it.
|
||||||
if(editionsForPiece) {
|
if (editionsForPiece) {
|
||||||
selectedEditionsCount = this.filterSelectedEditions().length;
|
selectedEditionsCount = this.filterSelectedEditions().length;
|
||||||
allEditionsCount = editionsForPiece.length;
|
allEditionsCount = editionsForPiece.length;
|
||||||
orderBy = editionsForPiece.orderBy;
|
orderBy = editionsForPiece.orderBy;
|
||||||
orderAsc = editionsForPiece.orderAsc;
|
orderAsc = editionsForPiece.orderAsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.props.parentId in this.state.isEditionListOpenForPieceId) {
|
if (parentId in isEditionListOpenForPieceId) {
|
||||||
show = this.state.isEditionListOpenForPieceId[this.props.parentId].show;
|
show = isEditionListOpenForPieceId[parentId].show;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the number of editions in the array is equal to the maximum number of editions,
|
// 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
|
// 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;
|
showExpandOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let transition = new TransitionModel('editions', 'editionId', 'bitcoin_id', (e) => e.stopPropagation() );
|
let transition = new TransitionModel('editions', 'editionId', 'bitcoin_id', (e) => e.stopPropagation() );
|
||||||
|
|
||||||
let columnList = [
|
const columnList = [
|
||||||
new ColumnModel(
|
new ColumnModel(
|
||||||
(item) => {
|
(item) => {
|
||||||
return {
|
return {
|
||||||
'editionId': item.id,
|
'editionId': item.id,
|
||||||
'pieceId': this.props.parentId,
|
'pieceId': parentId,
|
||||||
'selectItem': this.selectItem,
|
'selectItem': this.selectItem,
|
||||||
'selected': item.selected
|
'selected': item.selected
|
||||||
}; },
|
}; },
|
||||||
@ -173,11 +174,11 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
if(show && editionsForPiece && editionsForPiece.length > 0) {
|
if (show && editionsForPiece && editionsForPiece.length) {
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={className}>
|
||||||
<AccordionListItemTable
|
<AccordionListItemTable
|
||||||
parentId={this.props.parentId}
|
parentId={parentId}
|
||||||
itemList={editionsForPiece}
|
itemList={editionsForPiece}
|
||||||
columnList={columnList}
|
columnList={columnList}
|
||||||
show={show}
|
show={show}
|
||||||
@ -188,7 +189,14 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
<AccordionListItemTableToggle
|
<AccordionListItemTableToggle
|
||||||
className="ascribe-accordion-list-table-toggle"
|
className="ascribe-accordion-list-table-toggle"
|
||||||
onClick={this.loadFurtherEditions}
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user