mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 07:31:26 +00:00
BulkActionBar
This commit is contained in:
26
src/components/BulkActionBar.vue
Normal file
26
src/components/BulkActionBar.vue
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<div class="bulk-action-bar">
|
||||||
|
<button @click="emailSelection.markRead()">
|
||||||
|
Mark Read
|
||||||
|
</button>
|
||||||
|
<button @click="emailSelection.markUnread()">
|
||||||
|
Mark Unread
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import useEmailSelection from '../composition/useEmailSelection';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup(){
|
||||||
|
let {emailSelection} = useEmailSelection();
|
||||||
|
return { emailSelection }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -1,28 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>VMail Inbox</h1>
|
<h1>VMail Inbox</h1>
|
||||||
|
|
||||||
<p>Number selected: {{emailSelection.emails.size}}</p>
|
<BulkActionBar />
|
||||||
<button @click="emailSelection.markRead()">Mark Selected Read</button>
|
|
||||||
<button @click="emailSelection.markUnread()">Mark Selected Unread</button>
|
|
||||||
|
|
||||||
<MailTable :emails="emails" />
|
<MailTable :emails="emails" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MailTable from '@/components/MailTable.vue';
|
import MailTable from '@/components/MailTable.vue';
|
||||||
import useEmailSelection from '../composition/useEmailSelection';
|
import BulkActionBar from '@/components/BulkActionBar.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async setup(props, {attrs, slots}){
|
async setup(props, {attrs, slots}){
|
||||||
let response = await fetch('/api/emails');
|
let response = await fetch('/api/emails');
|
||||||
let {emails} = await response.json();
|
let {emails} = await response.json();
|
||||||
|
|
||||||
let {emailSelection} = useEmailSelection();
|
return {emails}
|
||||||
|
|
||||||
return {emails, emailSelection}
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MailTable
|
MailTable,
|
||||||
|
BulkActionBar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user