Start of lesson 14 (rebase into next commit)

This commit is contained in:
Jeffrey Biles
2020-08-18 00:05:08 -07:00
parent f3d4354735
commit aa1479f51a
3 changed files with 23 additions and 9 deletions

View File

@@ -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 />

View File

@@ -1,9 +1,16 @@
<template> <template>
<div> <div class="bulk-action-bar">
<span class="checkbox">
<input type="checkbox" <input type="checkbox"
:checked="allEmailsSelected" :checked="allEmailsSelected"
:class="[someEmailsSelected ? 'partial-check' : '']" :class="[someEmailsSelected ? 'partial-check' : '']"
@click="bulkSelect" /> @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: {

View File

@@ -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
} }
} }