Go back after completing a survey

This commit is contained in:
Ramon Wenger 2021-06-07 15:17:24 +02:00
parent 3156b2c482
commit 533d3804d6
1 changed files with 12 additions and 3 deletions

View File

@ -115,7 +115,8 @@
survey.data = flatAnswers; survey.data = flatAnswers;
} }
const saveSurvey = (sender, options) => { const saveSurvey = (sender, {exit}) => {
this.$log.debug('saving survey', sender);
if (this.saveDisabled) { if (this.saveDisabled) {
return; return;
} }
@ -142,7 +143,6 @@
data: JSON.stringify(data), data: JSON.stringify(data),
}; };
this.$log.debug('saving survey', answer);
this.$apollo.mutate({ this.$apollo.mutate({
mutation: UPDATE_ANSWER, mutation: UPDATE_ANSWER,
variables: { variables: {
@ -159,10 +159,19 @@
store.writeQuery({query, variables, data: queryData}); store.writeQuery({query, variables, data: queryData});
} }
}, },
}).then(() => {
if (exit) {
this.$router.go(-1);
}
}); });
}; };
survey.onComplete.add(saveSurvey); survey.onComplete.add((sender, options) => {
saveSurvey(sender, {
...options,
exit: true
});
});
survey.onCurrentPageChanged.add(saveSurvey); survey.onCurrentPageChanged.add(saveSurvey);
survey.css = css; survey.css = css;