mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
fix separation of orderings in edtionLists
This commit is contained in:
parent
eaefd253d5
commit
6aa74d6b42
@ -12,6 +12,11 @@ class EditionListActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchEditionList(pieceId, orderBy, orderAsc) {
|
fetchEditionList(pieceId, orderBy, orderAsc) {
|
||||||
|
if(!orderBy && typeof orderAsc == "undefined") {
|
||||||
|
orderBy = 'edition_number';
|
||||||
|
orderAsc = true;
|
||||||
|
}
|
||||||
|
|
||||||
EditionListFetcher
|
EditionListFetcher
|
||||||
.fetch(pieceId, orderBy, orderAsc)
|
.fetch(pieceId, orderBy, orderAsc)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
@ -65,7 +65,7 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
|
|
||||||
toggleTable() {
|
toggleTable() {
|
||||||
PieceListActions.showEditionList(this.props.parentId);
|
PieceListActions.showEditionList(this.props.parentId);
|
||||||
EditionListActions.fetchEditionList(this.props.parentId, this.state.orderBy, this.state.orderAsc);
|
EditionListActions.fetchEditionList(this.props.parentId);
|
||||||
},
|
},
|
||||||
|
|
||||||
changeEditionListOrder(orderBy, orderAsc) {
|
changeEditionListOrder(orderBy, orderAsc) {
|
||||||
@ -75,6 +75,8 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
render() {
|
render() {
|
||||||
let selectedEditionsCount = 0;
|
let selectedEditionsCount = 0;
|
||||||
let allEditionsCount = 0;
|
let allEditionsCount = 0;
|
||||||
|
let orderBy;
|
||||||
|
let orderAsc;
|
||||||
|
|
||||||
// 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
|
||||||
@ -82,6 +84,8 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
if(this.state.editionList[this.props.parentId]) {
|
if(this.state.editionList[this.props.parentId]) {
|
||||||
selectedEditionsCount = this.filterSelectedEditions().length;
|
selectedEditionsCount = this.filterSelectedEditions().length;
|
||||||
allEditionsCount = this.state.editionList[this.props.parentId].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);
|
let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id', PieceListActions.closeAllEditionLists);
|
||||||
@ -151,8 +155,8 @@ let AccordionListItemTableEditions = React.createClass({
|
|||||||
columnList={columnList}
|
columnList={columnList}
|
||||||
numOfTableItems={this.props.numOfEditions}
|
numOfTableItems={this.props.numOfEditions}
|
||||||
show={this.props.show}
|
show={this.props.show}
|
||||||
orderBy={this.state.orderBy}
|
orderBy={orderBy}
|
||||||
orderAsc={this.state.orderAsc}
|
orderAsc={orderAsc}
|
||||||
changeOrder={this.changeEditionListOrder}>
|
changeOrder={this.changeEditionListOrder}>
|
||||||
<AccordionListItemTableToggle
|
<AccordionListItemTableToggle
|
||||||
className="ascribe-accordion-list-table-toggle"
|
className="ascribe-accordion-list-table-toggle"
|
||||||
|
@ -6,8 +6,6 @@ import EditionsListActions from '../actions/edition_list_actions';
|
|||||||
class EditionListStore {
|
class EditionListStore {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.editionList = {};
|
this.editionList = {};
|
||||||
this.orderBy = 'edition_number';
|
|
||||||
this.orderAsc = true;
|
|
||||||
this.bindActions(EditionsListActions);
|
this.bindActions(EditionsListActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,8 +18,15 @@ class EditionListStore {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.editionList[pieceId] = editionListOfPiece;
|
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}) {
|
onSelectEdition({pieceId, editionId}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user