acammies
2018-04-10 b03f9891b5719cd470c93f785c52855fc06362dd
commit | author | age
a34f1d 1 <template>
D 2   <div>
fbee7b 3     <div class="itemCardAndFlag">
3f23cc 4     <md-list-item
26aabc 5       @click="markCompleted()"
3f23cc 6       >
b03f98 7       <checkbox v-model="todoItem.completed" class="checkbox-completed"/> 
b4180d 8
e38844 9       <span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span>
637b4a 10     </md-list-item>
A 11       <md-button class="flag"
12         @click="markImportant()"
b4180d 13         >
b03f98 14         <!-- find a nice way to utilise svg fill property without doing it all inline -->
26aabc 15         <svg :class="{'red-flag': todoItem.important}"  height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" ><path d="M0 0h24v24H0z" fill="none"/><path d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg>
b4180d 16       </md-button>
fbee7b 17     </div>
a34f1d 18   </div>
D 19 </template>
20 <script>
8acdfc 21 import Vue from "vue";
1f415e 22 import { Checkbox, Radio } from "vue-checkbox-radio";
A 23 Vue.component("checkbox", Checkbox);
24 Vue.component("radio", Radio);
8acdfc 25
a34f1d 26 export default {
D 27   name: "TodoItem",
28   props: {
29     // type any object ;)
30     todoItem: {}
31   },
32   methods: {
ba91cd 33     markCompleted() {
D 34       this.$store.dispatch("markTodoCompleted", this.todoItem._id);
9e628c 35       console.info("INFO - Mark todo as completed ", this.todoItem.completed);
b4180d 36     },
A 37     markImportant() {
9e628c 38       console.info("INFO - Mark todo as important ", this.todoItem.important);
ba91cd 39       // TODO - FILL THIS OUT IN THE LAB EXERCISE
26aabc 40       // this.todoItem.important = !this.todoItem.important;
a34f1d 41     }
D 42   }
43 };
44 </script>
45
46 <!-- Add "scoped" attribute to limit CSS to this component only -->
47 <style scoped lang="scss">
637b4a 48 .md-list-item {
acdeac 49   width: 320px;
A 50   max-width: 100%;
637b4a 51   height: 50px;
acdeac 52   display: inline-block;
A 53   overflow: auto;
991fff 54 }
A 55
8acdfc 56 .md-list-item-text {
A 57   padding-left: 0.5em;
637b4a 58 }
A 59
60 .itemCardandFlag {
61   display: inline-block;
8acdfc 62 }
A 63
a34f1d 64 .strike-through {
D 65   text-decoration: line-through;
b4180d 66   font-style: italic;
A 67 }
68
637b4a 69 .flag {
A 70   height: 50px;
71   margin: 0px;
72 }
b4180d 73 .red-flag {
A 74   fill: #cc0000;
a34f1d 75 }
D 76 </style>