Skip to content

Commit

Permalink
Remove Audit Section create and delete
Browse files Browse the repository at this point in the history
Not needed anymore since automatically handled by Audit Type
  • Loading branch information
yeln4ts committed May 20, 2021
1 parent 404420d commit 30a1563
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 83 deletions.
32 changes: 0 additions & 32 deletions backend/src/routes/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,6 @@ module.exports = function(app, io) {
.catch(err => Response.Internal(res, err))
});

// Add section to audit
app.post("/api/audits/:auditId/sections", acl.hasPermission('audits:update'), function(req, res) {
if (!req.body.field || !req.body.name) {
Response.BadParameters(res, 'Missing some required parameters: field, name');
return;
}

var section = {};
// Required parameters
section.name = req.body.name;
section.field = req.body.field;
// Optional parameters
if (req.body.customFields) section.customFields = req.body.customFields

Audit.createSection(acl.isAllowed(req.decodedToken.role, 'audits:update-all'), req.params.auditId, req.decodedToken.id, section)
.then(msg => {
io.to(req.params.auditId).emit('updateAudit');
Response.Ok(res, msg)
})
.catch(err => Response.Internal(res, err))
});

// Get section of audit
app.get("/api/audits/:auditId/sections/:sectionId", acl.hasPermission('audits:read'), function(req, res) {
Audit.getSection(acl.isAllowed(req.decodedToken.role, 'audits:read-all'), req.params.auditId, req.decodedToken.id, req.params.sectionId)
Expand Down Expand Up @@ -276,16 +254,6 @@ module.exports = function(app, io) {
.catch(err => Response.Internal(res, err))
});

// Delete section of audit
app.delete("/api/audits/:auditId/sections/:sectionId", acl.hasPermission('audits:update'), function(req, res) {
Audit.deleteSection(acl.isAllowed(req.decodedToken.role, 'audits:update-all'), req.params.auditId, req.decodedToken.id, req.params.sectionId)
.then(msg => {
io.to(req.params.auditId).emit('updateAudit');
Response.Ok(res, msg);
})
.catch(err => Response.Internal(res, err))
});

// Generate Report for specific audit
app.get("/api/audits/:auditId/generate", acl.hasPermission('audits:read'), function(req, res){
Audit.getAudit(acl.isAllowed(req.decodedToken.role, 'audits:read-all'), req.params.auditId, req.decodedToken.id)
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/pages/audits/edit/sections/sections.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<div>
<breadcrumb buttons :title="`${$parent.audit.name} (${$parent.audit.auditType || 'Audit Type not set'})`">
<div slot="buttons">
<q-btn
color="negative"
class="q-mr-sm"
label="Delete"
no-caps
@click="deleteSection"
/>
<q-btn color="positive" label="Save (ctrl+s)" no-caps @click="updateSection" />
</div>
</breadcrumb>
Expand Down
36 changes: 0 additions & 36 deletions frontend/src/pages/audits/edit/sections/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,42 +137,6 @@ export default {
})
},

deleteSection: function() {
Dialog.create({
title: 'Delete current Section ?',
message: `This action can't be cancelled`,
ok: {label: 'Confirm', color: 'negative'},
cancel: {label: 'Cancel', color: 'white'}
})
.onOk(() => {
AuditService.deleteSection(this.auditId, this.sectionId)
.then(() => {
Notify.create({
message: 'Section deleted successfully',
color: 'positive',
textColor:'white',
position: 'top-right'
})
this.sectionOrig = this.section
var currentIndex = this.$parent.audit.sections.findIndex(e => e._id === this.sectionId)
if (this.$parent.audit.sections.length === 1)
this.$router.push(`/audits/${this.$parent.auditId}/general`)
else if (currentIndex === this.$parent.audit.sections.length - 1)
this.$router.push(`/audits/${this.$parent.auditId}/sections/${this.$parent.audit.sections[currentIndex - 1]._id}`)
else
this.$router.push(`/audits/${this.$parent.auditId}/sections/${this.$parent.audit.sections[currentIndex + 1]._id}`)
})
.catch((err) => {
Notify.create({
message: err.response.data.datas,
color: 'negative',
textColor:'white',
position: 'top-right'
})
})
})
},

unsavedChanges: function() {
if (!this.$_.isEqual(this.section.customFields, this.sectionOrig.customFields))
return true
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/services/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export default {
return Vue.prototype.$axios.delete(`audits/${auditId}/findings/${findingId}`)
},

createSection: function(auditId, section) {
return Vue.prototype.$axios.post(`audits/${auditId}/sections`, section)
},

getSection: function(auditId, sectionId) {
return Vue.prototype.$axios.get(`audits/${auditId}/sections/${sectionId}`)
},
Expand All @@ -69,10 +65,6 @@ export default {
return Vue.prototype.$axios.put(`audits/${auditId}/sections/${sectionId}`, section)
},

deleteSection: function(auditId, sectionId) {
return Vue.prototype.$axios.delete(`audits/${auditId}/sections/${sectionId}`)
},

getAuditTypes: function() {
return Vue.prototype.$axios.get(`audits/types`)
},
Expand Down

0 comments on commit 30a1563

Please sign in to comment.