mirror of
https://github.com/ascribe/onion.git
synced 2025-01-18 16:57:00 +01:00
fix merging on ACL action
This commit is contained in:
parent
e10b56cfc7
commit
f12a57c3cf
@ -71,7 +71,11 @@ let PieceListBulkModal = React.createClass({
|
||||
handleSuccess() {
|
||||
this.fetchSelectedPieceEditionList()
|
||||
.forEach((pieceId) => {
|
||||
EditionListActions.fetchEditionList(pieceId, this.state.orderBy, this.state.orderAsc);
|
||||
let editionsForPiece = this.state.editionList[pieceId];
|
||||
for(let i = 1; i <= editionsForPiece.page; i++) {
|
||||
EditionListActions.fetchEditionList(pieceId, i, editionsForPiece.pageSize, editionsForPiece.orderBy, editionsForPiece.orderAsc);
|
||||
}
|
||||
|
||||
});
|
||||
EditionListActions.clearAllEditionSelections();
|
||||
},
|
||||
|
@ -13,27 +13,28 @@ class EditionListStore {
|
||||
}
|
||||
|
||||
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc}) {
|
||||
if(this.editionList[pieceId]) {
|
||||
|
||||
let pageOfCurrentEditionList = this.editionList[pieceId].slice((page - 1) * pageSize, pageSize);
|
||||
|
||||
if(pageOfCurrentEditionList.length < 1) {
|
||||
// just append newly received editions
|
||||
console.log('asdasd');
|
||||
this.editionList[pieceId].push.apply(this.editionList[pieceId], editionListOfPiece);
|
||||
} else {
|
||||
// merge with existing page's editions
|
||||
pageOfCurrentEditionList.forEach((edition, i) => {
|
||||
for(let i = 0; i < editionListOfPiece.length; i++) {
|
||||
|
||||
if(editionListOfPiece[i]) {
|
||||
edition = React.addons.update(edition, {$merge: editionListOfPiece[i]});
|
||||
// if editionList for a specific piece does not exist yet,
|
||||
// just initialize a new array
|
||||
if(!this.editionList[pieceId]) {
|
||||
this.editionList[pieceId] = [];
|
||||
}
|
||||
|
||||
this.editionList[pieceId].splice((page - 1) * pageSize + i, 0, edition);
|
||||
});
|
||||
}
|
||||
// this is the index formula for accessing an edition of a specific
|
||||
// page
|
||||
let storeEditionIndex = (page - 1) * pageSize + i;
|
||||
let editionsForPieces = this.editionList[pieceId];
|
||||
|
||||
// if edition already exists, just merge
|
||||
if(editionsForPieces[storeEditionIndex]) {
|
||||
editionsForPieces[storeEditionIndex] = React.addons.update(editionsForPieces[storeEditionIndex], {$merge: editionListOfPiece[i]});
|
||||
} else {
|
||||
this.editionList[pieceId] = editionListOfPiece;
|
||||
// if does not exist, assign
|
||||
editionsForPieces[storeEditionIndex] = editionListOfPiece[i];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user