mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 15:41:33 +00:00
clicking the Select All box
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
:checked="allAreSelected"
|
:checked="allAreSelected"
|
||||||
:class="[partialSelection ? 'partial-check' : '']">
|
:class="[partialSelection ? 'partial-check' : '']"
|
||||||
|
@click="bulkSelect">
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -23,10 +24,19 @@
|
|||||||
let partialSelection = computed(() => {
|
let partialSelection = computed(() => {
|
||||||
return numberSelected.value > 0 && !allAreSelected.value;
|
return numberSelected.value > 0 && !allAreSelected.value;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let bulkSelect = function(){
|
||||||
|
if(allAreSelected.value) {
|
||||||
|
emailSelection.clear();
|
||||||
|
} else {
|
||||||
|
emailSelection.addMultiple(emails)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
partialSelection,
|
partialSelection,
|
||||||
allAreSelected
|
allAreSelected,
|
||||||
|
bulkSelect
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ export const useEmailSelection = function(){
|
|||||||
this.emails.add(id);
|
this.emails.add(id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clear(){
|
||||||
|
this.emails.clear();
|
||||||
|
},
|
||||||
|
addMultiple(emails) {
|
||||||
|
emails.forEach(email => {
|
||||||
|
this.emails.add(email)
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return { emailSelection }
|
return { emailSelection }
|
||||||
|
|||||||
Reference in New Issue
Block a user