Delete Submission
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
This commit is contained in:
parent
bb9bca3667
commit
8a96e16413
6 changed files with 84 additions and 6 deletions
|
|
@ -22,9 +22,16 @@
|
|||
|
||||
<template>
|
||||
<div class="table submission section">
|
||||
<h3 class="submission-title">
|
||||
Response by {{ userDisplayName }}
|
||||
</h3>
|
||||
<div class="submission-head">
|
||||
<h3 class="submission-title">
|
||||
Response by {{ userDisplayName }}
|
||||
</h3>
|
||||
<Actions class="submission-menu" :force-menu="true">
|
||||
<ActionButton icon="icon-delete" @click="onDelete">
|
||||
{{ t('forms', 'Delete submission') }}
|
||||
</ActionButton>
|
||||
</Actions>
|
||||
</div>
|
||||
<p class="submission-date">
|
||||
{{ submissionDateTime }}
|
||||
</p>
|
||||
|
|
@ -39,13 +46,18 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import Actions from '@nextcloud/vue/dist/Components/Actions'
|
||||
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
|
||||
import moment from '@nextcloud/moment'
|
||||
|
||||
import Answer from './Answer'
|
||||
|
||||
export default {
|
||||
name: 'Submission',
|
||||
|
||||
components: {
|
||||
Actions,
|
||||
ActionButton,
|
||||
Answer,
|
||||
},
|
||||
|
||||
|
|
@ -73,6 +85,10 @@ export default {
|
|||
questionToAnswer(questionId) {
|
||||
return this.questions.find(question => question.id === questionId)
|
||||
},
|
||||
|
||||
onDelete() {
|
||||
this.$emit('delete')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@
|
|||
v-for="submission in submissions"
|
||||
:key="submission.id"
|
||||
:submission="submission"
|
||||
:questions="questions" />
|
||||
:questions="questions"
|
||||
@delete="deleteSubmission(submission.id)" />
|
||||
|
||||
<!-- <transition-group
|
||||
name="list"
|
||||
|
|
@ -150,6 +151,21 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
async deleteSubmission(id) {
|
||||
this.loadingResults = true
|
||||
|
||||
try {
|
||||
await axios.delete(generateUrl('/apps/forms/api/v1/submission/{id}', { id }))
|
||||
const index = this.submissions.findIndex(search => search.id === id)
|
||||
this.submissions.splice(index, 1)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
showError(t('forms', 'There was an error while removing the submission'))
|
||||
} finally {
|
||||
this.loadingResults = false
|
||||
}
|
||||
},
|
||||
|
||||
/* download() {
|
||||
this.loading = true
|
||||
axios.get(OC.generateUrl('apps/forms/get/form/' + this.$route.params.hash))
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export default {
|
|||
this.loading = true
|
||||
|
||||
try {
|
||||
await axios.post(generateUrl('/apps/forms/api/v1/submissions/insert'), {
|
||||
await axios.post(generateUrl('/apps/forms/api/v1/submission/insert'), {
|
||||
formId: this.form.id,
|
||||
answers: this.answers,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue