Explorar el Código

Should also add remove thread functionality to admin moderation page

sbkwgh hace 7 años
padre
commit
d75753eb52
Se han modificado 1 ficheros con 23 adiciones y 2 borrados
  1. 23 2
      frontend/src/components/routes/AdminModerationReports.vue

+ 23 - 2
frontend/src/components/routes/AdminModerationReports.vue

@@ -6,6 +6,10 @@
 			Are you sure you want to remove this post?
 		</confirm-modal>
 
+		<confirm-modal v-model='removePostObj.showThreadDeleteModal' @confirm='deleteThread' text='Delete' color='red'>
+			Are you sure you want to delete the thread containing this post?
+		</confirm-modal>
+
 		<transition name='fade' mode='out-in'>
 			<loading-message v-if='!reports' key='loading'></loading-message>
 
@@ -49,6 +53,7 @@
 						<menu-button
 							@delete='deleteReport(report.id, $index)'
 							@ban='banUser(report, $index)'
+							@deleteThread='deleteThread(report, $index)'
 							:options='reportMenuOptions'
 						>
 							<button class='button'>More options&hellip;</button>
@@ -96,12 +101,13 @@
 				reportMenuOptions: [
 					{ value: "Delete report", event: 'delete' },
 					{ value: "Ban or block user", event: 'ban' },
-					{ value: "Remove thread" }
+					{ value: "Delete thread", event: 'deleteThread' }
 				],
 				reports: null,
 
 				removePostObj: {
 					showConfirmModal: false,
+					showThreadDeleteModal: false,
 					report: null,
 					index: null
 				}
@@ -109,13 +115,28 @@
 		},
 		methods: {
 			deleteReport (id, index) {
-				this.axios
+				return this.axios
 					.delete('/api/v1/report/' + id)
 					.then(_ => {
 						this.reports.splice(index, 1)
 					})
 					.catch(AjaxErrorHandler(this.$store))
 			},
+			deleteThread (report, index) {
+				if(report) {
+					this.removePostObj.report = report
+					this.removePostObj.index = index
+
+					this.removePostObj.showThreadDeleteModal = true
+				} else {
+					this.axios
+						.delete('/api/v1/thread/' + this.removePostObj.report.Post.Thread.id)
+						.then(() => {
+							return this.deleteReport(this.removePostObj.report.id, this.removePostObj.index)
+						})
+						.catch(AjaxErrorHandler(this.$store))
+				}
+			},
 			removePost (report, index) {
 				if(report) {
 					this.removePostObj.report = report