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
|
<script>
import { fetchPolicies } from '~/lib/graphql';
import CreateForm from '../components/form.vue';
import savedRepliesQuery from '../queries/saved_replies.query.graphql';
import List from '../components/list.vue';
export default {
apollo: {
savedReplies: {
fetchPolicy: fetchPolicies.NETWORK_ONLY,
query: savedRepliesQuery,
update: (r) => r.currentUser?.savedReplies?.nodes,
variables() {
return {
...this.pagination,
};
},
result({ data }) {
const pageInfo = data.currentUser?.savedReplies?.pageInfo;
this.count = data.currentUser?.savedReplies?.count;
if (pageInfo) {
this.pageInfo = pageInfo;
}
},
},
},
components: {
CreateForm,
List,
},
data() {
return {
savedReplies: [],
count: 0,
pageInfo: {},
pagination: {},
};
},
methods: {
refetchSavedReplies() {
this.pagination = {};
this.$apollo.queries.savedReplies.refetch();
},
changePage(pageInfo) {
this.pagination = pageInfo;
},
},
};
</script>
<template>
<div>
<h5 class="gl-mt-0 gl-font-lg">
{{ __('Add new comment template') }}
</h5>
<create-form @saved="refetchSavedReplies" />
<list
:loading="$apollo.queries.savedReplies.loading"
:saved-replies="savedReplies"
:page-info="pageInfo"
:count="count"
@input="changePage"
/>
</div>
</template>
|