rename addToSelectedEmail to toggleEmailSelection

This commit is contained in:
Jeffrey Biles
2020-03-17 22:14:52 -07:00
parent d594a9fdd1
commit 67d539fd03

View File

@@ -6,9 +6,11 @@
</thead> </thead>
<tbody> <tbody>
<tr v-for="email in emails" :key="email.id" :class="[email.read ? 'read' : '']"> <tr v-for="email in emails" :key="email.id" :class="[email.read ? 'read' : '']">
<td><input type="checkbox" <td>
<input type="checkbox"
:checked="selectedEmailIds.has(email.id)" :checked="selectedEmailIds.has(email.id)"
@click="addToSelectedEmails(email.id)" /></td> @click="toggleEmailSelection(email.id)" />
</td>
<td>{{email.from}}</td> <td>{{email.from}}</td>
<td> <td>
<p><strong>{{email.subject}}</strong> - {{email.body}}</p> <p><strong>{{email.subject}}</strong> - {{email.body}}</p>
@@ -25,14 +27,14 @@
export default { export default {
setup(){ setup(){
let selectedEmailIds = ref(new Set(['1', '5'])) let selectedEmailIds = ref(new Set(['1', '5']))
let addToSelectedEmails = (id) => { let toggleEmailSelection = (id) => {
if(selectedEmailIds.value.has(id)) { if(selectedEmailIds.value.has(id)) {
selectedEmailIds.value.delete(id) selectedEmailIds.value.delete(id)
} else { } else {
selectedEmailIds.value.add(id); selectedEmailIds.value.add(id);
} }
} }
return {format, selectedEmailIds, addToSelectedEmails} return {format, selectedEmailIds, toggleEmailSelection}
}, },
props: { props: {
emails: { emails: {