Commit b40f5341 authored by GuiΩ's avatar GuiΩ
Browse files

fix(QuestionEditor): save the correct themes

parent c851b4cd
Pipeline #513642 failed with stages
in 3 minutes and 52 seconds
......@@ -158,16 +158,17 @@ export default {
save() {
this.$el.style['cursor'] = 'wait';
let themes = [];
for (const theme_id in this.themes_selection){
for (let i = 0; i < this.themes_selection.length; i++) {
const theme_id = this.themes_selection[i];
let found = false
for (const i in this.question.themes) {
if (this.question.themes.hasOwnProperty(i) && this.question.themes[i].theme === theme_id) {
themes.push(this.question.themes[i]);
for (let j = 0; j < this.question.themes.length; j++) {
if (this.question.themes[j].theme === theme_id) {
themes.push(this.question.themes[j]);
found = true;
break;
}
}
if (! found)
if (!found)
themes.push({theme: theme_id, position: null});
}
this.question.themes = themes;
......
......@@ -18,28 +18,29 @@ Events:
drop-context-menu(ref="rightContextMenu")
div(
v-if="editable(questionSel[0])"
@click="$emit('question-edit', {question_id: questionSel[0].id}); $refs.rightContextMenu.close()"
v-if="editable(questionSel[0])"
@click="$emit('question-edit', {question_id: contextMenuSelection}); contextMenuSelection=null; $refs.rightContextMenu.close()"
) Modifier
div(@click="$emit('question-duplicate', {question_id: questionSel[0].id}); $refs.rightContextMenu.close()") Dupliquer
div(@click="$refs.rightContextMenu.close()") Annuler
div(@click="$emit('question-duplicate', {question_id: contextMenuSelection}); contextMenuSelection=null; $refs.rightContextMenu.close()") Dupliquer
div(@click="contextMenuSelection=null; $refs.rightContextMenu.close()") Annuler
div
question-list-node(
v-for="(question_id, index) in question_ids"
:key="index"
ref="questions"
:index="index"
:question_id="question_id"
:selected="questionSel.indexOf(question_id)>=0"
@click="onQuestionClick($event)"
@dblclick="onQuestionDblClick($event)"
@dragStart="onDragStart($event)"
@hideDrop="onHideDrop"
@showDrop="onShowDrop"
@drop-context-menu="onDropContextMenu"
@question-drop="$emit('question-drop', $event)"
@question-edit="$emit('question-edit', $event)")/
v-for="(question_id, index) in question_ids"
:key="index"
ref="questions"
:index="index"
:question_id="question_id"
:selected="questionSel.indexOf(question_id)>=0"
@click="onQuestionClick"
@dblclick="onQuestionDblClick"
@contextmenu="onContextMenu"
@dragStart="onDragStart"
@hideDrop="onHideDrop"
@showDrop="onShowDrop"
@drop-context-menu="onDropContextMenu"
@question-drop="$emit('question-drop', $event)"
@question-edit="$emit('question-edit', $event)")/
</template>
<script>
......@@ -63,6 +64,7 @@ export default {
dropEvent: null,
dropIndex: 0,
questionSel: [],
contextMenuSelection: null,
}
},
computed: {
......@@ -133,13 +135,16 @@ export default {
}
} else
this.questionSel = [event.question_id];
if ((! event.ctrlKey && ! event.shiftKey) || !permissions.includes('Validateur') )
if ((!event.ctrlKey && !event.shiftKey) || !permissions.includes('Validateur'))
this.$emit('show-question-tooltip', event)
},
onQuestionDblClick(event) {
this.questionSel = [event.question_id];
this.$emit('question-edit', event)
},
onContextMenu(event) {
this.showContextMenu(event, event.question_id);
},
changePosition() {
const indexSource = this.dropEvent.dataTransfer.getData('index');
const positionDest = this.$refs.questions[this.dropIndex].question.getPositionInTheme(this.theme_id);
......@@ -247,8 +252,8 @@ export default {
index++
return this.$refs.questions[index]
},
showContextMenu(event, question) {
this.questionSel = [question.id];
showContextMenu(event, question_id) {
this.contextMenuSelection = question_id;
this.$refs.rightContextMenu.show(event);
}
},
......
......@@ -20,7 +20,7 @@
@dragover.prevent
@dragleave.prevent="onDragLeave($event, index)"
@dragstart="dragStart($event, index, question)"
@contextmenu.prevent.stop="questionSel = question; $parent.showContextMenu($event, question)"
@contextmenu.prevent="onContextMenu($event, question_id)"
@drop.prevent.stop="onDrop($event, index, question)")/
.question_vide(v-else) Question {{ question_id }}
</template>
......@@ -70,12 +70,16 @@ export default {
}, this.clickTimeout);
}
},
onDblClick(event, question_id){
onDblClick(event, question_id) {
clearTimeout(this.clickTimer);
this.nClick = 0;
event.question_id = question_id;
this.$emit('dblclick', event)
},
onContextMenu(event, question_id) {
event.question_id = question_id
this.$emit('contextmenu', event);
},
/**
* init dataTransfer for a drag
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment