Skip to content

Commit 08874fa

Browse files
committed
fix(QuestionRanking): drag and drop while ranking options
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent d92ecab commit 08874fa

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

src/components/Questions/QuestionRanking.vue

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,23 @@
4141
class="ranking-unranked__pool"
4242
:animation="300"
4343
:group="'ranking_' + id"
44-
@end="emitValues">
45-
<button
46-
v-for="option in unrankedOptions"
47-
:key="option.id"
48-
class="ranking-unranked__item"
49-
@click="rankOption(option)">
50-
{{ option.text }}
51-
</button>
44+
target=".sort-target"
45+
direction="horizontal"
46+
@updated="emitValues"
47+
@start="onRankingStart"
48+
@end="onRankingEnd">
49+
<TransitionGroup
50+
tag="ul"
51+
:name="isRanking ? undefined : 'options-list-transition'"
52+
class="sort-target">
53+
<li v-for="option in unrankedOptions" :key="option.id">
54+
<button
55+
class="ranking-unranked__item"
56+
@click="rankOption(option)">
57+
{{ option.text }}
58+
</button>
59+
</li>
60+
</TransitionGroup>
5261
</Draggable>
5362
<p v-else class="ranking-unranked__empty">
5463
{{ t('forms', 'All options ranked') }}
@@ -68,10 +77,12 @@
6877
target=".sort-target"
6978
direction="vertical"
7079
handle=".ranking-item__drag-handle"
80+
@updated="emitValues"
81+
@start="onRankingStart"
7182
@end="onRankingEnd">
7283
<TransitionGroup
7384
tag="ul"
74-
:name="isDragging ? undefined : 'options-list-transition'"
85+
:name="isRanking ? undefined : 'options-list-transition'"
7586
class="sort-target">
7687
<li
7788
v-for="(option, index) in rankedOptions"
@@ -235,6 +246,7 @@ export default {
235246
return {
236247
errorMessage: null,
237248
isDragging: false,
249+
isRanking: false,
238250
isLoading: false,
239251
isOptionDialogShown: false,
240252
rankedOptions: [],
@@ -412,11 +424,17 @@ export default {
412424
})
413425
},
414426
427+
onRankingStart() {
428+
this.isRanking = true
429+
},
430+
415431
/**
416432
* Emit the current ranking after a drag reorder
417433
*/
418434
onRankingEnd() {
419-
this.emitValues()
435+
this.$nextTick(() => {
436+
this.isRanking = false
437+
})
420438
},
421439
422440
/**
@@ -482,6 +500,10 @@ export default {
482500
font-style: italic;
483501
padding: var(--default-grid-baseline) 0;
484502
}
503+
504+
li {
505+
display: flex;
506+
}
485507
}
486508
487509
.ranking-ranked {

0 commit comments

Comments
 (0)