1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01:00

add toggle for show more

This commit is contained in:
Tim Daubenschütz 2015-07-06 15:56:14 +02:00
parent f12a57c3cf
commit 7863431727
3 changed files with 20 additions and 9 deletions

View File

@ -32,12 +32,13 @@ class EditionListActions {
.fetch(pieceId, page, pageSize, orderBy, orderAsc)
.then((res) => {
this.actions.updateEditionList({
'editionListOfPiece': res.editions,
pieceId,
page,
pageSize,
orderBy,
orderAsc
orderAsc,
'editionListOfPiece': res.editions,
'count': res.count
});
resolve(res);
})

View File

@ -82,21 +82,30 @@ let AccordionListItemTableEditions = React.createClass({
let orderBy;
let orderAsc;
let show;
let showExpandOption = false;
let editionsForPiece = this.state.editionList[this.props.parentId];
// 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(this.state.editionList[this.props.parentId]) {
if(editionsForPiece) {
selectedEditionsCount = this.filterSelectedEditions().length;
allEditionsCount = this.state.editionList[this.props.parentId].length;
orderBy = this.state.editionList[this.props.parentId].orderBy;
orderAsc = this.state.editionList[this.props.parentId].orderAsc;
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 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) {
showExpandOption = true;
}
let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id');
let columnList = [
@ -165,7 +174,7 @@ let AccordionListItemTableEditions = React.createClass({
<AccordionListItemTable
className={this.props.className}
parentId={this.props.parentId}
itemList={this.state.editionList[this.props.parentId]}
itemList={editionsForPiece}
columnList={columnList}
show={show}
orderBy={orderBy}
@ -174,7 +183,7 @@ let AccordionListItemTableEditions = React.createClass({
<AccordionListItemTableToggle
className="ascribe-accordion-list-table-toggle"
onClick={this.loadFurtherEditions}
message={show ? <p>Show me more</p> : ''} />
message={show && showExpandOption ? <p>Show me more</p> : ''} />
<AccordionListItemTableToggle
className="ascribe-accordion-list-table-toggle"
onClick={this.toggleTable}

View File

@ -12,7 +12,7 @@ class EditionListStore {
this.bindActions(EditionsListActions);
}
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc}) {
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc, count}) {
for(let i = 0; i < editionListOfPiece.length; i++) {
@ -47,6 +47,7 @@ class EditionListStore {
this.editionList[pieceId].pageSize = pageSize;
this.editionList[pieceId].orderBy = orderBy;
this.editionList[pieceId].orderAsc = orderAsc;
this.editionList[pieceId].count = count;
}
onSelectEdition({pieceId, editionId, toValue}) {