Add button to reopen survey

This commit is contained in:
Ramon Wenger 2019-07-24 15:22:53 +02:00
parent c81bcbd26b
commit fa72d8f5b8
2 changed files with 17 additions and 1 deletions

View File

@ -2,6 +2,9 @@
<div class="survey-page"> <div class="survey-page">
<h1 class="survey-page__title">{{title}}</h1> <h1 class="survey-page__title">{{title}}</h1>
<survey :survey='survey'></survey> <survey :survey='survey'></survey>
<div v-if="surveyComplete">
<a class="button button--primary" @click="reopen">Übung bearbeiten</a>
</div>
</div> </div>
</template> </template>
@ -28,6 +31,12 @@
} }
}, },
computed: {
surveyComplete() {
return this.survey && this.survey.isCompleted
}
},
methods: { methods: {
initSurvey(data, answer) { initSurvey(data, answer) {
let survey = new SurveyVue.Model(data); let survey = new SurveyVue.Model(data);
@ -72,6 +81,11 @@
survey.showProgressBar = 'bottom'; survey.showProgressBar = 'bottom';
return survey; return survey;
},
reopen() {
let data = this.survey.data; // save the data
this.survey.clear();
this.survey.data = data; // reapply it
} }
}, },
@ -110,6 +124,7 @@
max-width: 800px; max-width: 800px;
display: grid; display: grid;
grid-template-rows: auto 1fr; grid-template-rows: auto 1fr;
grid-auto-rows: 1fr;
grid-row-gap: $large-spacing; grid-row-gap: $large-spacing;
justify-self: center; justify-self: center;
padding: 100px 0; padding: 100px 0;

View File

@ -91,7 +91,8 @@ const routes = [
path: '/survey/:id', path: '/survey/:id',
component: surveyPage, component: surveyPage,
name: 'survey', name: 'survey',
props: true props: true,
meta: {layout: 'simple'}
}, },
{path: '/styleguide', component: styleGuidePage}, {path: '/styleguide', component: styleGuidePage},
{path: '*', component: p404} {path: '*', component: p404}