mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Small style changes for Piece and Edition ListStores
This commit is contained in:
parent
466872affb
commit
ea18b31db1
@ -12,7 +12,7 @@ class EditionListStore {
|
|||||||
this.bindActions(EditionsListActions);
|
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.
|
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
|
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,
|
// if editionList for a specific piece does not exist yet,
|
||||||
// just initialize a new array
|
// just initialize a new array
|
||||||
@ -60,7 +60,7 @@ 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 = {}}) {
|
onRefreshEditionList({ pieceId, filterBy = {} }) {
|
||||||
// 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,
|
||||||
@ -102,7 +102,7 @@ class EditionListStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectEdition({pieceId, editionId, toValue}) {
|
onSelectEdition({ pieceId, editionId, toValue }) {
|
||||||
this.editionList[pieceId].forEach((edition) => {
|
this.editionList[pieceId].forEach((edition) => {
|
||||||
|
|
||||||
// Taken from: http://stackoverflow.com/a/519157/1263876
|
// Taken from: http://stackoverflow.com/a/519157/1263876
|
||||||
|
@ -60,8 +60,8 @@ class PieceListStore {
|
|||||||
* point anyway. Then, this problem is automatically resolved.
|
* point anyway. Then, this problem is automatically resolved.
|
||||||
*/
|
*/
|
||||||
pieceList.forEach((piece, i) => {
|
pieceList.forEach((piece, i) => {
|
||||||
let oldPiece = this.pieceList[i];
|
const oldPiece = this.pieceList[i];
|
||||||
if(oldPiece) {
|
if (oldPiece) {
|
||||||
piece = React.addons.update(piece, {
|
piece = React.addons.update(piece, {
|
||||||
show: { $set: oldPiece.show }
|
show: { $set: oldPiece.show }
|
||||||
});
|
});
|
||||||
@ -76,12 +76,11 @@ class PieceListStore {
|
|||||||
this.requestActions = res.actions;
|
this.requestActions = res.actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdatePropertyForPiece({pieceId, key, value}) {
|
onUpdatePropertyForPiece({ pieceId, key, value }) {
|
||||||
let filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
|
const filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
|
||||||
|
|
||||||
if(filteredPieceList.length === 1) {
|
if (filteredPieceList.length === 1) {
|
||||||
|
const piece = filteredPieceList[0];
|
||||||
let piece = filteredPieceList[0];
|
|
||||||
piece[key] = value;
|
piece[key] = value;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Could not find a matching piece in piece list since its either not there or piecelist contains duplicates.');
|
throw new Error('Could not find a matching piece in piece list since its either not there or piecelist contains duplicates.');
|
||||||
|
Loading…
Reference in New Issue
Block a user