mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
refactor open state of edition table first cut
This commit is contained in:
parent
d41f5df3ee
commit
9cc70dc4c9
@ -9,7 +9,8 @@ class EditionListActions {
|
||||
this.generateActions(
|
||||
'updateEditionList',
|
||||
'selectEdition',
|
||||
'clearAllEditionSelections'
|
||||
'clearAllEditionSelections',
|
||||
'toggleEditionList'
|
||||
);
|
||||
}
|
||||
|
||||
@ -19,19 +20,24 @@ class EditionListActions {
|
||||
orderAsc = true;
|
||||
}
|
||||
|
||||
EditionListFetcher
|
||||
.fetch(pieceId, orderBy, orderAsc)
|
||||
.then((res) => {
|
||||
this.actions.updateEditionList({
|
||||
'editionListOfPiece': res.editions,
|
||||
pieceId,
|
||||
orderBy,
|
||||
orderAsc
|
||||
return new Promise((resolve, reject) => {
|
||||
EditionListFetcher
|
||||
.fetch(pieceId, orderBy, orderAsc)
|
||||
.then((res) => {
|
||||
this.actions.updateEditionList({
|
||||
'editionListOfPiece': res.editions,
|
||||
pieceId,
|
||||
orderBy,
|
||||
orderAsc
|
||||
});
|
||||
resolve(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
console.log(err);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,7 @@ import PieceListFetcher from '../fetchers/piece_list_fetcher';
|
||||
class PieceListActions {
|
||||
constructor() {
|
||||
this.generateActions(
|
||||
'updatePieceList',
|
||||
'showEditionList',
|
||||
'closeAllEditionLists'
|
||||
'updatePieceList'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ let AccordionListItemTable = React.createClass({
|
||||
parentId: React.PropTypes.number,
|
||||
itemList: React.PropTypes.array,
|
||||
columnList: React.PropTypes.arrayOf(React.PropTypes.instanceOf(ColumnModel)),
|
||||
numOfTableItems: React.PropTypes.number,
|
||||
show: React.PropTypes.bool,
|
||||
changeOrder: React.PropTypes.func,
|
||||
orderBy: React.PropTypes.string,
|
||||
|
@ -22,8 +22,7 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
className: React.PropTypes.string,
|
||||
parentId: React.PropTypes.number,
|
||||
show: React.PropTypes.bool
|
||||
parentId: React.PropTypes.number
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
@ -60,7 +59,7 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
},
|
||||
|
||||
toggleTable() {
|
||||
PieceListActions.showEditionList(this.props.parentId);
|
||||
// This is triggered everytime show all editions is clicked, which is wrong
|
||||
EditionListActions.fetchEditionList(this.props.parentId);
|
||||
},
|
||||
|
||||
@ -73,6 +72,7 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
let allEditionsCount = 0;
|
||||
let orderBy;
|
||||
let orderAsc;
|
||||
let show;
|
||||
|
||||
// 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
|
||||
@ -84,6 +84,10 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
orderAsc = this.state.editionList[this.props.parentId].orderAsc;
|
||||
}
|
||||
|
||||
if(this.props.parentId in this.state.editionOpenList) {
|
||||
show = this.state.editionOpenList[this.props.parentId].show;
|
||||
}
|
||||
|
||||
let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id');
|
||||
|
||||
let columnList = [
|
||||
@ -149,15 +153,14 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
parentId={this.props.parentId}
|
||||
itemList={this.state.editionList[this.props.parentId]}
|
||||
columnList={columnList}
|
||||
numOfTableItems={this.props.numOfEditions}
|
||||
show={this.props.show}
|
||||
show={show}
|
||||
orderBy={orderBy}
|
||||
orderAsc={orderAsc}
|
||||
changeOrder={this.changeEditionListOrder}>
|
||||
<AccordionListItemTableToggle
|
||||
className="ascribe-accordion-list-table-toggle"
|
||||
onClick={this.toggleTable}
|
||||
show={this.props.show} />
|
||||
show={show} />
|
||||
</AccordionListItemTable>
|
||||
|
||||
</div>
|
||||
|
@ -77,8 +77,7 @@ let PieceList = React.createClass({
|
||||
key={i}>
|
||||
<AccordionListItemTableEditions
|
||||
className="ascribe-accordion-list-item-table col-xs-12 col-sm-8 col-md-6 col-lg-6 col-sm-offset-2 col-md-offset-3 col-lg-offset-3"
|
||||
parentId={item.id}
|
||||
show={item.show} />
|
||||
parentId={item.id} />
|
||||
</AccordionListItem>
|
||||
);
|
||||
})}
|
||||
|
@ -8,6 +8,7 @@ import EditionsListActions from '../actions/edition_list_actions';
|
||||
class EditionListStore {
|
||||
constructor() {
|
||||
this.editionList = {};
|
||||
this.editionOpenList = {};
|
||||
this.bindActions(EditionsListActions);
|
||||
}
|
||||
|
||||
@ -24,6 +25,11 @@ class EditionListStore {
|
||||
|
||||
this.editionList[pieceId] = editionListOfPiece;
|
||||
|
||||
// ToDo: Do merging later
|
||||
this.editionOpenList[pieceId] = {
|
||||
show: this.editionOpenList[pieceId] ? !this.editionOpenList[pieceId].show : true
|
||||
};
|
||||
|
||||
/**
|
||||
* orderBy and orderAsc are specific to a single list of editons
|
||||
* therefore they need to be saved in relation to their parent-piece.
|
||||
|
@ -28,7 +28,7 @@ class PieceListStore {
|
||||
this.bindActions(PieceListActions);
|
||||
}
|
||||
|
||||
onShowEditionList(pieceId) {
|
||||
/*onShowEditionList(pieceId) {
|
||||
this.pieceList
|
||||
.forEach((piece) => {
|
||||
if(piece.id === pieceId) {
|
||||
@ -39,14 +39,14 @@ class PieceListStore {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}*/
|
||||
|
||||
onCloseAllEditionLists() {
|
||||
/*onCloseAllEditionLists() {
|
||||
this.pieceList
|
||||
.forEach((piece) => {
|
||||
piece.show = false;
|
||||
});
|
||||
}
|
||||
}*/
|
||||
|
||||
onUpdatePieceList({ page, pageSize, search, pieceList, orderBy, orderAsc, pieceListCount }) {
|
||||
this.page = page;
|
||||
|
Loading…
Reference in New Issue
Block a user