mirror of
https://github.com/ascribe/onion.git
synced 2024-06-30 13:41:57 +02:00
notes and bug fixes
This commit is contained in:
parent
22727c2703
commit
c25de71b4b
|
@ -13,6 +13,8 @@ import PieceListActions from '../../../../../actions/piece_list_actions';
|
||||||
import PrizeRatingActions from '../../actions/prize_rating_actions';
|
import PrizeRatingActions from '../../actions/prize_rating_actions';
|
||||||
import PrizeRatingStore from '../../stores/prize_rating_store';
|
import PrizeRatingStore from '../../stores/prize_rating_store';
|
||||||
|
|
||||||
|
import UserStore from '../../../../../stores/user_store';
|
||||||
|
|
||||||
import Piece from '../../../../../components/ascribe_detail/piece';
|
import Piece from '../../../../../components/ascribe_detail/piece';
|
||||||
|
|
||||||
import AppConstants from '../../../../../constants/application_constants';
|
import AppConstants from '../../../../../constants/application_constants';
|
||||||
|
@ -22,8 +24,12 @@ import Property from '../../../../../components/ascribe_forms/property';
|
||||||
import InputTextAreaToggable from '../../../../../components/ascribe_forms/input_textarea_toggable';
|
import InputTextAreaToggable from '../../../../../components/ascribe_forms/input_textarea_toggable';
|
||||||
import CollapsibleParagraph from '../../../../../components/ascribe_collapsible/collapsible_paragraph';
|
import CollapsibleParagraph from '../../../../../components/ascribe_collapsible/collapsible_paragraph';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../../../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../../../../actions/global_notification_actions';
|
||||||
|
|
||||||
import DetailProperty from '../../../../ascribe_detail/detail_property';
|
import DetailProperty from '../../../../ascribe_detail/detail_property';
|
||||||
|
|
||||||
|
import ApiUrls from '../../../../../constants/api_urls';
|
||||||
import { mergeOptions } from '../../../../../utils/general_utils';
|
import { mergeOptions } from '../../../../../utils/general_utils';
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +70,7 @@ let PieceContainer = React.createClass({
|
||||||
loadPiece={this.loadPiece}
|
loadPiece={this.loadPiece}
|
||||||
header={
|
header={
|
||||||
<div className="ascribe-detail-header">
|
<div className="ascribe-detail-header">
|
||||||
|
<NavigationHeader/>
|
||||||
<h1 className="ascribe-detail-title">{this.state.piece.title}</h1>
|
<h1 className="ascribe-detail-title">{this.state.piece.title}</h1>
|
||||||
<hr/>
|
<hr/>
|
||||||
<DetailProperty label="BY" value={this.state.piece.artist_name} />
|
<DetailProperty label="BY" value={this.state.piece.artist_name} />
|
||||||
|
@ -87,6 +94,21 @@ let PieceContainer = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let NavigationHeader = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
piece: React.PropTypes.object
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
navigation
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
let PrizePieceRatings = React.createClass({
|
let PrizePieceRatings = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
piece: React.PropTypes.object
|
piece: React.PropTypes.object
|
||||||
|
@ -95,7 +117,8 @@ let PrizePieceRatings = React.createClass({
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return mergeOptions(
|
||||||
PieceListStore.getState(),
|
PieceListStore.getState(),
|
||||||
PrizeRatingStore.getState()
|
PrizeRatingStore.getState(),
|
||||||
|
UserStore.getState()
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -103,6 +126,7 @@ let PrizePieceRatings = React.createClass({
|
||||||
PrizeRatingStore.listen(this.onChange);
|
PrizeRatingStore.listen(this.onChange);
|
||||||
PrizeRatingActions.fetchOne(this.props.piece.id);
|
PrizeRatingActions.fetchOne(this.props.piece.id);
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
|
UserStore.listen(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -113,6 +137,7 @@ let PrizePieceRatings = React.createClass({
|
||||||
PrizeRatingActions.updateRating({});
|
PrizeRatingActions.updateRating({});
|
||||||
PrizeRatingStore.unlisten(this.onChange);
|
PrizeRatingStore.unlisten(this.onChange);
|
||||||
PieceListStore.unlisten(this.onChange);
|
PieceListStore.unlisten(this.onChange);
|
||||||
|
UserStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
|
@ -135,26 +160,72 @@ let PrizePieceRatings = React.createClass({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
render(){
|
render(){
|
||||||
return (
|
if (this.state.currentUser && this.state.currentUser.is_jury) {
|
||||||
<DetailProperty
|
return (
|
||||||
labelClassName='col-xs-3 col-sm-3 col-md-2 col-lg-2 col-xs-height col-middle ascribe-detail-property-label'
|
<div>
|
||||||
label={
|
<DetailProperty
|
||||||
<span>YOUR VOTE</span>
|
labelClassName='col-xs-3 col-sm-3 col-md-2 col-lg-2 col-xs-height col-middle ascribe-detail-property-label'
|
||||||
}
|
label={
|
||||||
value={
|
<span>YOUR VOTE</span>
|
||||||
<StarRating
|
}
|
||||||
ref='rating'
|
value={
|
||||||
name="prize-rating"
|
<StarRating
|
||||||
caption=""
|
ref='rating'
|
||||||
step={1}
|
name="prize-rating"
|
||||||
size='md'
|
caption=""
|
||||||
rating={this.state.currentRating}
|
step={1}
|
||||||
onRatingClick={this.onRatingClick}
|
size='md'
|
||||||
ratingAmount={5} />}
|
rating={this.state.currentRating}
|
||||||
/>);
|
onRatingClick={this.onRatingClick}
|
||||||
|
ratingAmount={5} />
|
||||||
|
}/>
|
||||||
|
<PersonalNote
|
||||||
|
piece={this.props.piece}
|
||||||
|
currentUser={this.state.currentUser}/>
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let PersonalNote = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
piece: React.PropTypes.object,
|
||||||
|
currentUser: React.PropTypes.object
|
||||||
|
},
|
||||||
|
showNotification(){
|
||||||
|
let notification = new GlobalNotificationModel(getLangText('Jury note saved'), 'success');
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.props.currentUser.username && true || false) {
|
||||||
|
return (
|
||||||
|
<Form
|
||||||
|
url={ApiUrls.notes}
|
||||||
|
handleSuccess={this.showNotification}>
|
||||||
|
<Property
|
||||||
|
name='value'
|
||||||
|
label={getLangText('Note')}
|
||||||
|
editable={true}>
|
||||||
|
<InputTextAreaToggable
|
||||||
|
rows={1}
|
||||||
|
editable={true}
|
||||||
|
defaultValue={this.props.piece.note_from_user ? this.props.piece.note_from_user.note : null}
|
||||||
|
placeholder={getLangText('Enter a personal note%s', '...')}/>
|
||||||
|
</Property>
|
||||||
|
<Property hidden={true} name='piece_id'>
|
||||||
|
<input defaultValue={this.props.piece.id}/>
|
||||||
|
</Property>
|
||||||
|
<hr />
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
let PrizePieceDetails = React.createClass({
|
let PrizePieceDetails = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
piece: React.PropTypes.object
|
piece: React.PropTypes.object
|
||||||
|
|
|
@ -16,7 +16,10 @@ function getApiUrls(subdomain) {
|
||||||
'jury_activate': AppPrizeConstants.prizeApiEndpoint + subdomain + '/jury/${email}/activate/',
|
'jury_activate': AppPrizeConstants.prizeApiEndpoint + subdomain + '/jury/${email}/activate/',
|
||||||
'jury_resend': AppPrizeConstants.prizeApiEndpoint + subdomain + '/jury/${email}/resend/',
|
'jury_resend': AppPrizeConstants.prizeApiEndpoint + subdomain + '/jury/${email}/resend/',
|
||||||
'ratings': AppPrizeConstants.prizeApiEndpoint + subdomain + '/ratings/',
|
'ratings': AppPrizeConstants.prizeApiEndpoint + subdomain + '/ratings/',
|
||||||
'rating': AppPrizeConstants.prizeApiEndpoint + subdomain + '/ratings/${piece_id}/'
|
'rating': AppPrizeConstants.prizeApiEndpoint + subdomain + '/ratings/${piece_id}/',
|
||||||
|
'notes': AppPrizeConstants.prizeApiEndpoint + subdomain + '/notes/',
|
||||||
|
'note': AppPrizeConstants.prizeApiEndpoint + subdomain + '/notes/${piece_id}/'
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ let PrizeRatingFetcher = {
|
||||||
},
|
},
|
||||||
|
|
||||||
rate(pieceId, rating) {
|
rate(pieceId, rating) {
|
||||||
return requests.post('ratings', {body: {'piece_id': pieceId, 'rating': rating}});
|
return requests.post('ratings', {body: {'piece_id': pieceId, 'value': rating}});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user