Skip to content

Commit 08800d3

Browse files
fix: realign drag layout to be consistent with create view and include keyboard menu
Signed-off-by: paul bochtler <65470117+datapumpernickel@users.noreply.github.com>
1 parent 5b02986 commit 08800d3

1 file changed

Lines changed: 87 additions & 19 deletions

File tree

src/components/Questions/QuestionRanking.vue

Lines changed: 87 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,43 @@
6969
class="ranking-item"
7070
role="listitem">
7171
<span class="ranking-item__position">{{ index + 1 }}.</span>
72-
<span class="ranking-item__drag-handle">
73-
<IconDragHorizontalVariant :size="20" />
74-
</span>
7572
<span class="ranking-item__text">{{ option.text }}</span>
76-
<NcButton
77-
variant="tertiary"
78-
:ariaLabel="t('forms', 'Remove from ranking')"
79-
@click="unrankOption(option)">
80-
<template #icon>
81-
<IconClose :size="20" />
82-
</template>
83-
</NcButton>
73+
<div class="ranking-item__actions">
74+
<NcActions
75+
:aria-label="t('forms', 'Move option actions')"
76+
class="ranking-item__drag-handle"
77+
variant="tertiary-no-background">
78+
<template #icon>
79+
<IconDragIndicator :size="20" />
80+
</template>
81+
<NcActionButton
82+
ref="buttonOptionUp"
83+
:disabled="index === 0"
84+
@click="onMoveUp(index)">
85+
<template #icon>
86+
<IconArrowUp :size="20" />
87+
</template>
88+
{{ t('forms', 'Move option up') }}
89+
</NcActionButton>
90+
<NcActionButton
91+
ref="buttonOptionDown"
92+
:disabled="index === rankedOptions.length - 1"
93+
@click="onMoveDown(index)">
94+
<template #icon>
95+
<IconArrowDown :size="20" />
96+
</template>
97+
{{ t('forms', 'Move option down') }}
98+
</NcActionButton>
99+
</NcActions>
100+
<NcButton
101+
variant="tertiary"
102+
:ariaLabel="t('forms', 'Remove from ranking')"
103+
@click="unrankOption(option)">
104+
<template #icon>
105+
<IconClose :size="20" />
106+
</template>
107+
</NcButton>
108+
</div>
84109
</div>
85110
</Draggable>
86111
</div>
@@ -139,11 +164,14 @@
139164
import { VueDraggable as Draggable } from 'vue-draggable-plus'
140165
import NcActionButton from '@nextcloud/vue/components/NcActionButton'
141166
import NcActionCheckbox from '@nextcloud/vue/components/NcActionCheckbox'
167+
import NcActions from '@nextcloud/vue/components/NcActions'
142168
import NcButton from '@nextcloud/vue/components/NcButton'
143169
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
170+
import IconArrowDown from 'vue-material-design-icons/ArrowDown.vue'
171+
import IconArrowUp from 'vue-material-design-icons/ArrowUp.vue'
144172
import IconClose from 'vue-material-design-icons/Close.vue'
145173
import IconContentPaste from 'vue-material-design-icons/ContentPaste.vue'
146-
import IconDragHorizontalVariant from 'vue-material-design-icons/DragHorizontalVariant.vue'
174+
import IconDragIndicator from '../Icons/IconDragIndicator.vue'
147175
import OptionInputDialog from '../OptionInputDialog.vue'
148176
import AnswerInput from './AnswerInput.vue'
149177
import Question from './Question.vue'
@@ -157,11 +185,14 @@ export default {
157185
components: {
158186
AnswerInput,
159187
Draggable,
188+
IconArrowDown,
189+
IconArrowUp,
160190
IconClose,
161191
IconContentPaste,
162-
IconDragHorizontalVariant,
192+
IconDragIndicator,
163193
NcActionButton,
164194
NcActionCheckbox,
195+
NcActions,
165196
NcButton,
166197
NcLoadingIcon,
167198
OptionInputDialog,
@@ -262,6 +293,32 @@ export default {
262293
this.emitValues()
263294
},
264295
296+
/**
297+
* Move the ranked option at index up by one position
298+
*
299+
* @param {number} index Current index
300+
*/
301+
onMoveUp(index) {
302+
if (index <= 0) return
303+
const items = [...this.rankedOptions]
304+
;[items[index - 1], items[index]] = [items[index], items[index - 1]]
305+
this.rankedOptions = items
306+
this.emitValues()
307+
},
308+
309+
/**
310+
* Move the ranked option at index down by one position
311+
*
312+
* @param {number} index Current index
313+
*/
314+
onMoveDown(index) {
315+
if (index >= this.rankedOptions.length - 1) return
316+
const items = [...this.rankedOptions]
317+
;[items[index], items[index + 1]] = [items[index + 1], items[index]]
318+
this.rankedOptions = items
319+
this.emitValues()
320+
},
321+
265322
/**
266323
* Emit the current ranking after a drag reorder
267324
*/
@@ -353,19 +410,30 @@ export default {
353410
color: var(--color-text-maxcontrast);
354411
}
355412
356-
&__drag-handle {
413+
&__text {
414+
flex: 1;
415+
}
416+
417+
&__actions {
357418
display: flex;
358-
align-items: center;
419+
gap: var(--default-grid-baseline);
420+
margin-inline-start: auto;
421+
}
422+
423+
&__drag-handle {
424+
color: var(--color-text-maxcontrast);
359425
cursor: grab;
360426
427+
&:hover,
428+
&:focus,
429+
&:focus-within {
430+
color: var(--color-main-text);
431+
}
432+
361433
&:active {
362434
cursor: grabbing;
363435
}
364436
}
365-
366-
&__text {
367-
flex: 1;
368-
}
369437
}
370438
371439
.options-list-transition-move,

0 commit comments

Comments
 (0)