Browse Source

Made sure issues are only saved if reasons array isn't empty

theflametrooper 8 years ago
parent
commit
1bb2c14e8f

+ 8 - 0
backend/logic/actions/reports.js

@@ -111,6 +111,14 @@ module.exports = {
 
 				next();
 			},
+			
+			(next) => {
+				for (let r = 0; r < data.issues.length; r++) {
+					if (data.issues[r].reasons.length === 0) data.issues.splice(r, 1);
+				}
+
+				next();
+			},
 
 			(next) => {
 				data.createdBy = userId;

+ 1 - 1
frontend/components/Admin/Reports.vue

@@ -57,7 +57,7 @@
 			},
 			toggleModal: function (report) {
 				this.isModalActive = !this.isModalActive;
-				if (this.isModalActive) this.currentReport = report;
+				if (this.isModalActive) this.editing = report;
 			},
 			resolve: function (reportId) {
 				this.socket.emit('reports.resolve', reportId, res => {

+ 2 - 2
frontend/components/Modals/IssuesModal.vue

@@ -16,7 +16,7 @@
 						</tr>
 					</thead>
 					<tbody>
-						<tr v-for='(index, issue) in $parent.currentReport.issues' track-by='$index'>
+						<tr v-for='(index, issue) in $parent.editing.issues' track-by='$index'>
 							<td>
 								<span>{{ issue.name }}</span>
 							</td>
@@ -29,7 +29,7 @@
 
 			</section>
 			<footer class='modal-card-foot'>
-				<a class='button is-primary' @click='$parent.resolve($parent.currentReport._id)'>
+				<a class='button is-primary' @click='$parent.resolve($parent.editing._id)'>
 					<span>Resolve</span>
 				</a>
 				<a class='button is-danger' @click='$parent.toggleModal()'>