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

View File

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

View File

@ -95,7 +95,6 @@
type="singleCreation" type="singleCreation"
:item="row.item" :item="row.item"
:row="row" :row="row"
:creation="getOpenCreations(row.item.userId)"
:creationUserData="creationUserData" :creationUserData="creationUserData"
@update-creation-data="updateCreationData" @update-creation-data="updateCreationData"
/> />
@ -119,7 +118,6 @@ import { toggleRowDetails } from '../../mixins/toggleRowDetails'
import RowDetails from '../RowDetails' import RowDetails from '../RowDetails'
import EditCreationFormular from '../EditCreationFormular' import EditCreationFormular from '../EditCreationFormular'
import ContributionMessagesList from '../ContributionMessages/ContributionMessagesList' import ContributionMessagesList from '../ContributionMessages/ContributionMessagesList'
import { openCreations } from '../../graphql/openCreations'
const iconMap = { const iconMap = {
IN_PROGRESS: 'question-square', IN_PROGRESS: 'question-square',
@ -188,22 +186,6 @@ export default {
updateState(id) { updateState(id) {
this.$emit('update-state', 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> </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 = { export const creationMonths = {
props: { data() {
creation: { return {
type: Array, creation: [1000, 1000, 1000],
default: () => [1000, 1000, 1000], userId: 0,
}, }
}, },
computed: { computed: {
creationDates() { creationDates() {
@ -38,4 +40,23 @@ export const creationMonths = {
return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ') 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)
},
},
},
} }