mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
remove first edition routine
This commit is contained in:
parent
11545c13a6
commit
fd094aa471
@ -9,7 +9,6 @@ class PieceListActions {
|
|||||||
this.generateActions(
|
this.generateActions(
|
||||||
'updatePieceList',
|
'updatePieceList',
|
||||||
'updatePieceListRequestActions',
|
'updatePieceListRequestActions',
|
||||||
'addFirstEditionToPiece',
|
|
||||||
'updatePropertyForPiece'
|
'updatePropertyForPiece'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -41,17 +40,6 @@ class PieceListActions {
|
|||||||
this.actions.updatePieceListRequestActions(res.piece_ids);
|
this.actions.updatePieceListRequestActions(res.piece_ids);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchFirstEditionForPiece(pieceId) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
PieceListFetcher.fetchFirstEditionForPiece(pieceId)
|
|
||||||
.then((firstEdition) => {
|
|
||||||
this.actions.addFirstEditionToPiece({pieceId, firstEdition});
|
|
||||||
resolve();
|
|
||||||
})
|
|
||||||
.catch((err) => reject(err));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default alt.createActions(PieceListActions);
|
export default alt.createActions(PieceListActions);
|
||||||
|
@ -31,17 +31,10 @@ let AccordionListItem = React.createClass({
|
|||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
showCreateEditionsDialog: false,
|
showCreateEditionsDialog: false
|
||||||
creatingEditions: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
if(this.props.content.num_editions > 0) {
|
|
||||||
PieceListActions.fetchFirstEditionForPiece(this.props.content.id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
if(this.props.content.num_editions === 0 && typeof this.state.pollingIntervalIndex == 'undefined') {
|
if(this.props.content.num_editions === 0 && typeof this.state.pollingIntervalIndex == 'undefined') {
|
||||||
this.startPolling();
|
this.startPolling();
|
||||||
@ -78,10 +71,6 @@ let AccordionListItem = React.createClass({
|
|||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
PieceListActions.updatePropertyForPiece({pieceId: this.props.content.id, key: 'num_editions', value: 0});
|
PieceListActions.updatePropertyForPiece({pieceId: this.props.content.id, key: 'num_editions', value: 0});
|
||||||
|
|
||||||
this.setState({
|
|
||||||
creatingEditions: true
|
|
||||||
});
|
|
||||||
|
|
||||||
this.toggleCreateEditionsDialog();
|
this.toggleCreateEditionsDialog();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -92,10 +81,6 @@ let AccordionListItem = React.createClass({
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
||||||
clearInterval(this.state.pollingIntervalIndex);
|
clearInterval(this.state.pollingIntervalIndex);
|
||||||
|
|
||||||
this.setState({
|
|
||||||
creatingEditions: false
|
|
||||||
});
|
|
||||||
|
|
||||||
PieceListActions.updatePropertyForPiece({
|
PieceListActions.updatePropertyForPiece({
|
||||||
pieceId: this.props.content.id,
|
pieceId: this.props.content.id,
|
||||||
@ -156,8 +141,7 @@ let AccordionListItem = React.createClass({
|
|||||||
<AccordionListItemEditionWidget
|
<AccordionListItemEditionWidget
|
||||||
className="pull-right"
|
className="pull-right"
|
||||||
piece={this.props.content}
|
piece={this.props.content}
|
||||||
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}
|
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}/>
|
||||||
creatingEditions={this.state.creatingEditions}/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span style={{'clear': 'both'}}></span>
|
<span style={{'clear': 'both'}}></span>
|
||||||
|
@ -12,8 +12,7 @@ let AccordionListItemEditionWidget = React.createClass({
|
|||||||
propTypes: {
|
propTypes: {
|
||||||
className: React.PropTypes.string,
|
className: React.PropTypes.string,
|
||||||
piece: React.PropTypes.object.isRequired,
|
piece: React.PropTypes.object.isRequired,
|
||||||
toggleCreateEditionsDialog: React.PropTypes.func.isRequired,
|
toggleCreateEditionsDialog: React.PropTypes.func.isRequired
|
||||||
creatingEditions: React.PropTypes.bool.isRequired
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
|
@ -72,19 +72,6 @@ class PieceListStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onAddFirstEditionToPiece({pieceId, firstEdition}) {
|
|
||||||
let filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
|
|
||||||
|
|
||||||
if(filteredPieceList.length === 1) {
|
|
||||||
|
|
||||||
let piece = filteredPieceList[0];
|
|
||||||
piece.firstEdition = firstEdition.edition;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new Error('Could not find a matching piece in piece list since its either not there or piecelist contains duplicates.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onUpdatePropertyForPiece({pieceId, key, value}) {
|
onUpdatePropertyForPiece({pieceId, key, value}) {
|
||||||
let filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
|
let filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user