mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
average rating
cyland bug fix
This commit is contained in:
parent
1b335e31a4
commit
15bcd4ba14
@ -65,17 +65,28 @@ let AccordionListItemPrize = React.createClass({
|
||||
|
||||
getPrizeButtons() {
|
||||
if (this.state.currentUser && this.state.currentUser.is_jury){
|
||||
if (this.props.content.ratings && this.props.content.ratings.rating){
|
||||
if (this.props.content.ratings &&
|
||||
(this.props.content.ratings.rating || this.props.content.ratings.average)){
|
||||
// jury and rating available
|
||||
let rating = parseInt(this.props.content.ratings.rating, 10);
|
||||
let rating = null,
|
||||
caption = null;
|
||||
if (this.props.content.ratings.rating){
|
||||
rating = parseInt(this.props.content.ratings.rating, 10);
|
||||
caption = 'Your rating';
|
||||
}
|
||||
else if (this.props.content.ratings.average){
|
||||
rating = this.props.content.ratings.average;
|
||||
caption = 'Average (' + this.props.content.ratings.ratings.length + ' ratings)';
|
||||
}
|
||||
|
||||
return (
|
||||
<div id="list-rating" className="pull-right">
|
||||
<Link to='piece' params={{pieceId: this.props.content.id}}>
|
||||
<StarRating
|
||||
ref='rating'
|
||||
name="prize-rating"
|
||||
caption="Your rating"
|
||||
step={1}
|
||||
caption={caption}
|
||||
step={0.5}
|
||||
size='sm'
|
||||
rating={rating}
|
||||
ratingAmount={5} />
|
||||
|
@ -59,6 +59,7 @@ let PieceContainer = React.createClass({
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if(this.props.params.pieceId !== nextProps.params.pieceId) {
|
||||
PieceActions.updatePiece({});
|
||||
console.log('update')
|
||||
PieceActions.fetchOne(nextProps.params.pieceId);
|
||||
}
|
||||
},
|
||||
@ -218,19 +219,40 @@ let PrizePieceRatings = React.createClass({
|
||||
title="Average Rating"
|
||||
show={true}
|
||||
defaultExpanded={true}>
|
||||
<div style={{marginLeft: '1.5em', marginBottom: '1em'}}>
|
||||
<StarRating
|
||||
ref='average-rating'
|
||||
name="average-rating"
|
||||
caption=""
|
||||
size='md'
|
||||
step={0.5}
|
||||
rating={this.state.average}
|
||||
ratingAmount={5}/>
|
||||
<div id="list-rating" style={{marginLeft: '1.5em', marginBottom: '1em'}}>
|
||||
<StarRating
|
||||
ref='average-rating'
|
||||
name="average-rating"
|
||||
caption=""
|
||||
size='md'
|
||||
step={0.5}
|
||||
rating={this.state.average}
|
||||
ratingAmount={5}/>
|
||||
</div>
|
||||
<hr />
|
||||
{this.state.ratings.map((item) => {
|
||||
return item.user;
|
||||
{this.state.ratings.map((item, i) => {
|
||||
let note = item.note ?
|
||||
<div className="rating-note">
|
||||
note: {item.note}
|
||||
</div> : null;
|
||||
return (
|
||||
<div className="rating-list">
|
||||
<div id="list-rating" className="row no-margin">
|
||||
<span className="pull-right">
|
||||
<StarRating
|
||||
ref={'rating' + i}
|
||||
name={'rating' + i}
|
||||
caption=""
|
||||
size='sm'
|
||||
step={0.5}
|
||||
rating={item.rating}
|
||||
ratingAmount={5}/>
|
||||
</span>
|
||||
<span> {item.user}</span>
|
||||
{note}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<hr />
|
||||
</CollapsibleParagraph>);
|
||||
@ -267,43 +289,6 @@ let PrizePieceRatings = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
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 && this.props.currentUser.username) {
|
||||
return (
|
||||
<Form
|
||||
url={ApiUrls.notes}
|
||||
handleSuccess={this.showNotification}>
|
||||
<Property
|
||||
name='value'
|
||||
label={getLangText('Jury note')}
|
||||
editable={true}>
|
||||
<InputTextAreaToggable
|
||||
rows={1}
|
||||
editable={true}
|
||||
defaultValue={this.props.piece && this.props.piece.note_from_user ? this.props.piece.note_from_user.note : null}
|
||||
placeholder={getLangText('Enter your comments...')}/>
|
||||
</Property>
|
||||
<Property hidden={true} name='piece_id'>
|
||||
<input defaultValue={this.props.piece.id}/>
|
||||
</Property>
|
||||
<hr />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
let PrizePieceDetails = React.createClass({
|
||||
propTypes: {
|
||||
|
@ -105,6 +105,7 @@ let CylandAdditionalDataForm = React.createClass({
|
||||
<InputTextAreaToggable
|
||||
rows={1}
|
||||
editable={!this.props.disabled}
|
||||
defaultValue={this.props.piece.extra_data.artist_bio}
|
||||
placeholder={getLangText('Enter the artist\'s biography...')}
|
||||
required="required"/>
|
||||
</Property>
|
||||
@ -115,6 +116,7 @@ let CylandAdditionalDataForm = React.createClass({
|
||||
<InputTextAreaToggable
|
||||
rows={1}
|
||||
editable={!this.props.disabled}
|
||||
defaultValue={this.props.piece.extra_data.conceptual_overview}
|
||||
placeholder={getLangText('Enter a conceptual overview...')}
|
||||
required="required"/>
|
||||
</Property>
|
||||
|
@ -77,6 +77,15 @@ let CylandRegisterPiece = React.createClass({
|
||||
}
|
||||
},
|
||||
|
||||
// This is done to update the container when the user clicks on the prev or next
|
||||
// button to update the URL parameter (and therefore to switch pieces)
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if(this.props.params.pieceId !== nextProps.params.pieceId) {
|
||||
PieceActions.updatePiece({});
|
||||
PieceActions.fetchOne(nextProps.params.pieceId);
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
PieceListStore.unlisten(this.onChange);
|
||||
UserStore.unlisten(this.onChange);
|
||||
|
@ -7,7 +7,8 @@ function getWalletApiUrls(subdomain) {
|
||||
if (subdomain === 'cyland'){
|
||||
return {
|
||||
'pieces_list': walletConstants.walletApiEndpoint + subdomain + '/pieces/',
|
||||
'piece': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/'
|
||||
'piece': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/',
|
||||
'piece_extradata': walletConstants.walletApiEndpoint + subdomain + '/pieces/${piece_id}/extradata/'
|
||||
};
|
||||
}
|
||||
else if (subdomain === 'ikonotv'){
|
||||
|
@ -403,17 +403,6 @@ hr {
|
||||
}
|
||||
}
|
||||
|
||||
.rating-container .rating-stars {
|
||||
width: 25px;
|
||||
color: #02b6a3;
|
||||
}
|
||||
#list-rating > a > span > span > .rating-container .rating-stars{
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.react-rating-caption {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.disable-select {
|
||||
-webkit-user-select: none;
|
||||
|
@ -1,4 +1,5 @@
|
||||
@import 'landing';
|
||||
@import 'rating';
|
||||
|
||||
.ascribe-prize-app {
|
||||
border-radius: 0;
|
||||
|
34
sass/whitelabel/prize/rating.scss
Normal file
34
sass/whitelabel/prize/rating.scss
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
.rating-container .rating-stars {
|
||||
width: 25px;
|
||||
color: #02b6a3;
|
||||
}
|
||||
|
||||
#list-rating {
|
||||
> a > span > span > .rating-container .rating-stars {
|
||||
color: #000;
|
||||
}
|
||||
> span > span > span > .rating-container .rating-stars {
|
||||
color: #000;
|
||||
}
|
||||
> span > span > .rating-container .rating-stars {
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
.react-rating-caption {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.rating-list {
|
||||
margin-left: 1.5em;
|
||||
font-size: 0.9em;
|
||||
margin-bottom: 0.3em;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.rating-note {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
padding: 0.2em;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user