mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Revert "Merge with AD-1443"
Revert https://github.com/ascribe/onion/pull/40, as that needs more work.
This commit is contained in:
parent
dafdf97678
commit
e69dfeb355
@ -189,14 +189,13 @@ let PieceList = React.createClass({
|
|||||||
this.state.pieceList
|
this.state.pieceList
|
||||||
.forEach((piece) => {
|
.forEach((piece) => {
|
||||||
// but only if they're actually open
|
// but only if they're actually open
|
||||||
const isEditionListOpenForPiece = this.state.isEditionListOpenForPieceId[piece.id];
|
if(this.state.isEditionListOpenForPieceId[piece.id].show) {
|
||||||
|
|
||||||
if (isEditionListOpenForPiece && isEditionListOpenForPiece.show) {
|
|
||||||
EditionListActions.refreshEditionList({
|
EditionListActions.refreshEditionList({
|
||||||
pieceId: piece.id,
|
pieceId: piece.id,
|
||||||
filterBy
|
filterBy
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,29 +60,46 @@ class EditionListStore {
|
|||||||
* We often just have to refresh the edition list for a certain pieceId,
|
* We often just have to refresh the edition list for a certain pieceId,
|
||||||
* this method provides exactly that functionality without any side effects
|
* this method provides exactly that functionality without any side effects
|
||||||
*/
|
*/
|
||||||
onRefreshEditionList({pieceId, filterBy = this.editionList[pieceId].filterBy}) {
|
onRefreshEditionList({pieceId, filterBy = {}}) {
|
||||||
const pieceEditionList = this.editionList[pieceId];
|
|
||||||
|
|
||||||
// It may happen that the user enters the site logged in already
|
// It may happen that the user enters the site logged in already
|
||||||
// through /editions
|
// through /editions
|
||||||
// If he then tries to delete a piece/edition and this method is called,
|
// If he then tries to delete a piece/edition and this method is called,
|
||||||
// we'll not be able to refresh his edition list since its not yet there.
|
// we'll not be able to refresh his edition list since its not yet there.
|
||||||
// Therefore we can just return, since there is no data to be refreshed
|
// Therefore we can just return, since there is no data to be refreshed
|
||||||
if (!pieceEditionList) {
|
if(!this.editionList[pieceId]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let prevEditionListLength = this.editionList[pieceId].length;
|
||||||
|
let prevEditionListPage = this.editionList[pieceId].page;
|
||||||
|
let prevEditionListPageSize = this.editionList[pieceId].pageSize;
|
||||||
|
|
||||||
|
// we can also refresh the edition list using filterBy,
|
||||||
|
// if we decide not to do that then the old filter will just be applied.
|
||||||
|
if(filterBy && Object.keys(filterBy).length <= 0) {
|
||||||
|
filterBy = this.editionList[pieceId].filterBy;
|
||||||
|
prevEditionListLength = 10;
|
||||||
|
prevEditionListPage = 1;
|
||||||
|
prevEditionListPageSize = 10;
|
||||||
|
}
|
||||||
|
|
||||||
// to clear an array, david walsh recommends to just set it's length to zero
|
// to clear an array, david walsh recommends to just set it's length to zero
|
||||||
// http://davidwalsh.name/empty-array
|
// http://davidwalsh.name/empty-array
|
||||||
pieceEditionList.length = 0;
|
this.editionList[pieceId].length = 0;
|
||||||
|
|
||||||
// refetch editions from the beginning with the previous settings
|
// refetch editions with adjusted page size
|
||||||
EditionsListActions
|
EditionsListActions.fetchEditionList(pieceId, 1, prevEditionListLength,
|
||||||
.fetchEditionList(pieceId, 1, pieceEditionList.pageSize,
|
this.editionList[pieceId].orderBy,
|
||||||
pieceEditionList.orderBy,
|
this.editionList[pieceId].orderAsc,
|
||||||
pieceEditionList.orderAsc,
|
|
||||||
filterBy)
|
filterBy)
|
||||||
.catch(console.logGlobal);
|
.then(() => {
|
||||||
|
// reset back to the normal pageSize and page
|
||||||
|
this.editionList[pieceId].page = prevEditionListPage;
|
||||||
|
this.editionList[pieceId].pageSize = prevEditionListPageSize;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.logGlobal(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectEdition({pieceId, editionId, toValue}) {
|
onSelectEdition({pieceId, editionId, toValue}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user