Skip to content

Commit 85b80ff

Browse files
committed
Merge pull request #213 from DaleMcGrew/dale_work_april14
Updated components/Ballot/PositionItem.jsx to support individual voter opinions.
2 parents 80ecc66 + bd8c9a5 commit 85b80ff

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

src/js/components/Ballot/PositionItem.jsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class PositionItem extends Component {
66
static propTypes = {
77
position_we_vote_id: PropTypes.string.isRequired,
88
last_updated: PropTypes.string,
9+
speaker_type: PropTypes.string,
910
speaker_image_url_https: PropTypes.string,
1011
candidate_display_name: PropTypes.string.isRequired,
1112
speaker_display_name: PropTypes.string.isRequired
@@ -17,8 +18,30 @@ export default class PositionItem extends Component {
1718
var dateText = moment(dateStr).startOf("day").fromNow();
1819
var speaker_we_vote_id_link = "/voterguide/" + position.speaker_we_vote_id;
1920

21+
let image_placeholder = "";
22+
if (this.props.speaker_type == "O") {
23+
image_placeholder = <i className="icon-org-lg icon-icon-org-placeholder-6-2 icon-org-resting-color"></i>
24+
} else if (this.props.speaker_type == "V") {
25+
image_placeholder = <i className="icon-org-lg icon-icon-person-placeholder-6-1 icon-org-resting-color"></i>
26+
}
27+
28+
let position_description = <span></span>;
29+
if (position.vote_smart_rating) {
30+
position_description = <p className="">
31+
<span>rates {this.props.candidate_display_name} {position.vote_smart_rating}%</span>
32+
{ position.vote_smart_time_span ?
33+
<span> in {position.vote_smart_time_span}</span> :
34+
<span className="small">{ dateText }</span> }
35+
</p>;
36+
} else if (position.speaker_type == "V") {
37+
position_description = <p className="">
38+
<span>{this.props.candidate_display_name}</span>
39+
<span className="small"> { dateText }</span>
40+
</p>;
41+
}
42+
2043
return <div className="position-item">
21-
{/* One organization's Position on this Candidate */}
44+
{/* One Position on this Candidate */}
2245
<li className="list-group-item">
2346
<Link to={speaker_we_vote_id_link}>
2447
<div className="row">
@@ -28,20 +51,18 @@ export default class PositionItem extends Component {
2851
src={this.props.speaker_image_url_https}
2952
width="50px"
3053
/></span> :
31-
<i className="icon-org-lg icon-icon-org-placeholder-6-2 icon-org-resting-color"></i> }
54+
image_placeholder }
3255
</div>
3356
<div className="col-xs-8 col-md-10">
3457
<h4 className="">
35-
{ this.props.speaker_display_name }<br />
58+
{ this.props.speaker_display_name }
59+
{ position.is_support && !position.vote_smart_rating ? <span>
60+
&nbsp;support</span> : <span></span> }
61+
{ position.is_oppose && !position.vote_smart_rating ? <span>
62+
&nbsp;oppose</span> : <span></span> }
63+
<br />
3664
</h4>
37-
<p className="">rates {this.props.candidate_display_name}
38-
{ position.vote_smart_rating ?
39-
<span> {position.vote_smart_rating}%</span> :
40-
<span></span> }
41-
{ position.vote_smart_time_span ?
42-
<span> in {position.vote_smart_time_span}</span> :
43-
<span className="small">{ dateText }</span> }
44-
</p>
65+
{ position_description }
4566
</div>
4667
</div>
4768
</Link>

0 commit comments

Comments
 (0)