mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +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() {
|
handleSuccess() {
|
||||||
this.fetchSelectedPieceEditionList()
|
this.fetchSelectedPieceEditionList()
|
||||||
.forEach((pieceId) => {
|
.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();
|
EditionListActions.clearAllEditionSelections();
|
||||||
},
|
},
|
||||||
|
@ -13,27 +13,28 @@ class EditionListStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc}) {
|
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc}) {
|
||||||
if(this.editionList[pieceId]) {
|
|
||||||
|
|
||||||
let pageOfCurrentEditionList = this.editionList[pieceId].slice((page - 1) * pageSize, pageSize);
|
for(let i = 0; i < editionListOfPiece.length; i++) {
|
||||||
|
|
||||||
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) => {
|
|
||||||
|
|
||||||
if(editionListOfPiece[i]) {
|
// if editionList for a specific piece does not exist yet,
|
||||||
edition = React.addons.update(edition, {$merge: editionListOfPiece[i]});
|
// 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 {
|
||||||
|
// if does not exist, assign
|
||||||
|
editionsForPieces[storeEditionIndex] = editionListOfPiece[i];
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.editionList[pieceId] = editionListOfPiece;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user