get it working again

This commit is contained in:
Moriz Wahl 2023-03-10 12:48:27 +01:00
parent b9338e62a0
commit e07da27414
6 changed files with 50 additions and 47 deletions

View File

@ -117,10 +117,6 @@ export default {
return {}
},
},
creation: {
type: Array,
required: true,
},
},
data() {
return {
@ -129,6 +125,7 @@ export default {
rangeMin: 0,
rangeMax: 1000,
selected: '',
userId: this.item.userId,
}
},
methods: {
@ -167,6 +164,10 @@ export default {
this.$refs.creationForm.reset()
this.value = 0
})
.finally(() => {
this.$apollo.queries.OpenCreations.refetch()
this.selected = ''
})
},
},
watch: {

View File

@ -75,7 +75,6 @@
</template>
<script>
import { adminUpdateContribution } from '../graphql/adminUpdateContribution'
import { openCreations } from '../graphql/openCreations'
import { creationMonths } from '../mixins/creationMonths'
export default {
@ -97,16 +96,14 @@ export default {
type: Object,
required: true,
},
creation: {
type: Array,
default: () => [1000, 1000, 1000],
},
},
data() {
return {
text: !this.creationUserData.memo ? '' : this.creationUserData.memo,
value: !this.creationUserData.amount ? 0 : Number(this.creationUserData.amount),
rangeMin: 0,
selected: this.selectedComputed,
userId: this.item.userId,
}
},
methods: {
@ -146,6 +143,9 @@ export default {
// Den geschöpften Wert auf o setzen
this.value = 0
})
.finally(() => {
this.$apollo.queries.OpenCreations.refetch()
})
},
},
computed: {
@ -153,17 +153,16 @@ export default {
const month = this.$d(new Date(this.item.contributionDate), 'month')
return this.radioOptions.findIndex((obj) => obj.item.short === month)
},
selected() {
selectedComputed() {
return this.radioOptions[this.creationIndex].item
},
rangeMax() {
console.log('index', this.creationIndex, this.creation[this.creationIndex])
return Number(this.creation[this.creationIndex]) + Number(this.item.amount)
},
},
watch: {
creation() {
console.log('watch', this.creation)
selectedComputed() {
this.selected = this.selectedComputed
},
},
}

View File

@ -95,7 +95,6 @@
type="singleCreation"
:item="row.item"
:row="row"
:creation="getOpenCreations(row.item.userId)"
:creationUserData="creationUserData"
@update-creation-data="updateCreationData"
/>
@ -119,7 +118,6 @@ import { toggleRowDetails } from '../../mixins/toggleRowDetails'
import RowDetails from '../RowDetails'
import EditCreationFormular from '../EditCreationFormular'
import ContributionMessagesList from '../ContributionMessages/ContributionMessagesList'
import { openCreations } from '../../graphql/openCreations'
const iconMap = {
IN_PROGRESS: 'question-square',
@ -188,22 +186,6 @@ export default {
updateState(id) {
this.$emit('update-state', id)
},
getOpenCreations(userId) {
this.$apollo
.query({
query: openCreations,
variables: {
userId,
},
})
.then(({ data: { openCreations } }) => {
console.log(openCreations.map((obj) => obj.amount))
return openCreations.map((obj) => obj.amount)
})
.catch((error) => {
console.log(error)
})
},
},
}
</script>

View File

@ -0,0 +1,11 @@
import gql from 'graphql-tag'
export const adminOpenCreations = gql`
query ($userId: Int!) {
adminOpenCreations(userId: $userId) {
year
month
amount
}
}
`

View File

@ -1,11 +0,0 @@
import gql from 'graphql-tag'
export const openCreations = gql`
query ($userId: Int) {
openCreations(userId: $userId) {
year
month
amount
}
}
`

View File

@ -1,9 +1,11 @@
import { adminOpenCreations } from '../graphql/adminOpenCreations'
export const creationMonths = {
props: {
creation: {
type: Array,
default: () => [1000, 1000, 1000],
},
data() {
return {
creation: [1000, 1000, 1000],
userId: 0,
}
},
computed: {
creationDates() {
@ -38,4 +40,23 @@ export const creationMonths = {
return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ')
},
},
apollo: {
OpenCreations: {
query() {
return adminOpenCreations
},
variables() {
return {
userId: this.userId,
}
},
fetchPolicy: 'no-cache',
update({ adminOpenCreations }) {
this.creation = adminOpenCreations.map((obj) => obj.amount)
},
error({ message }) {
this.toastError(message)
},
},
},
}