File tree Expand file tree Collapse file tree 3 files changed +54
-28
lines changed Expand file tree Collapse file tree 3 files changed +54
-28
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
- <div id =" app" >
3
- <h1 >VMail Inbox</h1 >
4
-
2
+ <div id =" app" >
5
3
<Suspense >
6
4
<template #default >
7
- <MailTable />
5
+ <MailScreen />
8
6
</template >
9
7
<template #fallback >
10
8
Loading...
14
12
</template >
15
13
16
14
<script >
17
- import MailTable from ' @/components/MailTable .vue' ;
15
+ import MailScreen from ' @/components/MailScreen .vue' ;
18
16
19
17
export default {
20
18
name: ' App' ,
21
19
components: {
22
- MailTable
20
+ MailScreen
23
21
}
24
22
};
25
23
</script >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <h1 >VMail Inbox</h1 >
3
+
4
+ <BulkActionBar :emails =" unarchivedEmails" />
5
+
6
+ <MailTable :emails =" unarchivedEmails" />
7
+ </template >
8
+
9
+ <script >
10
+ import axios from ' axios' ;
11
+
12
+ import MailTable from ' @/components/MailTable.vue' ;
13
+ import BulkActionBar from ' @/components/BulkActionBar.vue' ;
14
+
15
+ export default {
16
+ async setup (){
17
+ let response = await axios .get (' http://localhost:3000/emails' );
18
+ let emails = response .data ;
19
+
20
+ return { emails }
21
+ },
22
+ components: {
23
+ BulkActionBar,
24
+ MailTable
25
+ },
26
+ computed: {
27
+ sortedEmails (){
28
+ return this .emails .sort ((e1 , e2 ) => {
29
+ return e1 .sentAt < e2 .sentAt ? 1 : - 1
30
+ })
31
+ },
32
+ unarchivedEmails (){
33
+ return this .sortedEmails .filter (e => ! e .archived )
34
+ },
35
+ }
36
+ }
37
+ </script >
38
+
39
+ <style scoped>
40
+
41
+ </style >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <BulkActionBar :emails =" unarchivedEmails" />
3
2
<table class =" mail-table" >
4
3
<tbody >
5
- <tr v-for =" email in unarchivedEmails "
4
+ <tr v-for =" email in emails "
6
5
:key =" email.id"
7
6
:class =" [email.read ? 'read': '', 'clickable']"
8
7
@click =" openEmail(email)" >
30
29
31
30
<script >
32
31
import { format } from ' date-fns' ;
33
- import axios from ' axios' ;
34
32
import MailView from ' @/components/MailView.vue' ;
35
33
import ModalView from ' @/components/ModalView.vue' ;
36
- import BulkActionBar from ' @/components/BulkActionBar.vue' ;
37
34
import { useEmailSelection } from ' ../composition/useEmailSelection' ;
38
35
39
36
export default {
40
37
async setup (){
41
- let response = await axios .get (' http://localhost:3000/emails' );
42
- let emails = response .data ;
43
38
let openedEmail = null ;
44
-
45
39
let { emailSelection } = useEmailSelection ();
46
40
47
41
return {
48
42
format,
49
- emails,
50
43
openedEmail,
51
44
emailSelection
52
45
}
53
46
},
54
47
components: {
55
48
MailView,
56
49
ModalView,
57
- BulkActionBar
58
- },
59
- computed: {
60
- unarchivedEmails (){
61
- return this .sortedEmails .filter (e => ! e .archived )
62
- },
63
- sortedEmails (){
64
- return this .emails .sort ((e1 , e2 ) => {
65
- return e1 .sentAt < e2 .sentAt ? 1 : - 1
66
- })
67
- }
68
50
},
69
51
methods: {
70
52
openEmail (email ){
86
68
if (closeModal) { this .openedEmail = null ; return null ; }
87
69
88
70
if (indexChange) {
89
- let emails = this .unarchivedEmails
90
- let index = emails .findIndex (e => e == email);
91
- this .openEmail (emails[index + indexChange])
71
+ let index = this .emails .findIndex (e => e == email);
72
+ this .openEmail (this .emails [index + indexChange])
92
73
}
93
74
}
75
+ },
76
+ props: {
77
+ emails: {
78
+ type: Array ,
79
+ required: true
80
+ }
94
81
}
95
82
}
96
83
</script >
You can’t perform that action at this time.
0 commit comments