-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Position Store action and constants
- Loading branch information
1 parent
9d6d520
commit 03d48d1
Showing
9 changed files
with
204 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
var AppDispatcher = require('../dispatcher/AppDispatcher'); | ||
var PositionConstants = require('../constants/BallotConstants'); | ||
|
||
// In the stores, there are AppDispatcher blocks that listen for these actionType constants (ex/ VOTER_SUPPORTING_SAVE) | ||
// When action calls one of these functions, we are telling the code in the AppDispatcher block to run | ||
module.exports = { | ||
|
||
positionRetrieved: function( we_vote_id, payload) { | ||
AppDispatcher.dispatch({ | ||
actionType: PositionConstants.POSITION_RETRIEVED, | ||
payload: payload, | ||
we_vote_id: we_vote_id | ||
}); | ||
}, | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import BallotStore from '../../stores/BallotStore'; | ||
import PositionItem from './PositionItem'; | ||
|
||
export default class PositionList extends Component { | ||
static propTypes = { | ||
we_vote_id: PropTypes.string.isRequired | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { position_list: [] }; | ||
} | ||
// no candidate exists... go to ballot | ||
componentDidMount(){ | ||
BallotStore.fetchCandidatePositionsByWeVoteId(this.props.we_vote_id) | ||
BallotStore.addChangeListener(this._onChange.bind(this)); | ||
} | ||
|
||
componentWillUnmount(){ | ||
BallotStore.removeChangeListener(this._onChange.bind(this)); | ||
} | ||
|
||
_onChange(){ | ||
this.setState({ position_list: BallotStore.getCandidateByWeVoteId(this.props.we_vote_id).position_list }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<ul className="list-group"> | ||
{ this.state.position_list.map( item => | ||
<PositionItem key={item.position_we_vote_id} position_we_vote_id={item.position_we_vote_id} /> ) | ||
} | ||
</ul> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require('keymirror')({ | ||
POSITION_RETRIEVED: null | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.