From 2d4f7f9fd5bd7be5340f2fbb99c292bc00f2dcb8 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 11 Jan 2023 20:15:02 +0100 Subject: [PATCH] get open creations via own apollo call --- frontend/src/graphql/queries.js | 10 ++++++++++ frontend/src/pages/Community.vue | 33 +++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index db6a68bf4..65fde8d1d 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -250,3 +250,13 @@ export const listContributionMessages = gql` } } ` + +export const openCreations = gql` + query { + openCreations { + year + month + amount + } + } +` diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 16af01ce3..29173921f 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -52,7 +52,12 @@ import OpenCreationsAmount from '@/components/Contributions/OpenCreationsAmount. import ContributionForm from '@/components/Contributions/ContributionForm.vue' import ContributionList from '@/components/Contributions/ContributionList.vue' import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations' -import { listContributions, listAllContributions, verifyLogin } from '@/graphql/queries' +import { + listContributions, + listAllContributions, + verifyLogin, + openCreations, +} from '@/graphql/queries' export default { name: 'Community', @@ -82,6 +87,7 @@ export default { }, updateAmount: '', maximalDate: new Date(), + openCreations: [], } }, mounted() { @@ -90,6 +96,23 @@ export default { this.hashLink = this.$route.hash }) }, + apollo: { + OpenCreations: { + query() { + return openCreations + }, + fetchPolicy: 'network-only', + variables() { + return {} + }, + update({ openCreations }) { + this.openCreations = openCreations + }, + error({ message }) { + this.toastError(message) + }, + }, + }, watch: { $route(to, from) { this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === to.hash) @@ -123,14 +146,14 @@ export default { maxGddLastMonth() { // when existing contribution is edited, the amount is added back on top of the amount return this.form.id && !this.isThisMonth - ? parseInt(this.$store.state.creation[1]) + parseInt(this.updateAmount) - : parseInt(this.$store.state.creation[1]) + ? parseInt(this.openCreations[1].amount) + parseInt(this.updateAmount) + : parseInt(this.openCreations[1].amount) }, maxGddThisMonth() { // when existing contribution is edited, the amount is added back on top of the amount return this.form.id && this.isThisMonth - ? parseInt(this.$store.state.creation[2]) + parseInt(this.updateAmount) - : parseInt(this.$store.state.creation[2]) + ? parseInt(this.openCreations[2].amount) + parseInt(this.updateAmount) + : parseInt(this.openCreations[2].amount) }, }, methods: {