2023-12-09 15:47:03 +01:00
|
|
|
<template>
|
2025-02-17 11:27:58 +01:00
|
|
|
<UButtonGroup
|
|
|
|
|
size="xs"
|
|
|
|
|
orientation="horizontal"
|
|
|
|
|
>
|
2025-02-12 13:48:06 +01:00
|
|
|
<UButton
|
2025-05-15 16:24:11 +02:00
|
|
|
v-track.edit_record_click
|
2025-02-12 13:48:06 +01:00
|
|
|
size="sm"
|
|
|
|
|
color="white"
|
|
|
|
|
icon="heroicons:pencil-square"
|
2024-04-15 19:39:03 +02:00
|
|
|
@click="showEditSubmissionModal = true"
|
2025-02-12 13:48:06 +01:00
|
|
|
/>
|
|
|
|
|
<UButton
|
2024-04-15 19:39:03 +02:00
|
|
|
v-track.delete_record_click
|
2025-02-12 13:48:06 +01:00
|
|
|
size="sm"
|
|
|
|
|
color="white"
|
|
|
|
|
icon="heroicons:trash"
|
2024-04-15 19:39:03 +02:00
|
|
|
@click="onDeleteClick"
|
2025-02-12 13:48:06 +01:00
|
|
|
/>
|
|
|
|
|
</UButtonGroup>
|
2024-04-15 19:39:03 +02:00
|
|
|
<EditSubmissionModal
|
|
|
|
|
:show="showEditSubmissionModal"
|
|
|
|
|
:form="form"
|
|
|
|
|
:submission="submission"
|
|
|
|
|
@close="showEditSubmissionModal = false"
|
|
|
|
|
@updated="(submission) => $emit('updated', submission)"
|
|
|
|
|
/>
|
2023-12-09 15:47:03 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-04-15 19:39:03 +02:00
|
|
|
import EditSubmissionModal from "./EditSubmissionModal.vue"
|
2023-12-09 15:47:03 +01:00
|
|
|
|
|
|
|
|
export default {
|
2024-02-03 12:50:57 +01:00
|
|
|
components: { EditSubmissionModal },
|
2023-12-09 15:47:03 +01:00
|
|
|
props: {
|
|
|
|
|
form: {
|
|
|
|
|
type: Object,
|
2024-04-15 19:39:03 +02:00
|
|
|
required: true,
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
|
|
|
|
structure: {
|
|
|
|
|
type: Array,
|
2024-04-15 19:39:03 +02:00
|
|
|
default: () => [],
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
2024-02-03 12:50:57 +01:00
|
|
|
submission: {
|
|
|
|
|
type: Object,
|
2024-04-15 19:39:03 +02:00
|
|
|
default: () => {},
|
|
|
|
|
},
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
2024-04-15 19:39:03 +02:00
|
|
|
emits: ["updated", "deleted"],
|
|
|
|
|
setup() {
|
2023-12-31 12:39:01 +01:00
|
|
|
return {
|
2024-04-15 19:39:03 +02:00
|
|
|
useAlert: useAlert(),
|
2023-12-31 12:39:01 +01:00
|
|
|
}
|
|
|
|
|
},
|
2024-04-15 19:39:03 +02:00
|
|
|
data() {
|
2023-12-09 15:47:03 +01:00
|
|
|
return {
|
2024-04-15 19:39:03 +02:00
|
|
|
showEditSubmissionModal: false,
|
2023-12-09 15:47:03 +01:00
|
|
|
}
|
|
|
|
|
},
|
2024-04-15 19:39:03 +02:00
|
|
|
computed: {},
|
|
|
|
|
mounted() {},
|
2023-12-09 15:47:03 +01:00
|
|
|
methods: {
|
2024-04-15 19:39:03 +02:00
|
|
|
onDeleteClick() {
|
|
|
|
|
this.useAlert.confirm(
|
|
|
|
|
"Do you really want to delete this record?",
|
|
|
|
|
this.deleteRecord,
|
|
|
|
|
)
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
2024-04-15 19:39:03 +02:00
|
|
|
async deleteRecord() {
|
|
|
|
|
opnFetch(
|
|
|
|
|
"/open/forms/" +
|
|
|
|
|
this.form.id +
|
|
|
|
|
"/records/" +
|
|
|
|
|
this.submission.id +
|
|
|
|
|
"/delete",
|
|
|
|
|
{ method: "DELETE" },
|
|
|
|
|
)
|
|
|
|
|
.then(async (data) => {
|
|
|
|
|
if (data.type === "success") {
|
|
|
|
|
this.$emit("deleted", this.submission)
|
|
|
|
|
this.useAlert.success(data.message)
|
|
|
|
|
} else {
|
|
|
|
|
this.useAlert.error("Something went wrong!")
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
this.useAlert.error(error.data.message)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-12-09 15:47:03 +01:00
|
|
|
}
|
|
|
|
|
</script>
|