mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-20 14:25:14 +00:00
Select All checkbox reflects state of email selection
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<table class="mail-table">
|
||||
<BulkActionBar />
|
||||
<BulkActionBar :emails="unarchivedEmails" />
|
||||
|
||||
<tbody>
|
||||
<tr v-for="email in unarchivedEmails"
|
||||
|
||||
Reference in New Issue
Block a user