Skip to content

Commit

Permalink
Merge pull request #678 from getguesstimate/new-form-should-reset
Browse files Browse the repository at this point in the history
The new fact form should reset properly after fact creation.
  • Loading branch information
OAGr authored Aug 2, 2016
2 parents 77ecf2d + 6e1d154 commit e8012fd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/organizations/show/facts/facts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {getVar} from 'gEngine/facts'
export class FactBookTab extends Component {
state = {
editingFactId: null,
newFactKey: 0,
}

componentWillUpdate(newProps) {
Expand All @@ -16,6 +17,11 @@ export class FactBookTab extends Component {
}
}

onAddFact(fact) {
this.props.onAddFact(fact)
this.setState({newFactKey: this.state.newFactKey + 1})
}

renderFactShow(fact) {
return (
<FactRow
Expand All @@ -28,12 +34,12 @@ export class FactBookTab extends Component {
}

renderFactForm(fact = null) {
const {facts, onAddFact, onEditFact} = this.props
const {facts, onEditFact} = this.props
let props = {
key: !!fact ? fact.id : 'new',
key: !!fact ? fact.id : this.state.newFactKey.toString(),
existingVariableNames: facts.map(getVar).filter(v => v !== getVar(fact)),
buttonText: !!fact ? 'Save' : 'Create',
onSubmit: (!!fact ? onEditFact : onAddFact),
onSubmit: (!!fact ? onEditFact : this.onAddFact.bind(this)),
}
if (!!fact) {props.startingFact = fact}
return (<FactForm {...props}/>)
Expand Down

0 comments on commit e8012fd

Please sign in to comment.