Skip to content

Commit ea22275

Browse files
author
Jeffrey Biles
committed
Select All checkbox reflects state of email selection
1 parent 19c0f6d commit ea22275

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/components/BulkActionBar.vue

+27-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
11
<template>
22
<div>
3-
{{emailSelection.emails.size}}
3+
<input type="checkbox"
4+
:checked="allAreSelected"
5+
:class="[partialSelection ? 'partial-check' : '']">
46
</div>
57
</template>
68

79
<script>
810
import { useEmailSelection } from '../composition/useEmailSelection';
11+
import { computed } from 'vue';
912
1013
export default {
11-
setup(){
14+
setup({emails}){
1215
let { emailSelection } = useEmailSelection();
13-
14-
return { emailSelection }
15-
}
16+
17+
let numberSelected = computed(() => {
18+
return emailSelection.emails.size;
19+
})
20+
let allAreSelected = computed(() => {
21+
return emails.length == numberSelected.value;
22+
})
23+
let partialSelection = computed(() => {
24+
return numberSelected.value > 0 && !allAreSelected.value;
25+
})
26+
27+
return {
28+
partialSelection,
29+
allAreSelected
30+
}
31+
},
32+
props: {
33+
emails: {
34+
type: Array,
35+
required: true
36+
}
37+
}
1638
}
1739
</script>
1840

src/components/MailTable.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<table class="mail-table">
3-
<BulkActionBar />
3+
<BulkActionBar :emails="unarchivedEmails" />
44

55
<tbody>
66
<tr v-for="email in unarchivedEmails"

0 commit comments

Comments
 (0)