From 1654dd1116d6341923510e02abedf3dd8a687679 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 17 Oct 2022 22:52:28 +0200 Subject: admin: edit warnings --- pages/admin/reports.vue | 110 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 10 deletions(-) (limited to 'pages') diff --git a/pages/admin/reports.vue b/pages/admin/reports.vue index 65825bb..4668222 100644 --- a/pages/admin/reports.vue +++ b/pages/admin/reports.vue @@ -1,6 +1,65 @@ @@ -76,6 +136,8 @@ export default { pages: 0, notResolved: false, boxDeleteReport: 0, + boxEditWarning: 0, + form: {}, }; }, components: { @@ -83,16 +145,6 @@ export default { pagination: Pagination, "v-table": VTable, }, - methods: { - filter() { - if (this.notResolved) { - window.location.href = - "/admin/reports?page=" + this.page + "¬_resolved"; - } else { - window.location.href = "/admin/reports?page=" + this.page; - } - }, - }, async mounted() { await this.$store.dispatch("auth/findMe"); @@ -117,6 +169,44 @@ export default { } }, methods: { + openEditModal(id) { + this.$store.dispatch("warnings/findWarning", id).then((response) => { + this.boxEditWarning = id; + this.form = response.data; + }); + }, + filter() { + if (this.notResolved) { + window.location.href = + "/admin/reports?page=" + this.page + "¬_resolved"; + } else { + window.location.href = "/admin/reports?page=" + this.page; + } + }, + saveWarning() { + this.$store + .dispatch("warnings/editWarning", { ...this.form }) + .then((response) => { + if (response.status == 200) { + this.$toast.success("Report saved"); + if (this.notResolved) { + this.$store + .dispatch("warnings/filterWarnings", { page: this.page }) + .then(() => { + this.pages = Math.ceil(this.count / 20); + }); + } else { + this.$store + .dispatch("warnings/getWarnings", this.page) + .then(() => { + this.pages = Math.ceil(this.count / 20); + }); + } + } else { + this.$toast.error(response.data); + } + }); + }, openModal(id) { this.boxDeleteReport = id; }, -- cgit v1.2.3-18-g5258