From cb58720c23f9e670586717d193a334767920f2f2 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Thu, 29 Nov 2018 14:31:33 +0000 Subject: [PATCH] Changed observation entry to a more scenario based format. --- frontend/src/views/Observation.vue | 547 +++++++++++++++++++---------- frontend/src/views/StartNew.vue | 19 +- 2 files changed, 365 insertions(+), 201 deletions(-) diff --git a/frontend/src/views/Observation.vue b/frontend/src/views/Observation.vue index a262098..08c7e94 100644 --- a/frontend/src/views/Observation.vue +++ b/frontend/src/views/Observation.vue @@ -1,117 +1,222 @@ @@ -167,18 +274,53 @@ export default { title: "Observation", data: function() { return { - observations: [ + scenarios: [ { - type: null, - rating: null, - strengths: "", - improvements: "" + title: "", + monitoring: { + rating: null, + strengths: "", + improvements: "" + }, + controlProcedural: { + rating: null, + strengths: "", + improvements: "" + }, + control: { + rating: null, + strengths: "", + improvements: "" + }, + conservatism: { + rating: null, + strengths: "", + improvements: "" + }, + teamworkCommunications: { + rating: null, + strengths: "", + improvements: "" + }, + teamworkLeadership: { + rating: null, + strengths: "", + improvements: "" + }, + teamworkWorkload: { + rating: null, + strengths: "", + improvements: "" + }, + knowledge: { + rating: null, + strengths: "", + improvements: "" + } } ], totals: [0, 0, 0, 0, 0, 0, 0, 0], - submitPassword: null, - persons: [], - personInput: null + submitPassword: null }; }, computed: { @@ -186,11 +328,48 @@ export default { }, methods: { addAnotherObservation: function() { - this.observations.push({ - type: null, - rating: null, - strengths: "", - improvements: "" + this.scenarios.push({ + title: "", + monitoring: { + rating: null, + strengths: "", + improvements: "" + }, + controlProcedural: { + rating: null, + strengths: "", + improvements: "" + }, + control: { + rating: null, + strengths: "", + improvements: "" + }, + conservatism: { + rating: null, + strengths: "", + improvements: "" + }, + teamworkCommunications: { + rating: null, + strengths: "", + improvements: "" + }, + teamworkLeadership: { + rating: null, + strengths: "", + improvements: "" + }, + teamworkWorkload: { + rating: null, + strengths: "", + improvements: "" + }, + knowledge: { + rating: null, + strengths: "", + improvements: "" + } }); Vue.nextTick(function() { window.scrollTo( @@ -200,66 +379,54 @@ export default { }); }, deleteObservation: function(index) { - this.observations.splice(index, 1); - if (this.observations.length === 0) { + this.$delete(this.scenarios, index); + if (this.scenarios.length === 0) { this.addAnotherObservation(); } this.updateTotals(); }, - changeType: function(index, ev) { - this.observations[index].type = ev; - this.updateTotals(); - }, - changeRating: function(index, ev) { - this.observations[index].rating = parseInt(ev); - this.updateTotals(); - }, updateTotals: function() { var iTotals = [0, 0, 0, 0, 0, 0, 0, 0]; var counts = [0, 0, 0, 0, 0, 0, 0, 0]; - this.observations.forEach(function(element) { - if (element.rating > 0) { - switch (element.type) { - case "MONITORING": - iTotals[0] += element.rating; - counts[0] += 1; - break; - case "CONTROL_PROCEDURAL": - iTotals[1] += element.rating; - counts[1] += 1; - break; - case "CONTROL": - iTotals[2] += element.rating; - counts[2] += 1; - break; - case "CONSERVATISM": - iTotals[3] += element.rating; - counts[3] += 1; - break; - case "TEAMWORK_COMMUNICATIONS": - iTotals[4] += element.rating; - counts[4] += 1; - break; - case "TEAMWORK_LEADERSHIP": - iTotals[5] += element.rating; - counts[5] += 1; - break; - case "TEAMWORK_WORKLOAD": - iTotals[6] += element.rating; - counts[6] += 1; - break; - case "KNOWLEDGE": - iTotals[7] += element.rating; - counts[7] += 1; - break; - } + this.scenarios.forEach(function(element) { + if (element.monitoring.rating) { + iTotals[0] += parseInt(element.monitoring.rating); + counts[0] += 1; + } + if (element.controlProcedural.rating) { + iTotals[1] += parseInt(element.controlProcedural.rating); + counts[1] += 1; + } + if (element.control.rating) { + iTotals[2] += parseInt(element.control.rating); + counts[2] += 1; + } + if (element.conservatism.rating) { + iTotals[3] += parseInt(element.conservatism.rating); + counts[3] += 1; + } + if (element.teamworkCommunications.rating) { + iTotals[4] += parseInt(element.teamworkCommunications.rating); + counts[4] += 1; + } + if (element.teamworkLeadership.rating) { + iTotals[5] += parseInt(element.teamworkLeadership.rating); + counts[5] += 1; + } + if (element.teamworkWorkload.rating) { + iTotals[6] += parseInt(element.teamworkWorkload.rating); + counts[6] += 1; + } + if (element.knowledge.rating) { + iTotals[7] += parseInt(element.knowledge.rating); + counts[7] += 1; } }); for (var i = 0; i < iTotals.length; i++) { if (counts[i] !== 0) { - this.totals[i] = (iTotals[i] / counts[i]).toFixed(1); + Vue.set(this.totals, i, (iTotals[i] / counts[i]).toFixed(1)); } else { - this.totals[i] = 0; + Vue.set(this.totals, i, 0); } } }, @@ -301,11 +468,9 @@ export default { { site: this.site, tutors: this.tutors, - observed: this.description, whom: this.whom, type: this.type, - persons: this.persons, - entries: JSON.parse(JSON.stringify(this.observations)) + scenarios: JSON.parse(JSON.stringify(this.scenarios)) }, axiosConfig ) @@ -332,6 +497,16 @@ export default { diff --git a/frontend/src/views/StartNew.vue b/frontend/src/views/StartNew.vue index 9b018d3..9acdcbc 100644 --- a/frontend/src/views/StartNew.vue +++ b/frontend/src/views/StartNew.vue @@ -33,23 +33,8 @@ - - - - - - - - - - - - - - - - - +