From 5fcee39ed3195243b18b411f71680669976d526a Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 25 Aug 2015 15:19:10 +0200 Subject: [PATCH] shortlisting enabled up till loan request --- js/components/ascribe_detail/edition.js | 8 +- .../prize/actions/prize_rating_actions.js | 14 +++ .../accordion_list_item_prize.js | 54 ++++++--- .../ascribe_detail/prize_piece_container.js | 109 ++++++++++++------ .../prize/constants/prize_api_urls.js | 1 + .../prize/fetchers/prize_rating_fetcher.js | 4 + .../ascribe_detail/cyland_piece_container.js | 7 +- sass/ascribe_settings.scss | 15 ++- 8 files changed, 147 insertions(+), 65 deletions(-) diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 9d2af633..4f4d424c 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -101,10 +101,6 @@ let Edition = React.createClass({ this.transitionTo('pieces'); }, - getId() { - return {'bitcoin_id': this.props.edition.bitcoin_id}; - }, - render() { return ( @@ -159,7 +155,7 @@ let Edition = React.createClass({ show={(this.state.currentUser.username && true || false) || (this.props.edition.acl.acl_edit || this.props.edition.public_note)}> {return {'bitcoin_id': this.props.edition.bitcoin_id}; }} label={getLangText('Personal note (private)')} defaultValue={this.props.edition.private_note ? this.props.edition.private_note : null} placeholder={getLangText('Enter your comments ...')} @@ -168,7 +164,7 @@ let Edition = React.createClass({ url={ApiUrls.note_private_edition} currentUser={this.state.currentUser}/> {return {'bitcoin_id': this.props.edition.bitcoin_id}; }} label={getLangText('Edition note (public)')} defaultValue={this.props.edition.public_note ? this.props.edition.public_note : null} placeholder={getLangText('Enter your comments ...')} diff --git a/js/components/whitelabel/prize/actions/prize_rating_actions.js b/js/components/whitelabel/prize/actions/prize_rating_actions.js index 73569875..40e24858 100644 --- a/js/components/whitelabel/prize/actions/prize_rating_actions.js +++ b/js/components/whitelabel/prize/actions/prize_rating_actions.js @@ -57,6 +57,20 @@ class PrizeRatingActions { }); } + toggleShortlist(pieceId) { + return Q.Promise((resolve, reject) => { + PrizeRatingFetcher + .select(pieceId) + .then((res) => { + this.actions.updatePrizeRating(res.rating.rating); + resolve(res); + }) + .catch((err) => { + reject(err); + }); + }); + } + updateRating(rating) { this.actions.updatePrizeRating(rating); } diff --git a/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js b/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js index 9270efe1..0ca54d93 100644 --- a/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js +++ b/js/components/whitelabel/prize/components/ascribe_accordion_list/accordion_list_item_prize.js @@ -4,13 +4,17 @@ import React from 'react'; import Router from 'react-router'; import StarRating from 'react-star-rating'; -import AccordionListItemPiece from '../../../../ascribe_accordion_list/accordion_list_item_piece'; - import PieceListActions from '../../../../../actions/piece_list_actions'; import PieceListStore from '../../../../../stores/piece_list_store'; +import PrizeRatingActions from '../../actions/prize_rating_actions'; + import UserStore from '../../../../../stores/user_store'; +import InputCheckbox from '../../../../ascribe_forms/input_checkbox'; + +import AccordionListItemPiece from '../../../../ascribe_accordion_list/accordion_list_item_piece'; + import GlobalNotificationModel from '../../../../../models/global_notification_model'; import GlobalNotificationActions from '../../../../../actions/global_notification_actions'; @@ -76,7 +80,7 @@ let AccordionListItemPrize = React.createClass({ } else if (this.props.content.ratings.average){ rating = this.props.content.ratings.average; - caption = 'Average (' + this.props.content.ratings.ratings.length + ' ratings)'; + caption = 'Average of ' + this.props.content.ratings.ratings.length + ' rating(s)'; } return ( @@ -97,7 +101,7 @@ let AccordionListItemPrize = React.createClass({ if (this.state.currentUser.is_judge){ return (
- No votes yet + Not rated
); } @@ -126,22 +130,42 @@ let AccordionListItemPrize = React.createClass({ ); }, + getPrizeBadge(){ + if (this.state.currentUser && this.state.currentUser.is_judge) { + return ( + + { + PrizeRatingActions.toggleShortlist(this.props.content.id).then( + PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, + this.state.orderBy, this.state.orderAsc, this.state.filterBy) + ); }}/> + + ); + } + return null; + }, + render() { let artistName = this.state.currentUser.is_jury ?