2023-04-23 21:23:45 +05:30
|
|
|
<script>
|
2023-05-27 22:25:52 +05:30
|
|
|
import { fetchPolicies } from '~/lib/graphql';
|
|
|
|
import CreateForm from '../components/form.vue';
|
|
|
|
import savedRepliesQuery from '../queries/saved_replies.query.graphql';
|
2023-04-23 21:23:45 +05:30
|
|
|
import List from '../components/list.vue';
|
|
|
|
|
|
|
|
export default {
|
2023-05-27 22:25:52 +05:30
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-04-23 21:23:45 +05:30
|
|
|
components: {
|
2023-05-27 22:25:52 +05:30
|
|
|
CreateForm,
|
2023-04-23 21:23:45 +05:30
|
|
|
List,
|
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
savedReplies: [],
|
|
|
|
count: 0,
|
|
|
|
pageInfo: {},
|
|
|
|
pagination: {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
refetchSavedReplies() {
|
|
|
|
this.pagination = {};
|
|
|
|
this.$apollo.queries.savedReplies.refetch();
|
|
|
|
},
|
|
|
|
changePage(pageInfo) {
|
|
|
|
this.pagination = pageInfo;
|
|
|
|
},
|
|
|
|
},
|
2023-04-23 21:23:45 +05:30
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2023-05-27 22:25:52 +05:30
|
|
|
<h5 class="gl-mt-0 gl-font-lg">
|
|
|
|
{{ __('Add new saved reply') }}
|
|
|
|
</h5>
|
|
|
|
<create-form @saved="refetchSavedReplies" />
|
|
|
|
<list
|
|
|
|
:loading="$apollo.queries.savedReplies.loading"
|
|
|
|
:saved-replies="savedReplies"
|
|
|
|
:page-info="pageInfo"
|
|
|
|
:count="count"
|
|
|
|
@input="changePage"
|
|
|
|
/>
|
2023-04-23 21:23:45 +05:30
|
|
|
</div>
|
|
|
|
</template>
|