From c43aa314a3916be3c264d0d4f94f9153151d118f Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sun, 16 Oct 2022 19:30:29 +0200 Subject: Delete rows from admin cp --- pages/admin/models.vue | 58 ++++++++++++++++++++++++++++++++++++++++++ pages/admin/reports.vue | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) (limited to 'pages') diff --git a/pages/admin/models.vue b/pages/admin/models.vue index e1f65d7..ca84932 100644 --- a/pages/admin/models.vue +++ b/pages/admin/models.vue @@ -1,6 +1,39 @@ @@ -25,6 +59,7 @@ export default { name: "AdminView", head: { title: "Models · Verden" }, computed: { + ...mapGetters(["isLoading"]), ...mapGetters("auth", ["isLogged", "me"]), ...mapGetters("models", ["models", "count"]), }, @@ -32,6 +67,7 @@ export default { return { page: 0, pages: 0, + boxDeleteModel: 0, }; }, components: { @@ -51,5 +87,27 @@ export default { this.pages = Math.ceil(this.count / 20); }); }, + methods: { + openModal(id) { + this.boxDeleteModel = id; + }, + deleteModel() { + if (this.boxDeleteModel) { + this.$store + .dispatch("models/deleteModel", this.boxDeleteModel) + .then((response) => { + if (response.status == 204) { + this.$store.dispatch("models/getModels", this.page).then(() => { + this.pages = Math.ceil(this.count / 20); + }); + this.$toast.success("Model deleted!"); + this.boxDeleteModel = 0; + } else { + this.$toast.error(response.data); + } + }); + } + }, + }, }; diff --git a/pages/admin/reports.vue b/pages/admin/reports.vue index 7191060..5866335 100644 --- a/pages/admin/reports.vue +++ b/pages/admin/reports.vue @@ -1,6 +1,38 @@ @@ -34,6 +67,7 @@ export default { name: "AdminView", head: { title: "Reports · Verden" }, computed: { + ...mapGetters(["isLoading"]), ...mapGetters("auth", ["isLogged", "me"]), ...mapGetters("warnings", ["warnings", "count"]), }, @@ -42,6 +76,7 @@ export default { page: 0, pages: 0, notResolved: false, + boxDeleteReport: 0, }; }, components: { @@ -82,5 +117,37 @@ export default { }); } }, + methods: { + openModal(id) { + this.boxDeleteReport = id; + }, + deleteReport() { + if (this.boxDeleteReport) { + this.$store + .dispatch("warnings/deleteWarning", this.boxDeleteReport) + .then((response) => { + if (response.status == 204) { + 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); + }); + } + this.$toast.success("Report deleted!"); + this.boxDeleteReport = 0; + } else { + this.$toast.error(response.data); + } + }); + } + }, + }, }; -- cgit v1.2.3-18-g5258