Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated components/Ballot/PositionItem.jsx to support individual voter opinions. #213

Merged
merged 2 commits into from
Apr 16, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions src/js/components/Ballot/PositionItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default class PositionItem extends Component {
static propTypes = {
position_we_vote_id: PropTypes.string.isRequired,
last_updated: PropTypes.string,
speaker_type: PropTypes.string,
speaker_image_url_https: PropTypes.string,
candidate_display_name: PropTypes.string.isRequired,
speaker_display_name: PropTypes.string.isRequired
Expand All @@ -17,8 +18,30 @@ export default class PositionItem extends Component {
var dateText = moment(dateStr).startOf("day").fromNow();
var speaker_we_vote_id_link = "/voterguide/" + position.speaker_we_vote_id;

var image_placeholder = "";
if (this.props.speaker_type == "O") {
image_placeholder = <i className="icon-org-lg icon-icon-org-placeholder-6-2 icon-org-resting-color"></i>
} else if (this.props.speaker_type == "V") {
image_placeholder = <i className="icon-org-lg icon-icon-person-placeholder-6-1 icon-org-resting-color"></i>
}

var position_description = <span></span>;
if (position.vote_smart_rating) {
var position_description = <p className="">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will get hoisted because there is no block scope unless you use let. var will get hoisted outside of the block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have altered this now for your review. Thank you.

<span>rates {this.props.candidate_display_name} {position.vote_smart_rating}%</span>
{ position.vote_smart_time_span ?
<span> in {position.vote_smart_time_span}</span> :
<span className="small">{ dateText }</span> }
</p>;
} else if (position.speaker_type == "V") {
var position_description = <p className="">
<span>{this.props.candidate_display_name}</span>
<span className="small"> { dateText }</span>
</p>;
}

return <div className="position-item">
{/* One organization's Position on this Candidate */}
{/* One Position on this Candidate */}
<li className="list-group-item">
<Link to={speaker_we_vote_id_link}>
<div className="row">
Expand All @@ -28,20 +51,18 @@ export default class PositionItem extends Component {
src={this.props.speaker_image_url_https}
width="50px"
/></span> :
<i className="icon-org-lg icon-icon-org-placeholder-6-2 icon-org-resting-color"></i> }
image_placeholder }
</div>
<div className="col-xs-8 col-md-10">
<h4 className="">
{ this.props.speaker_display_name }<br />
{ this.props.speaker_display_name }
{ position.is_support && !position.vote_smart_rating ? <span>
&nbsp;support</span> : <span></span> }
{ position.is_oppose && !position.vote_smart_rating ? <span>
&nbsp;oppose</span> : <span></span> }
<br />
</h4>
<p className="">rates {this.props.candidate_display_name}
{ position.vote_smart_rating ?
<span> {position.vote_smart_rating}%</span> :
<span></span> }
{ position.vote_smart_time_span ?
<span> in {position.vote_smart_time_span}</span> :
<span className="small">{ dateText }</span> }
</p>
{ position_description }
</div>
</div>
</Link>
Expand Down