mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
remove first edition routine
This commit is contained in:
parent
11545c13a6
commit
fd094aa471
@ -9,7 +9,6 @@ class PieceListActions {
|
||||
this.generateActions(
|
||||
'updatePieceList',
|
||||
'updatePieceListRequestActions',
|
||||
'addFirstEditionToPiece',
|
||||
'updatePropertyForPiece'
|
||||
);
|
||||
}
|
||||
@ -41,17 +40,6 @@ class PieceListActions {
|
||||
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);
|
||||
|
@ -31,17 +31,10 @@ let AccordionListItem = React.createClass({
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
showCreateEditionsDialog: false,
|
||||
creatingEditions: false
|
||||
showCreateEditionsDialog: false
|
||||
};
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
if(this.props.content.num_editions > 0) {
|
||||
PieceListActions.fetchFirstEditionForPiece(this.props.content.id);
|
||||
}
|
||||
},
|
||||
|
||||
componentDidUpdate() {
|
||||
if(this.props.content.num_editions === 0 && typeof this.state.pollingIntervalIndex == 'undefined') {
|
||||
this.startPolling();
|
||||
@ -78,10 +71,6 @@ let AccordionListItem = React.createClass({
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
PieceListActions.updatePropertyForPiece({pieceId: this.props.content.id, key: 'num_editions', value: 0});
|
||||
|
||||
this.setState({
|
||||
creatingEditions: true
|
||||
});
|
||||
|
||||
this.toggleCreateEditionsDialog();
|
||||
},
|
||||
|
||||
@ -92,10 +81,6 @@ let AccordionListItem = React.createClass({
|
||||
.then((res) => {
|
||||
|
||||
clearInterval(this.state.pollingIntervalIndex);
|
||||
|
||||
this.setState({
|
||||
creatingEditions: false
|
||||
});
|
||||
|
||||
PieceListActions.updatePropertyForPiece({
|
||||
pieceId: this.props.content.id,
|
||||
@ -156,8 +141,7 @@ let AccordionListItem = React.createClass({
|
||||
<AccordionListItemEditionWidget
|
||||
className="pull-right"
|
||||
piece={this.props.content}
|
||||
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}
|
||||
creatingEditions={this.state.creatingEditions}/>
|
||||
toggleCreateEditionsDialog={this.toggleCreateEditionsDialog}/>
|
||||
</div>
|
||||
</div>
|
||||
<span style={{'clear': 'both'}}></span>
|
||||
|
@ -12,8 +12,7 @@ let AccordionListItemEditionWidget = React.createClass({
|
||||
propTypes: {
|
||||
className: React.PropTypes.string,
|
||||
piece: React.PropTypes.object.isRequired,
|
||||
toggleCreateEditionsDialog: React.PropTypes.func.isRequired,
|
||||
creatingEditions: React.PropTypes.bool.isRequired
|
||||
toggleCreateEditionsDialog: React.PropTypes.func.isRequired
|
||||
},
|
||||
|
||||
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}) {
|
||||
let filteredPieceList = this.pieceList.filter((piece) => piece.id === pieceId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user