Skip to content

Commit 4bbd075

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

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

src/components/Questions/QuestionRanking.vue

Lines changed: 31 additions & 9 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+
@start="onRankingStart"
47+
@end="onRankingEnd">
48+
<TransitionGroup
49+
tag="ul"
50+
:name="isRanking ? undefined : 'options-list-transition'"
51+
class="sort-target">
52+
<li v-for="option in unrankedOptions" :key="option.id">
53+
<button
54+
type="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,11 @@
6877
target=".sort-target"
6978
direction="vertical"
7079
handle=".ranking-item__drag-handle"
80+
@start="onRankingStart"
7181
@end="onRankingEnd">
7282
<TransitionGroup
7383
tag="ul"
74-
:name="isDragging ? undefined : 'options-list-transition'"
84+
:name="isRanking ? undefined : 'options-list-transition'"
7585
class="sort-target">
7686
<li
7787
v-for="(option, index) in rankedOptions"
@@ -235,6 +245,7 @@ export default {
235245
return {
236246
errorMessage: null,
237247
isDragging: false,
248+
isRanking: false,
238249
isLoading: false,
239250
isOptionDialogShown: false,
240251
rankedOptions: [],
@@ -412,10 +423,17 @@ export default {
412423
})
413424
},
414425
426+
onRankingStart() {
427+
this.isRanking = true
428+
},
429+
415430
/**
416431
* Emit the current ranking after a drag reorder
417432
*/
418433
onRankingEnd() {
434+
this.$nextTick(() => {
435+
this.isRanking = false
436+
})
419437
this.emitValues()
420438
},
421439
@@ -482,6 +500,10 @@ export default {
482500
font-style: italic;
483501
padding: var(--default-grid-baseline) 0;
484502
}
503+
504+
li {
505+
display: inline-block;
506+
}
485507
}
486508
487509
.ranking-ranked {

0 commit comments

Comments
 (0)