|
|
@@ -2,7 +2,6 @@
|
|
|
<div class="questionnaire-container">
|
|
|
<div class="questionnaire-editor">
|
|
|
<h4>Edition du questionnaire</h4>
|
|
|
- <div></div>
|
|
|
<div class="editor">
|
|
|
<textarea
|
|
|
ref="textarea"
|
|
|
@@ -27,6 +26,9 @@
|
|
|
<i class="material-icons">launch</i>Lien vers le formulaire d'inscription
|
|
|
</a>
|
|
|
</div>
|
|
|
+ <div class="actions">
|
|
|
+ <toggle id="switch-questionnaire" label="Activer le questionnaire" v-model="opened" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="questionnaire-preview">
|
|
|
<h4>Previsualisation du questionnaire</h4>
|
|
|
@@ -49,6 +51,7 @@ import debounce from "lodash-es/debounce";
|
|
|
|
|
|
import vQuestion from "@/components/EditeurQuestionnaireQuestion.vue";
|
|
|
import vQuestionnaire from "@/components/Questionaire.vue";
|
|
|
+import toggle from "@/components/Form/Toggle.vue";
|
|
|
|
|
|
import { Question } from "@/models/Questionnaire";
|
|
|
import Competence from "@/models/Competence";
|
|
|
@@ -58,7 +61,7 @@ import Toast from "@/utils/Toast";
|
|
|
const API_URL = process.env.VUE_APP_API_URL;
|
|
|
|
|
|
export default defineComponent({
|
|
|
- components: { vQuestion, vQuestionnaire },
|
|
|
+ components: { vQuestion, vQuestionnaire, toggle },
|
|
|
mixins: [getQuestionnaire],
|
|
|
props: {
|
|
|
competences: { type: Array as PropType<Array<Competence>>, default: () => [] },
|
|
|
@@ -88,19 +91,27 @@ export default defineComponent({
|
|
|
a.style.height = a.scrollHeight + "px";
|
|
|
});
|
|
|
},
|
|
|
+ opened(val: boolean) {
|
|
|
+ const url = `${API_URL}api/questionnaire/${this.uuid}/${val ? "open" : "close"}`;
|
|
|
+ fetch(url, { method: "POST" });
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
updateIntro(e: InputEvent) {
|
|
|
this.introduction = (e.target as HTMLInputElement).value;
|
|
|
this.savedIntro = false;
|
|
|
|
|
|
- this.saveIntro();
|
|
|
+ this.saveQuestionnaire();
|
|
|
},
|
|
|
- saveIntro() {
|
|
|
+ saveQuestionnaire() {
|
|
|
if (!this.loading) {
|
|
|
fetch(`${API_URL}api/questionnaire/${this.uuid}`, {
|
|
|
method: "POST",
|
|
|
- body: JSON.stringify({ uuid: this.uuid, introduction: this.introduction }),
|
|
|
+ body: JSON.stringify({
|
|
|
+ uuid: this.uuid,
|
|
|
+ introduction: this.introduction,
|
|
|
+ opened: this.opened,
|
|
|
+ }),
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
}).then(() => (this.savedIntro = true));
|
|
|
}
|
|
|
@@ -185,14 +196,14 @@ export default defineComponent({
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.saveIntro = debounce(this.saveIntro, 5000);
|
|
|
+ this.saveQuestionnaire = debounce(this.saveQuestionnaire, 5000);
|
|
|
this.updateIntro = debounce(this.updateIntro, 300);
|
|
|
this.saveQuestions = debounce(this.saveQuestions, 1000);
|
|
|
if (this.uuid) this.getQuestionnaire(this.uuid);
|
|
|
setTimeout(() => (this.loading = false), 5000);
|
|
|
},
|
|
|
unmounted() {
|
|
|
- if (!this.savedIntro) this.saveIntro();
|
|
|
+ if (!this.savedIntro) this.saveQuestionnaire();
|
|
|
if (!this.savedQuestions) this.saveQuestions();
|
|
|
},
|
|
|
});
|