Merge branch 'develop'
This commit is contained in:
commit
23db6e373c
|
|
@ -39,6 +39,7 @@
|
||||||
survey: this.initSurvey(),
|
survey: this.initSurvey(),
|
||||||
title: '',
|
title: '',
|
||||||
module: {},
|
module: {},
|
||||||
|
completed: false,
|
||||||
me: {
|
me: {
|
||||||
permissions: []
|
permissions: []
|
||||||
},
|
},
|
||||||
|
|
@ -74,19 +75,21 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
initSurvey(data, answer) {
|
initSurvey(data, answers) {
|
||||||
let survey = new SurveyVue.Model(data);
|
let survey = new SurveyVue.Model(data);
|
||||||
const flatAnswers = {};
|
const flatAnswers = {};
|
||||||
for (let k in answer) {
|
for (let k in answers) {
|
||||||
flatAnswers[k] = answer[k].answer;
|
flatAnswers[k] = answers[k].answer;
|
||||||
}
|
}
|
||||||
survey.data = flatAnswers;
|
survey.data = flatAnswers;
|
||||||
|
|
||||||
survey.onComplete.add((sender, options) => {
|
const saveSurvey = (sender, options) => {
|
||||||
// sender.clear(false);
|
// sender.clear(false);
|
||||||
//
|
//
|
||||||
// sender.mode = 'display';
|
// sender.mode = 'display';
|
||||||
|
|
||||||
|
this.completed = true;
|
||||||
|
|
||||||
const data = {};
|
const data = {};
|
||||||
|
|
||||||
for (let k in survey.data) {
|
for (let k in survey.data) {
|
||||||
|
|
@ -109,43 +112,30 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refetchQueries: [{
|
|
||||||
query: SURVEY_QUERY,
|
|
||||||
variables: {id: this.id}
|
|
||||||
}],
|
|
||||||
// fixme: make the update work instead of refetching
|
// fixme: make the update work instead of refetching
|
||||||
// update: (store, {data: {updateAnswer: {answer}}}) => {
|
update: (store, {data: {updateAnswer: {answer}}}) => {
|
||||||
// // try {
|
const query = SURVEY_QUERY;
|
||||||
// console.log(answer);
|
const variables = {id: this.id};
|
||||||
// const query = SURVEY_QUERY;
|
const queryData = store.readQuery({query, variables});
|
||||||
// const variables = {id: this.id};
|
if (queryData.survey) {
|
||||||
// const queryData = store.readQuery({query, variables});
|
queryData.survey.answer = answer;
|
||||||
// console.log('queryData', queryData);
|
store.writeQuery({query, variables, data: queryData});
|
||||||
// if (queryData.survey) {
|
}
|
||||||
// console.log('answer.data', answer.data);
|
}
|
||||||
// queryData.survey.answer = {
|
|
||||||
// data: {
|
|
||||||
// ...data,
|
|
||||||
// __typename: 'AnswerNode'
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// store.writeQuery({query, variables, data: queryData});
|
|
||||||
// }
|
|
||||||
// // } catch (e) {
|
|
||||||
// // console.error(e);
|
|
||||||
// // // Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
survey.onComplete.add(saveSurvey);
|
||||||
|
survey.onCurrentPageChanged.add(saveSurvey);
|
||||||
|
|
||||||
survey.css = css;
|
survey.css = css;
|
||||||
survey.locale = 'de';
|
survey.locale = 'de';
|
||||||
survey.showProgressBar = 'bottom';
|
survey.showProgressBar = 'bottom';
|
||||||
|
survey.pageNextText = 'Speichern & Weiter';
|
||||||
return survey;
|
return survey;
|
||||||
},
|
},
|
||||||
reopen() {
|
reopen() {
|
||||||
|
this.completed = false;
|
||||||
let data = this.survey.data; // save the data
|
let data = this.survey.data; // save the data
|
||||||
this.survey.clear();
|
this.survey.clear();
|
||||||
this.survey.data = data; // reapply it
|
this.survey.data = data; // reapply it
|
||||||
|
|
@ -170,7 +160,9 @@
|
||||||
answer = JSON.parse(data.survey.answer.data);
|
answer = JSON.parse(data.survey.answer.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.survey = this.initSurvey(json, answer);
|
if (!this.completed) {
|
||||||
|
this.survey = this.initSurvey(json, answer);
|
||||||
|
}
|
||||||
this.title = json.title;
|
this.title = json.title;
|
||||||
const module = data.survey.module;
|
const module = data.survey.module;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue