Added observation POST.

This commit is contained in:
neviyn 2018-09-20 12:23:34 +01:00
parent 07622febd3
commit 94a23df7f9

View File

@ -50,6 +50,7 @@
<script>
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue/dist/bootstrap-vue.css";
import { mapState } from "vuex";
import Vue from "vue";
export default {
name: "observation",
@ -65,6 +66,9 @@ export default {
]
};
},
computed: {
...mapState(["site", "description", "type", "tutors"])
},
methods: {
addAnotherObservation: function() {
this.observations.push({
@ -91,6 +95,27 @@ export default {
e.stopPropagation();
var form = document.getElementById("submission-form");
console.log(form.checkValidity());
if (form.checkValidity()) {
Vue.axios
.post("/api/observation", {
siteId: this.site,
tutorIds: this.tutors,
observed: this.description,
type: this.type,
monitoring: "",
control: "",
conservatism: "",
teamwork: "",
knowledge: "",
rawData: this.observations
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
}
form.classList.add("was-validated");
}
}