1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-14 21:10:27 +01:00

Small style changes for Piece and Edition ListStores

This commit is contained in:
Brett Sun 2016-01-13 17:14:09 +01:00
parent 466872affb
commit ea18b31db1
2 changed files with 14 additions and 15 deletions

View File

@ -12,7 +12,7 @@ class EditionListStore {
this.bindActions(EditionsListActions);
}
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc, count, filterBy}) {
onUpdateEditionList({ pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc, count, filterBy }) {
/*
Basically there are two modes an edition list can be updated.
@ -20,7 +20,7 @@ class EditionListStore {
2. The elements are already defined => merge current objects with the new ones from the server
*/
for(let i = 0; i < editionListOfPiece.length; i++) {
for (let i = 0; i < editionListOfPiece.length; i++) {
// if editionList for a specific piece does not exist yet,
// just initialize a new array
@ -60,7 +60,7 @@ class EditionListStore {
* We often just have to refresh the edition list for a certain pieceId,
* this method provides exactly that functionality without any side effects
*/
onRefreshEditionList({pieceId, filterBy = {}}) {
onRefreshEditionList({ pieceId, filterBy = {} }) {
// It may happen that the user enters the site logged in already
// through /editions
// If he then tries to delete a piece/edition and this method is called,
@ -102,7 +102,7 @@ class EditionListStore {
});
}
onSelectEdition({pieceId, editionId, toValue}) {
onSelectEdition({ pieceId, editionId, toValue }) {
this.editionList[pieceId].forEach((edition) => {
// Taken from: http://stackoverflow.com/a/519157/1263876

View File

@ -60,8 +60,8 @@ class PieceListStore {
* point anyway. Then, this problem is automatically resolved.
*/
pieceList.forEach((piece, i) => {
let oldPiece = this.pieceList[i];
if(oldPiece) {
const oldPiece = this.pieceList[i];
if (oldPiece) {
piece = React.addons.update(piece, {
show: { $set: oldPiece.show }
});
@ -76,12 +76,11 @@ class PieceListStore {
this.requestActions = res.actions;
}
onUpdatePropertyForPiece({pieceId, key, value}) {
let filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
onUpdatePropertyForPiece({ pieceId, key, value }) {
const filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
if(filteredPieceList.length === 1) {
let piece = filteredPieceList[0];
if (filteredPieceList.length === 1) {
const piece = filteredPieceList[0];
piece[key] = value;
} else {
throw new Error('Could not find a matching piece in piece list since its either not there or piecelist contains duplicates.');