File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 2626 -->
2727
2828 < div id ="app ">
29+ < button @click ="toggleTodos "> Toggle todos</ button >
30+ < br />
2931 < input
3032 v-model.trim ="newTodoText "
3133 @keyup.enter ="addTodo "
5557 databaseURL : 'https://vue-fire-store.firebaseio.com'
5658 } )
5759 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 )
5963 const config = db . collection ( 'configs' ) . doc ( 'jORwjIykFo2NmkdzTkhU' )
6064
6165 new Vue ( {
6569 config : null ,
6670 newTodoText : ''
6771 } ,
72+
6873 firestore : {
69- todos : todos . where ( 'finished' , '==' , false ) ,
74+ todos : unFinishedTodos ,
7075 config
7176 } ,
77+
7278 methods : {
7379 addTodo : function ( ) {
7480 if ( this . newTodoText ) {
8591 } ,
8692 removeTodo : function ( todo ) {
8793 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+ )
88103 }
89104 }
90105 } )
You can’t perform that action at this time.
0 commit comments