File tree Expand file tree Collapse file tree 3 files changed +47
-14
lines changed Expand file tree Collapse file tree 3 files changed +47
-14
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div >
3
+ {{emailSelection.emails.size}}
4
+ </div >
5
+ </template >
6
+
7
+ <script >
8
+ import { useEmailSelection } from ' ../composition/useEmailSelection' ;
9
+
10
+ export default {
11
+ setup (){
12
+ let { emailSelection } = useEmailSelection ();
13
+
14
+ return { emailSelection }
15
+ }
16
+ }
17
+ </script >
18
+
19
+ <style scoped>
20
+
21
+ </style >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<table class =" mail-table" >
3
- {{emailSelection.emails.size}}
3
+ <BulkActionBar />
4
+
4
5
<tbody >
5
6
<tr v-for =" email in unarchivedEmails"
6
7
:key =" email.id"
33
34
import axios from ' axios' ;
34
35
import MailView from ' @/components/MailView.vue' ;
35
36
import ModalView from ' @/components/ModalView.vue' ;
36
- import { reactive } from ' vue' ;
37
+ import BulkActionBar from ' @/components/BulkActionBar.vue' ;
38
+ import { useEmailSelection } from ' ../composition/useEmailSelection' ;
37
39
38
40
export default {
39
41
async setup (){
40
42
let response = await axios .get (' http://localhost:3000/emails' );
41
43
let emails = response .data ;
42
44
let openedEmail = null ;
43
45
44
-
45
- let emailSelection = reactive ({
46
- emails: new Set (),
47
- toggle (id ) {
48
- if (this .emails .has (id)) {
49
- this .emails .delete (id)
50
- } else {
51
- this .emails .add (id);
52
- }
53
- },
54
- })
46
+ let { emailSelection } = useEmailSelection ();
55
47
56
48
return {
57
49
format,
62
54
},
63
55
components: {
64
56
MailView,
65
- ModalView
57
+ ModalView,
58
+ BulkActionBar
66
59
},
67
60
computed: {
68
61
unarchivedEmails (){
Original file line number Diff line number Diff line change
1
+ import { reactive } from 'vue' ;
2
+
3
+ let emails = new Set ( )
4
+ export const useEmailSelection = function ( ) {
5
+ let emailSelection = reactive ( {
6
+ emails : emails ,
7
+ toggle ( id ) {
8
+ if ( this . emails . has ( id ) ) {
9
+ this . emails . delete ( id )
10
+ } else {
11
+ this . emails . add ( id ) ;
12
+ }
13
+ } ,
14
+ } )
15
+
16
+ return { emailSelection }
17
+ }
18
+
19
+ export default useEmailSelection ;
You can’t perform that action at this time.
0 commit comments