Skip to content

Commit

Permalink
Merge pull request #10172 from nextcloud/backport/10165/stable3.7
Browse files Browse the repository at this point in the history
[stable3.7] fix: select multiple envelopes by holding shift directly
  • Loading branch information
ChristophWurst authored Sep 18, 2024
2 parents 3402b5f + 5aec041 commit 15fe30f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/components/Envelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
:name="addresses"
:details="formatted()"
:one-line="oneLineLayout"
@click="onClick"
@click.ctrl.prevent="toggleSelected"
@click.exact="onClick"
@click.ctrl.exact.prevent="toggleSelected"
@click.shift.exact.prevent="onSelectMultiple"
@update:menuOpen="closeMoreAndSnoozeOptions">
<template #icon>
<Star v-if="data.flags.flagged"
Expand Down Expand Up @@ -47,7 +48,7 @@
:checked="selected">
<label :for="`select-checkbox-${data.uid}`"
@click.exact.prevent="toggleSelected"
@click.shift.prevent="onSelectMultiple" />
@click.shift.exact.prevent="onSelectMultiple" />
</p>
</div>
</template>
Expand Down
24 changes: 21 additions & 3 deletions src/components/EnvelopeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,15 @@ export default {
this.setEnvelopeSelected(envelope, selected)
},
onEnvelopeSelectMultiple(envelope, index) {
if (this.lastToggledIndex === undefined) {
const lastToggledIndex = this.lastToggledIndex
?? this.findSelectionIndex(parseInt(this.$route.params.threadId))
?? undefined
if (lastToggledIndex === undefined) {
return
}
const start = Math.min(this.lastToggledIndex, index)
const end = Math.max(this.lastToggledIndex, index)
const start = Math.min(lastToggledIndex, index)
const end = Math.max(lastToggledIndex, index)
const selected = this.selection.includes(envelope.databaseId)
for (let i = start; i <= end; i++) {
this.setEnvelopeSelected(this.sortedEnvelops[i], !selected)
Expand Down Expand Up @@ -581,6 +584,21 @@ export default {
this.showMoveModal = false
this.unselectAll()
},
/**
* Find the envelope list index of a given envelope's database id.
*
* @param {int} databaseId
* @return {int|undefined} Index or undefined if not found in the envelope list
*/
findSelectionIndex(databaseId) {
for (const [index, envelope] of this.sortedEnvelops.entries()) {
if (envelope.databaseId === databaseId) {
return index
}
}
return undefined
},
},
}
</script>
Expand Down

0 comments on commit 15fe30f

Please sign in to comment.