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