-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListSelected.vue
88 lines (81 loc) · 1.85 KB
/
ListSelected.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<template>
<list-window :title="selected_list.name" >
<task-entry v-for="task in tasks" :key="task" :task="task" ></task-entry>
<button class="red_button" @click="deleteList" >Delete</button>
</list-window>
</template>
<script>
import ListWindow from "./ListWindow";
import { baseUrl, listsUri, backendPort, tasksUri } from "../util/apiUtil";
import { mapState } from "vuex";
import TaskEntry from './TaskEntry.vue';
export default {
name: 'list-selected',
data () {
return {
tasks: []
}
},
computed: {
...mapState(['selected_list'])
},
created () {
this.getTasks()
},
methods: {
deleteList: function () {
fetch("http://" + baseUrl + backendPort + listsUri +
"/" + this.selected_list.id, {
method: "DELETE"
})
.then((res) => { return res.json(); })
.then((data) => {
if (data.message.includes("List deleted")) {
this.$store.commit('trigger_fetch_lists')
this.$router.push('/list/create')
console.log("deleted");
}
})
.catch((error) => { console.log(error); });
},
getTasks: function () {
fetch("http://" + baseUrl + backendPort + listsUri +
"/" + this.selected_list.id + tasksUri, {
method: "GET"
})
.then((res) => { return res.json(); })
.then((data) => {
this.tasks = data
console.log("tasks fetched successfully")
})
.catch((error) => { console.log(error); });
}
},
components: {
ListWindow,
TaskEntry
}
}
</script>
TaskEntry<style lang="scss" >
@import "../assets/stylesheets/base";
.red_button {
padding: 5px;
background-color: $warning_red;
color: $secondary_color;
width: 15%;
height: 35px;
font-family: 'Roboto', sans-serif;
font-size: 18px;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
margin-bottom: 15px;
border: none;
outline: none;
}
.red_button:hover {
background-color: $warning_red_dark_1;
}
</style>