mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 15:41:33 +00:00
Email Selection via checkboxes
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<table class="mail-table">
|
<table class="mail-table">
|
||||||
|
{{emailSelection.emails.size}}
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="email in unarchivedEmails"
|
<tr v-for="email in unarchivedEmails"
|
||||||
:key="email.id"
|
:key="email.id"
|
||||||
:class="[email.read ? 'read': '', 'clickable']"
|
:class="[email.read ? 'read': '', 'clickable']"
|
||||||
@click="openEmail(email)">
|
@click="openEmail(email)">
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" />
|
<input type="checkbox"
|
||||||
|
:checked="emailSelection.emails.has(email)"
|
||||||
|
@click="emailSelection.toggle(email)" />
|
||||||
</td>
|
</td>
|
||||||
<td>{{email.from}}</td>
|
<td>{{email.from}}</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -30,16 +33,31 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import MailView from '@/components/MailView.vue';
|
import MailView from '@/components/MailView.vue';
|
||||||
import ModalView from '@/components/ModalView.vue';
|
import ModalView from '@/components/ModalView.vue';
|
||||||
|
import { reactive } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async setup(){
|
async setup(){
|
||||||
let response = await axios.get('http://localhost:3000/emails');
|
let response = await axios.get('http://localhost:3000/emails');
|
||||||
let emails = response.data;
|
let emails = response.data;
|
||||||
let openedEmail = null;
|
let openedEmail = null;
|
||||||
|
|
||||||
|
|
||||||
|
let emailSelection = reactive({
|
||||||
|
emails: new Set(),
|
||||||
|
toggle(id) {
|
||||||
|
if(this.emails.has(id)) {
|
||||||
|
this.emails.delete(id)
|
||||||
|
} else {
|
||||||
|
this.emails.add(id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
format,
|
format,
|
||||||
emails,
|
emails,
|
||||||
openedEmail
|
openedEmail,
|
||||||
|
emailSelection
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|||||||
Reference in New Issue
Block a user