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 |
> |
A |
7 |
<!-- TODO find a nice way of not calling markdone when clicking flag on card rather than calling "markDone" twice --> |
e38844
|
8 |
<checkbox v-model="todoItem.completed"/> |
b4180d
|
9 |
|
e38844
|
10 |
<span class="md-list-item-text" :class="{'strike-through': todoItem.completed}">{{ todoItem.title }}</span> |
637b4a
|
11 |
</md-list-item> |
A |
12 |
<md-button class="flag" |
|
13 |
@click="markImportant()" |
b4180d
|
14 |
> |
26aabc
|
15 |
<!-- find a nice way to utilise svg fill property without doing it inline --> |
A |
16 |
<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
|
17 |
</md-button> |
fbee7b
|
18 |
</div> |
a34f1d
|
19 |
</div> |
D |
20 |
</template> |
|
21 |
<script> |
8acdfc
|
22 |
import Vue from "vue"; |
1f415e
|
23 |
import { Checkbox, Radio } from "vue-checkbox-radio"; |
A |
24 |
Vue.component("checkbox", Checkbox); |
|
25 |
Vue.component("radio", Radio); |
8acdfc
|
26 |
|
a34f1d
|
27 |
export default { |
D |
28 |
name: "TodoItem", |
|
29 |
props: { |
|
30 |
// type any object ;) |
|
31 |
todoItem: {} |
|
32 |
}, |
acdeac
|
33 |
data() { |
a34f1d
|
34 |
return { |
0f0a91
|
35 |
// isActive: false, |
A |
36 |
// isImportant: false |
acdeac
|
37 |
}; |
a34f1d
|
38 |
}, |
D |
39 |
methods: { |
ba91cd
|
40 |
markCompleted() { |
D |
41 |
this.$store.dispatch("markTodoCompleted", this.todoItem._id); |
9e628c
|
42 |
console.info("INFO - Mark todo as completed ", this.todoItem.completed); |
b4180d
|
43 |
}, |
A |
44 |
markImportant() { |
9e628c
|
45 |
console.info("INFO - Mark todo as important ", this.todoItem.important); |
26aabc
|
46 |
// this.todoItem.important = !this.todoItem.important; |
ba91cd
|
47 |
// TODO - FILL THIS OUT IN THE LAB EXERCISE |
26aabc
|
48 |
// this.todoItem.important = !this.todoItem.important; |
a34f1d
|
49 |
} |
D |
50 |
} |
|
51 |
}; |
|
52 |
</script> |
|
53 |
|
|
54 |
<!-- Add "scoped" attribute to limit CSS to this component only --> |
|
55 |
<style scoped lang="scss"> |
637b4a
|
56 |
.md-list-item { |
acdeac
|
57 |
width: 320px; |
A |
58 |
max-width: 100%; |
637b4a
|
59 |
height: 50px; |
acdeac
|
60 |
display: inline-block; |
A |
61 |
overflow: auto; |
991fff
|
62 |
} |
A |
63 |
|
8acdfc
|
64 |
.md-list-item-text { |
A |
65 |
padding-left: 0.5em; |
637b4a
|
66 |
} |
A |
67 |
|
|
68 |
.itemCardandFlag { |
|
69 |
display: inline-block; |
8acdfc
|
70 |
} |
A |
71 |
|
a34f1d
|
72 |
.strike-through { |
D |
73 |
text-decoration: line-through; |
b4180d
|
74 |
font-style: italic; |
A |
75 |
} |
|
76 |
|
637b4a
|
77 |
.flag { |
A |
78 |
height: 50px; |
|
79 |
margin: 0px; |
|
80 |
} |
b4180d
|
81 |
.red-flag { |
A |
82 |
fill: #cc0000; |
a34f1d
|
83 |
} |
D |
84 |
</style> |