1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 00:28:00 +02:00

bug fix promises and notifications

This commit is contained in:
diminator 2015-08-26 14:50:16 +02:00
parent e3b85bf808
commit bcd6400a78
2 changed files with 18 additions and 4 deletions

View File

@ -62,7 +62,7 @@ class PrizeRatingActions {
PrizeRatingFetcher
.select(pieceId)
.then((res) => {
this.actions.updatePrizeRating(res.rating.rating);
this.actions.updatePrizeRatings(res.data.ratings);
resolve(res);
})
.catch((err) => {

View File

@ -264,9 +264,15 @@ let PrizePieceRatings = React.createClass({
},
handleLoanRequestSuccess(){},
handleShortlistSuccess(message){
let notification = new GlobalNotificationModel(message, 'success', 2000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
refreshPieceData() {
this.props.loadPiece();
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
},
render(){
@ -282,9 +288,17 @@ let PrizePieceRatings = React.createClass({
<InputCheckbox
defaultChecked={this.props.piece.selected}
onChange={() => {
PrizeRatingActions.toggleShortlist(this.props.piece.id).then(
this.refreshPieceData()
); }}>
PrizeRatingActions.toggleShortlist(this.props.piece.id)
.then(
(res) => {
this.refreshPieceData();
return res;
})
.then(
(res) => {
this.handleShortlistSuccess(res.notification);
}
); }}>
<span>
Select for the prize
</span>