Skip to content

Commit

Permalink
Force validation and save after importing a questionnaire (fixes #1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
waj committed Jun 28, 2017
1 parent f6478b3 commit aa22844
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions web/static/js/actions/questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const SET_SECONDARY_COLOR = 'QUESTIONNAIRE_SET_SECONDARY_COLOR'
export const SET_DISPLAYED_TITLE = 'QUESTIONNAIRE_SET_DISPLAYED_TITLE'
export const SET_SURVEY_ALREADY_TAKEN_MESSAGE = 'QUESTIONNAIRE_SET_SURVEY_ALREADY_TAKEN_MESSAGE'
export const TOGGLE_QUOTA_COMPLETED_STEPS = 'QUESTIONNAIRE_TOGGLE_QUOTA_COMPLETED_STEPS'
export const SET_DIRTY = 'QUESTIONNAIRE_SET_DIRTY'

export const fetchQuestionnaire = (projectId, id) => (dispatch, getState) => {
dispatch(fetch(projectId, id))
Expand Down Expand Up @@ -101,6 +102,10 @@ export const shouldFetch = (state, projectId, id) => {
return !state.fetching || !(state.filter && (state.filter.projectId == projectId && state.filter.id == id))
}

export const setDirty = () => ({
type: SET_DIRTY
})

export const addChoice = (stepId) => ({
type: ADD_CHOICE,
stepId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class QuestionnaireMenu extends Component {
this.props.uiActions.deselectStep()
this.props.uiActions.deselectQuotaCompletedStep()
this.props.questionnaireActions.receive(questionnaire)
this.props.questionnaireActions.setDirty()
importModal.close()
})

Expand Down
3 changes: 3 additions & 0 deletions web/static/js/reducers/questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const dataReducer = (state: Questionnaire, action): Questionnaire => {
case actions.CHANGE_DISPOSITION: return changeDisposition(state, action)
case actions.TOGGLE_ACCEPT_REFUSALS: return toggleAcceptsRefusals(state, action)
case actions.CHANGE_REFUSAL: return changeRefusal(state, action)
case actions.SET_DIRTY: return setDirty(state)
default: return state
}
}
Expand Down Expand Up @@ -1549,3 +1550,5 @@ const setSecondaryColor = (state, action) => {
}
}
}

const setDirty = (state) => ({...state})

0 comments on commit aa22844

Please sign in to comment.