mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 23:51:25 +00:00
Mark read and unread
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>VMail Inbox</h1>
|
<h1>VMail Inbox</h1>
|
||||||
|
|
||||||
<p>Number selected: {{emailSelection.ids.size}}</p>
|
<p>Number selected: {{emailSelection.emails.size}}</p>
|
||||||
|
<button @click="emailSelection.markRead()">Mark Selected Read</button>
|
||||||
|
<button @click="emailSelection.markUnread()">Mark Selected Unread</button>
|
||||||
|
|
||||||
<MailTable :emails="emails" />
|
<MailTable :emails="emails" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<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>
|
<td>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
:checked="emailSelection.ids.has(email)"
|
:checked="emailSelection.emails.has(email)"
|
||||||
@click="emailSelection.toggle(email)" />
|
@click="emailSelection.toggle(email)" />
|
||||||
</td>
|
</td>
|
||||||
<td>{{email.from}}</td>
|
<td>{{email.from}}</td>
|
||||||
|
|||||||
@@ -5,12 +5,22 @@ export const useEmailSelection = function(){
|
|||||||
|
|
||||||
let emailSelection = reactive({
|
let emailSelection = reactive({
|
||||||
emails: emails,
|
emails: emails,
|
||||||
toggle: function(id) {
|
toggle(id) {
|
||||||
if(this.emails.has(id)) {
|
if(this.emails.has(id)) {
|
||||||
this.emails.delete(id)
|
this.emails.delete(id)
|
||||||
} else {
|
} else {
|
||||||
this.emails.add(id);
|
this.emails.add(id);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
markRead(){
|
||||||
|
this.emails.forEach(email => {
|
||||||
|
email.read = true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
markUnread(){
|
||||||
|
this.emails.forEach(email => {
|
||||||
|
email.read = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user