mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 15:41:33 +00:00
Start of lesson 14 (rebase into next commit)
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>VMail Inbox</h1>
|
<h1>VMail Inbox</h1>
|
||||||
|
|
||||||
<h1>{{emailSelection.emails.size}} emails selected</h1>
|
|
||||||
|
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<template #default>
|
<template #default>
|
||||||
<MailTable />
|
<MailTable />
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="bulk-action-bar">
|
||||||
<input type="checkbox"
|
<span class="checkbox">
|
||||||
:checked="allEmailsSelected"
|
<input type="checkbox"
|
||||||
:class="[someEmailsSelected ? 'partial-check' : '']"
|
:checked="allEmailsSelected"
|
||||||
@click="bulkSelect" />
|
:class="[someEmailsSelected ? 'partial-check' : '']"
|
||||||
|
@click="bulkSelect" />
|
||||||
|
</span>
|
||||||
|
<span class="buttons">
|
||||||
|
<button @click="emailSelection.markRead">Mark Read</button>
|
||||||
|
<button @click="emailSelection.markUnread()">Mark Unread</button>
|
||||||
|
<button @click="emailSelection.archive()">Archive</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -29,7 +36,8 @@
|
|||||||
return {
|
return {
|
||||||
allEmailsSelected,
|
allEmailsSelected,
|
||||||
someEmailsSelected,
|
someEmailsSelected,
|
||||||
bulkSelect
|
bulkSelect,
|
||||||
|
emailSelection
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
let emails = reactive(new Set())
|
let emails = reactive(new Set())
|
||||||
|
|
||||||
@@ -18,12 +19,19 @@ export const useEmailSelection = function(){
|
|||||||
emails.add(email)
|
emails.add(email)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
let markRead = () => {
|
||||||
|
emails.forEach((email) => {
|
||||||
|
email.read = true;
|
||||||
|
axios.put(`http://localhost:3000/emails/${email.id}`, email)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
emails,
|
emails,
|
||||||
toggle,
|
toggle,
|
||||||
clear,
|
clear,
|
||||||
addMultiple
|
addMultiple,
|
||||||
|
markRead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user