|
|
@@ -1,59 +1,64 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <styled-input label="Titre" v-model="title" />
|
|
|
- <styled-input label="Description" v-model="subTitle" />
|
|
|
- <div>
|
|
|
- <div class="formcontrol-label">Type de question</div>
|
|
|
- <button
|
|
|
- class="btn-group small left"
|
|
|
- :class="{ selected: type == 'competence' }"
|
|
|
- @click="type = 'competence'"
|
|
|
- >
|
|
|
- Options
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="btn-group small right"
|
|
|
- :class="{ selected: type == 'text' }"
|
|
|
- @click="type = 'text'"
|
|
|
- >
|
|
|
- Text libre
|
|
|
- </button>
|
|
|
- <button
|
|
|
- style="margin-left: 8px"
|
|
|
- class="btn-group small left"
|
|
|
- :class="{ selected: mandatory }"
|
|
|
- @click="mandatory = true"
|
|
|
- >
|
|
|
- Obligatoire
|
|
|
- </button>
|
|
|
- <button
|
|
|
- class="btn-group small right"
|
|
|
- :class="{ selected: mandatory == false }"
|
|
|
- @click="mandatory = false"
|
|
|
- >
|
|
|
- Facultative
|
|
|
- </button>
|
|
|
+ <div style="position: relative">
|
|
|
+ <div class="expand-button" @click="collapse">
|
|
|
+ <i class="material-icons">expand_{{ collapsed ? "more" : "less" }}</i>
|
|
|
</div>
|
|
|
- <div v-if="type == 'competence'">
|
|
|
- <chips-input
|
|
|
- label="Ajouter une option"
|
|
|
- placeholder="Choisir une option"
|
|
|
- secondary-placeholder="+ option"
|
|
|
- :autocompleteList="autocompleteList"
|
|
|
- :strict-autocomplete="true"
|
|
|
- v-model="competenceIdList"
|
|
|
- />
|
|
|
- <styled-input
|
|
|
- v-for="(c, idx) in competences"
|
|
|
- :key="idx"
|
|
|
- :helpText="competenceLabel(c.id)"
|
|
|
- :modelValue="c.text"
|
|
|
- @input="updateCompetenceText($event, idx)"
|
|
|
- />
|
|
|
- <styled-input v-if="mandatory" helpText="Réponse par défaut" v-model="mandatoryText" />
|
|
|
- <button class="btn small error" @click="$emit('delete')">
|
|
|
- <i class="material-icons">delete_forever</i>Supprimer
|
|
|
- </button>
|
|
|
+ <styled-input label="Titre" v-model="title" />
|
|
|
+ <div class="question-container" :class="{ collapsed }" ref="container">
|
|
|
+ <styled-input label="Description" v-model="subTitle" />
|
|
|
+ <div>
|
|
|
+ <div class="formcontrol-label">Type de question</div>
|
|
|
+ <button
|
|
|
+ class="btn-group small left"
|
|
|
+ :class="{ selected: type == 'competence' }"
|
|
|
+ @click="type = 'competence'"
|
|
|
+ >
|
|
|
+ Options
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ class="btn-group small right"
|
|
|
+ :class="{ selected: type == 'text' }"
|
|
|
+ @click="type = 'text'"
|
|
|
+ >
|
|
|
+ Text libre
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ style="margin-left: 8px"
|
|
|
+ class="btn-group small left"
|
|
|
+ :class="{ selected: mandatory }"
|
|
|
+ @click="mandatory = true"
|
|
|
+ >
|
|
|
+ Obligatoire
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ class="btn-group small right"
|
|
|
+ :class="{ selected: mandatory == false }"
|
|
|
+ @click="mandatory = false"
|
|
|
+ >
|
|
|
+ Facultative
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ <div v-if="type == 'competence'">
|
|
|
+ <chips-input
|
|
|
+ label="Ajouter une option"
|
|
|
+ placeholder="Choisir une option"
|
|
|
+ secondary-placeholder="+ option"
|
|
|
+ :autocompleteList="autocompleteList"
|
|
|
+ :strict-autocomplete="true"
|
|
|
+ v-model="competenceIdList"
|
|
|
+ />
|
|
|
+ <styled-input
|
|
|
+ v-for="(c, idx) in competences"
|
|
|
+ :key="idx"
|
|
|
+ :helpText="competenceLabel(c.id)"
|
|
|
+ :modelValue="c.text"
|
|
|
+ @input="updateCompetenceText($event, idx)"
|
|
|
+ />
|
|
|
+ <styled-input v-if="mandatory" helpText="Réponse par défaut" v-model="mandatoryText" />
|
|
|
+ <button class="btn small error" @click="$emit('delete')">
|
|
|
+ <i class="material-icons">delete_forever</i>Supprimer
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -72,6 +77,7 @@ export default defineComponent({
|
|
|
components: { styledInput, chipsInput },
|
|
|
data() {
|
|
|
return {
|
|
|
+ collapsed: false,
|
|
|
title: "",
|
|
|
subTitle: "",
|
|
|
type: "competence" as QuestionType,
|
|
|
@@ -140,6 +146,14 @@ export default defineComponent({
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
+ collapse() {
|
|
|
+ const c = this.$refs.container as HTMLDivElement;
|
|
|
+ c.style.height = c.scrollHeight + "px";
|
|
|
+ setTimeout(() => {
|
|
|
+ c.style.height = "";
|
|
|
+ }, 100);
|
|
|
+ this.collapsed = !this.collapsed;
|
|
|
+ },
|
|
|
updateValue() {
|
|
|
const val = this.modelValue;
|
|
|
if (this.title != val.title) this.title = val.title;
|
|
|
@@ -196,4 +210,21 @@ export default defineComponent({
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
-<style scoped></style>
|
|
|
+<style scoped>
|
|
|
+.question-container {
|
|
|
+ transition: all 300ms;
|
|
|
+ transform-origin: top;
|
|
|
+ opacity: 1;
|
|
|
+}
|
|
|
+.question-container.collapsed {
|
|
|
+ height: 0;
|
|
|
+ opacity: 0;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.expand-button {
|
|
|
+ position: absolute;
|
|
|
+ right: 8px;
|
|
|
+ cursor: pointer;
|
|
|
+ z-index: 1;
|
|
|
+}
|
|
|
+</style>
|