1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-05 11:25:09 +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) .fetch(pieceId, page, pageSize, orderBy, orderAsc)
.then((res) => { .then((res) => {
this.actions.updateEditionList({ this.actions.updateEditionList({
'editionListOfPiece': res.editions,
pieceId, pieceId,
page, page,
pageSize, pageSize,
orderBy, orderBy,
orderAsc orderAsc,
'editionListOfPiece': res.editions,
'count': res.count
}); });
resolve(res); resolve(res);
}) })

View File

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

View File

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