mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 23:51:25 +00:00
Select All checkbox reflects state of email selection
This commit is contained in:
@@ -1,17 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
{{emailSelection.emails.size}}
|
<input type="checkbox"
|
||||||
|
:checked="allAreSelected"
|
||||||
|
:class="[partialSelection ? 'partial-check' : '']">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { useEmailSelection } from '../composition/useEmailSelection';
|
import { useEmailSelection } from '../composition/useEmailSelection';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(){
|
setup({emails}){
|
||||||
let { emailSelection } = useEmailSelection();
|
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>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<table class="mail-table">
|
<table class="mail-table">
|
||||||
<BulkActionBar />
|
<BulkActionBar :emails="unarchivedEmails" />
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="email in unarchivedEmails"
|
<tr v-for="email in unarchivedEmails"
|
||||||
|
|||||||
Reference in New Issue
Block a user