fix separation of orderings in edtionLists

This commit is contained in:
Tim Daubenschütz 2015-06-04 16:41:14 +02:00
parent eaefd253d5
commit 6aa74d6b42
3 changed files with 21 additions and 7 deletions

View File

@ -12,6 +12,11 @@ class EditionListActions {
}
fetchEditionList(pieceId, orderBy, orderAsc) {
if(!orderBy && typeof orderAsc == "undefined") {
orderBy = 'edition_number';
orderAsc = true;
}
EditionListFetcher
.fetch(pieceId, orderBy, orderAsc)
.then((res) => {

View File

@ -65,7 +65,7 @@ let AccordionListItemTableEditions = React.createClass({
toggleTable() {
PieceListActions.showEditionList(this.props.parentId);
EditionListActions.fetchEditionList(this.props.parentId, this.state.orderBy, this.state.orderAsc);
EditionListActions.fetchEditionList(this.props.parentId);
},
changeEditionListOrder(orderBy, orderAsc) {
@ -75,6 +75,8 @@ let AccordionListItemTableEditions = React.createClass({
render() {
let selectedEditionsCount = 0;
let allEditionsCount = 0;
let orderBy;
let orderAsc;
// 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
@ -82,6 +84,8 @@ let AccordionListItemTableEditions = React.createClass({
if(this.state.editionList[this.props.parentId]) {
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;
}
let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id', PieceListActions.closeAllEditionLists);
@ -151,8 +155,8 @@ let AccordionListItemTableEditions = React.createClass({
columnList={columnList}
numOfTableItems={this.props.numOfEditions}
show={this.props.show}
orderBy={this.state.orderBy}
orderAsc={this.state.orderAsc}
orderBy={orderBy}
orderAsc={orderAsc}
changeOrder={this.changeEditionListOrder}>
<AccordionListItemTableToggle
className="ascribe-accordion-list-table-toggle"

View File

@ -6,8 +6,6 @@ import EditionsListActions from '../actions/edition_list_actions';
class EditionListStore {
constructor() {
this.editionList = {};
this.orderBy = 'edition_number';
this.orderAsc = true;
this.bindActions(EditionsListActions);
}
@ -20,8 +18,15 @@ class EditionListStore {
})
}
this.editionList[pieceId] = editionListOfPiece;
this.orderBy = orderBy;
this.orderAsc = orderAsc;
/**
* orderBy and orderAsc are specific to a single list of editons
* therefore they need to be saved in relation to their parent-piece.
*
* Default values for both are set in the editon_list-actions.
*/
this.editionList[pieceId].orderBy = orderBy;
this.editionList[pieceId].orderAsc = orderAsc
}
onSelectEdition({pieceId, editionId}) {