File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 26
26
-->
27
27
28
28
< div id ="app ">
29
+ < button @click ="toggleTodos "> Toggle todos</ button >
30
+ < br />
29
31
< input
30
32
v-model.trim ="newTodoText "
31
33
@keyup.enter ="addTodo "
55
57
databaseURL : 'https://vue-fire-store.firebaseio.com'
56
58
} )
57
59
const db = firebase . firestore ( )
58
- var todos = db . collection ( 'todos' )
60
+ const todos = db . collection ( 'todos' )
61
+ const unFinishedTodos = todos . where ( 'finished' , '==' , false )
62
+ const finishedTodos = todos . where ( 'finished' , '==' , true )
59
63
const config = db . collection ( 'configs' ) . doc ( 'jORwjIykFo2NmkdzTkhU' )
60
64
61
65
new Vue ( {
65
69
config : null ,
66
70
newTodoText : ''
67
71
} ,
72
+
68
73
firestore : {
69
- todos : todos . where ( 'finished' , '==' , false ) ,
74
+ todos : unFinishedTodos ,
70
75
config
71
76
} ,
77
+
72
78
methods : {
73
79
addTodo : function ( ) {
74
80
if ( this . newTodoText ) {
85
91
} ,
86
92
removeTodo : function ( todo ) {
87
93
todos . doc ( todo . id ) . delete ( )
94
+ } ,
95
+ toggleTodos ( ) {
96
+ console . log ( this . $firestoreRefs . todos === unFinishedTodos )
97
+ this . $bind (
98
+ 'todos' ,
99
+ this . $firestoreRefs . todos === unFinishedTodos
100
+ ? finishedTodos
101
+ : unFinishedTodos
102
+ )
88
103
}
89
104
}
90
105
} )
You can’t perform that action at this time.
0 commit comments