mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add mutation and query for automatic creations, create, list, delete
This commit is contained in:
parent
92acf44c7d
commit
ac88b08785
@ -43,7 +43,7 @@
|
||||
<!-- Desc -->
|
||||
<b-form-group id="input-group-2" label="Nachricht:">
|
||||
<b-form-textarea
|
||||
v-model="form.text"
|
||||
v-model="form.memo"
|
||||
size="lg"
|
||||
placeholder="Memo"
|
||||
required
|
||||
@ -106,6 +106,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { createAutomaticCreation } from '@/graphql/createAutomaticCreation.js'
|
||||
export default {
|
||||
name: 'AutomaticCreationForm',
|
||||
props: {
|
||||
@ -120,7 +121,7 @@ export default {
|
||||
return {
|
||||
form: {
|
||||
name: null,
|
||||
text: null,
|
||||
memo: null,
|
||||
amount: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
@ -152,11 +153,32 @@ export default {
|
||||
if (this.form.startDate === null) return this.toastError('No start Date')
|
||||
if (this.form.endDate === null) return this.toastError('No end Date')
|
||||
alert(JSON.stringify(this.form))
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: createAutomaticCreation,
|
||||
variables: {
|
||||
startDate: this.form.startDate,
|
||||
endDate: this.form.endDate,
|
||||
name: this.form.name,
|
||||
amount: this.form.amount,
|
||||
memo: this.form.memo,
|
||||
cycle: this.form.cycle,
|
||||
repetition: this.form.repetition,
|
||||
maxAmount: this.form.maxAmount,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.link = result.data.createAutomaticCreation.link
|
||||
this.toastSuccess(this.link)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
onReset(event) {
|
||||
event.preventDefault()
|
||||
this.form.name = null
|
||||
this.form.text = null
|
||||
this.form.memo = null
|
||||
this.form.amount = null
|
||||
this.form.startDate = null
|
||||
this.form.endDate = null
|
||||
|
||||
27
admin/src/graphql/createAutomaticCreation.js
Normal file
27
admin/src/graphql/createAutomaticCreation.js
Normal file
@ -0,0 +1,27 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const createAutomaticCreation = gql`
|
||||
mutation (
|
||||
$startDate: String!
|
||||
$endDate: String!
|
||||
$name: String!
|
||||
$amount: Decimal!
|
||||
$memo: String!
|
||||
$cycle: String
|
||||
$repetition: String
|
||||
$maxAmount: Decimal
|
||||
) {
|
||||
createAutomaticCreation(
|
||||
startDate: $startDate
|
||||
endDate: $endDate
|
||||
name: $name
|
||||
amount: $amount
|
||||
memo: $memo
|
||||
cycle: $cycle
|
||||
repetition: $repetition
|
||||
maxAmount: $maxAmount
|
||||
) {
|
||||
link
|
||||
}
|
||||
}
|
||||
`
|
||||
7
admin/src/graphql/deleteAutomaticCreation.js
Normal file
7
admin/src/graphql/deleteAutomaticCreation.js
Normal file
@ -0,0 +1,7 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const deleteAutomaticCreation = gql`
|
||||
mutation ($id: Int!) {
|
||||
deleteAutomaticCreation(id: $id)
|
||||
}
|
||||
`
|
||||
18
admin/src/graphql/listAutomaticCreations.js
Normal file
18
admin/src/graphql/listAutomaticCreations.js
Normal file
@ -0,0 +1,18 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const listAutomaticCreations = gql`
|
||||
query {
|
||||
listAutomaticCreations {
|
||||
id
|
||||
startDate
|
||||
endDate
|
||||
name
|
||||
memo
|
||||
amount
|
||||
cycle
|
||||
repetition
|
||||
maxAmount
|
||||
link
|
||||
}
|
||||
}
|
||||
`
|
||||
18
admin/src/graphql/showAutomaticCreation.js
Normal file
18
admin/src/graphql/showAutomaticCreation.js
Normal file
@ -0,0 +1,18 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const showAutomaticCreation = gql`
|
||||
query ($id: Int!) {
|
||||
showAutomaticCreation {
|
||||
id
|
||||
startDate
|
||||
endDate
|
||||
name
|
||||
memo
|
||||
amount
|
||||
cycle
|
||||
repetition
|
||||
maxAmount
|
||||
code
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -33,6 +33,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import { getPendingCreations } from '../graphql/getPendingCreations'
|
||||
import { listAutomaticCreations } from '@/graphql/listAutomaticCreations.js'
|
||||
import AutomaticCreation from '../components/AutomaticCreation.vue'
|
||||
|
||||
export default {
|
||||
@ -57,15 +58,18 @@ export default {
|
||||
})
|
||||
},
|
||||
async getAutomaticCreations() {
|
||||
// TODO
|
||||
// this.$apollo
|
||||
// .query({
|
||||
// query: getAutomaticCreations,
|
||||
// fetchPolicy: 'network-only',
|
||||
// })
|
||||
// .then((result) => {
|
||||
//
|
||||
// })
|
||||
this.$apollo
|
||||
.query({
|
||||
query: listAutomaticCreations,
|
||||
fetchPolicy: 'network-only',
|
||||
})
|
||||
.then((result) => {
|
||||
this.toastSuccess('TODO! change this.items')
|
||||
})
|
||||
.catch(() => {
|
||||
this.toastError('listAutomaticCreations has no result, use default data')
|
||||
})
|
||||
|
||||
this.items = [
|
||||
{
|
||||
id: 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user