From b925a6f99142b1d6c871b1aaf20ee20063bd0cd9 Mon Sep 17 00:00:00 2001 From: Jeffrey Biles Date: Sun, 29 Mar 2020 23:52:38 -0700 Subject: [PATCH] clicking the Select All box --- src/components/BulkActionBar.vue | 14 ++++++++++++-- src/composition/useEmailSelection.js | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/BulkActionBar.vue b/src/components/BulkActionBar.vue index 0860ee7..8b1960a 100644 --- a/src/components/BulkActionBar.vue +++ b/src/components/BulkActionBar.vue @@ -2,7 +2,8 @@
+ :class="[partialSelection ? 'partial-check' : '']" + @click="bulkSelect">
@@ -23,10 +24,19 @@ let partialSelection = computed(() => { return numberSelected.value > 0 && !allAreSelected.value; }) + + let bulkSelect = function(){ + if(allAreSelected.value) { + emailSelection.clear(); + } else { + emailSelection.addMultiple(emails) + } + } return { partialSelection, - allAreSelected + allAreSelected, + bulkSelect } }, props: { diff --git a/src/composition/useEmailSelection.js b/src/composition/useEmailSelection.js index de57bba..68ed23c 100644 --- a/src/composition/useEmailSelection.js +++ b/src/composition/useEmailSelection.js @@ -11,6 +11,14 @@ export const useEmailSelection = function(){ this.emails.add(id); } }, + clear(){ + this.emails.clear(); + }, + addMultiple(emails) { + emails.forEach(email => { + this.emails.add(email) + }) + }, }) return { emailSelection }