Select All checkbox reflects state of email selection

This commit is contained in:
Jeffrey Biles
2020-03-29 23:45:33 -07:00
parent 19c0f6d212
commit ea22275726
2 changed files with 28 additions and 6 deletions

View File

@@ -1,18 +1,40 @@
<template>
<div>
{{emailSelection.emails.size}}
<input type="checkbox"
:checked="allAreSelected"
:class="[partialSelection ? 'partial-check' : '']">
</div>
</template>
<script>
import { useEmailSelection } from '../composition/useEmailSelection';
import { computed } from 'vue';
export default {
setup(){
setup({emails}){
let { emailSelection } = useEmailSelection();
return { emailSelection }
}
let numberSelected = computed(() => {
return emailSelection.emails.size;
})
let allAreSelected = computed(() => {
return emails.length == numberSelected.value;
})
let partialSelection = computed(() => {
return numberSelected.value > 0 && !allAreSelected.value;
})
return {
partialSelection,
allAreSelected
}
},
props: {
emails: {
type: Array,
required: true
}
}
}
</script>

View File

@@ -1,6 +1,6 @@
<template>
<table class="mail-table">
<BulkActionBar />
<BulkActionBar :emails="unarchivedEmails" />
<tbody>
<tr v-for="email in unarchivedEmails"