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