-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToDoItemsList.vue
83 lines (75 loc) · 1.67 KB
/
ToDoItemsList.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
<template>
<div class="items-list">
<div v-if="items.length">
<div v-for="item in items" :key="item.id">
<ToDoCard :item="item"
:onStatusToggle="loadItems"
@deletedItem = "deletedItem" />
</div>
</div>
<p v-else-if="!isLoading">No items found!</p>
<BLoading :is-full-page="true" :active.sync="isLoading" />
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop } from "vue-property-decorator";
import ToDoCard from "@/components/ToDoCard.vue";
import gql from "graphql-tag";
@Component({
components: {
ToDoCard
}
})
export default class ToDoItemsList extends Vue {
@Prop({ required: true }) filters: any;
items = [];
isLoading = false;
mounted() {
this.loadItems();
}
deletedItem(e: ToDoCard)
{
this.$emit('handleDeletedItem', e);
}
//reload()
//{
// this.$forceUpdate();
//}
loadItems() {
this.isLoading = true;
this.$apollo
.query({
query: gql`
query($filters: ToDoItemFilterInput) {
toDoItems(
order: [{priority:ASC}, {createdDate:DESC}]
where: $filters
) {
nodes {
content
createdDate
id
status
priority
}
}
}
`,
variables: {
filters: this.filters
},
fetchPolicy: "network-only"
})
.then(
({
data: {
toDoItems: { nodes: items }
}
}) => {
this.items = items;
}
)
.finally(() => (this.isLoading = false));
}
}
</script>