Using live calculated totals in submission object

This commit is contained in:
neviyn 2020-09-21 14:05:26 +01:00
parent 9d209b7b52
commit cdb156c818

View File

@ -400,7 +400,7 @@ export default {
},
handleSubmit() {
var form = document.getElementById("submission-form");
var notObservedValue = 0
var notObservedValue = 0;
if (form.checkValidity()) {
let axiosConfig = {
auth: {
@ -439,11 +439,7 @@ export default {
title: scenario.title,
monitoringRating:
monitoring.length > 0
? monitoring.length > 1
? monitoring.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / monitoring.length
: monitoring[0].rating
? Math.round(self.totals[0])
: notObservedValue,
monitoringStrengths: monitoring
.map((entry) => entry.strengths)
@ -453,11 +449,7 @@ export default {
.join("; "),
controlProceduralRating:
controlProcedural.length > 0
? controlProcedural.length > 1
? controlProcedural.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / controlProcedural.length
: controlProcedural[0].rating
? Math.round(self.totals[1])
: notObservedValue,
controlProceduralStrengths: controlProcedural
.map((entry) => entry.strengths)
@ -467,11 +459,7 @@ export default {
.join("; "),
controlRating:
control.length > 0
? control.length > 1
? control.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / control.length
: control[0].rating
? Math.round(self.totals[2])
: notObservedValue,
controlStrengths: control
.map((entry) => entry.strengths)
@ -479,11 +467,7 @@ export default {
controlImprovements: control.map((entry) => entry.AFIs).join("; "),
conservatismRating:
conservatism.length > 0
? conservatism.length > 1
? conservatism.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / conservatism.length
: conservatism[0].rating
? Math.round(self.totals[3])
: notObservedValue,
conservatismStrengths: conservatism
.map((entry) => entry.strengths)
@ -493,11 +477,7 @@ export default {
.join(";"),
teamworkCommunicationsRating:
teamworkCommunications.length > 0
? teamworkCommunications.length > 1
? teamworkCommunications.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / teamworkCommunications.length
: teamworkCommunications[0].rating
? Math.round(self.totals[4])
: notObservedValue,
teamworkCommunicationsStrengths: teamworkCommunications
.map((entry) => entry.strengths)
@ -507,11 +487,7 @@ export default {
.join(";"),
teamworkLeadershipRating:
teamworkLeadership.length > 0
? teamworkLeadership.length > 1
? teamworkLeadership.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / teamworkLeadership.length
: teamworkLeadership[0].rating
? Math.round(self.totals[5])
: notObservedValue,
teamworkLeadershipStrengths: teamworkLeadership
.map((entry) => entry.strengths)
@ -521,11 +497,7 @@ export default {
.join(";"),
teamworkWorkloadRating:
teamworkWorkload.length > 0
? teamworkWorkload.length > 1
? teamworkWorkload.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / teamworkWorkload.length
: teamworkWorkload[0].rating
? Math.round(self.totals[6])
: notObservedValue,
teamworkWorkloadStrengths: teamworkWorkload
.map((entry) => entry.strengths)
@ -535,11 +507,7 @@ export default {
.join(";"),
knowledgeRating:
knowledge.length > 0
? knowledge.length > 1
? knowledge.reduce(
(a, b) => parseInt(a.rating) + parseInt(b.rating)
) / knowledge.length
: knowledge[0].rating
? Math.round(self.totals[7])
: notObservedValue,
knowledgeStrengths: knowledge
.map((entry) => entry.strengths)