From 2c0f16b7f3b8fc3928c0c1315935e42d49007217 Mon Sep 17 00:00:00 2001 From: oetrb <oetrb@github.com> Date: Mon, 12 Oct 2020 00:45:58 +0200 Subject: [PATCH] added student --- package-lock.json | 5 + src/App.vue | 1 - .../CreateEditComponents/CreateStudent.vue | 187 ++++++++++++++++++ src/components/SideMenu.vue | 6 +- src/components/Student.vue | 3 +- src/models/student.js | 2 +- src/router.js | 13 ++ src/store/index.js | 2 + 8 files changed, 213 insertions(+), 6 deletions(-) create mode 100644 src/components/CreateEditComponents/CreateStudent.vue diff --git a/package-lock.json b/package-lock.json index 5828fb1..537cad3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9226,6 +9226,11 @@ "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true }, + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + }, "query-string": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", diff --git a/src/App.vue b/src/App.vue index e7bc3d5..6b0af4a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -52,7 +52,6 @@ export default { this.$store.dispatch('event/get').then( (data) => { - console.log("appdata"+data) this.events = []; data.forEach(row => { let title = row.title; diff --git a/src/components/CreateEditComponents/CreateStudent.vue b/src/components/CreateEditComponents/CreateStudent.vue new file mode 100644 index 0000000..aa33d26 --- /dev/null +++ b/src/components/CreateEditComponents/CreateStudent.vue @@ -0,0 +1,187 @@ +<template> + <div> + <div class="row col-md-12"> + <div id="content" class="content col-md-12"> + <form @submit="validateBeforeSubmit" class="col-md-10" style="margin-bottom: 20px"> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 30px">Anrede</h1> + <div class="input_container"> + <input v-model="student.anrede" type="text" class="form-control inputField" placeholder="Anrede" aria-label="anrede" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 30px">Vorname</h1> + <div class="input_container"> + <input v-model="student.firstname" type="text" class="form-control inputField" placeholder="Vorname" aria-label="firstname" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle">Nachname</h1> + <div class="input_container"> + <input v-model="student.lastname" type="text" class="form-control inputField" placeholder="Nachname" aria-label="lastname" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">Straße</h1> + <div class="input_container"> + <input name="street" v-model="student.street" class="form-control inputField" placeholder="Straße" aria-label="street" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">Postleitzahl</h1> + <div class="input_container"> + <input name="zip" v-model="student.zip" class="form-control inputField" placeholder="Postleitzahl" aria-label="zip" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">Ort</h1> + <div class="input_container"> + <input name="city" v-model="student.city" class="form-control inputField" placeholder="Ort" aria-label="city" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">SommerUni 17</h1> + <div class="input_container"> + <input name="sommeruni17" v-model="student.sommeruni17" class="form-control inputField" placeholder="SommerUni 17" aria-label="sommeruni17" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">SommerUni 18</h1> + <div class="input_container"> + <input name="sommeruni18" v-model="student.sommeruni18" class="form-control inputField" placeholder="SommerUni 18" aria-label="sommeruni18" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">SommerUni 19</h1> + <div class="input_container"> + <input name="sommeruni19" v-model="student.sommeruni19" class="form-control inputField" placeholder="SommerUni 19" aria-label="sommeruni19" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">SommerUni 20</h1> + <div class="input_container"> + <input name="sommeruni20" v-model="student.sommeruni20" class="form-control inputField" placeholder="SommerUni 20" aria-label="sommeruni20" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">Natürlich 20</h1> + <div class="input_container"> + <input name="natuerlich20" v-model="student.natuerlich20" class="form-control inputField" placeholder="Natürlich 20" aria-label="natuerlich20" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <h1 class="formTitle" style="margin-top: 10px">Aktiv ?</h1> + <div class="input_container"> + <input name="status" v-model="student.status" class="form-control inputField" placeholder="Ist der Student aktiv, dann 1, ansonsten 0 eingeben..." aria-label="status" required> + </div> + </div> + </div> + <div class="form-row"> + <div class="col-md-11 mb-3"> + <button class="btn btn-primary btn-lg btn-block" style="margin-top: 20px; border-radius: 10px" type="button" @click="validateBeforeSubmit">Eintrag hinzufügen</button> + </div> + </div> + <div class="row"> + <div class="col-md-12 mb-3"> + </div> + </div> + </form> + </div> + </div> + </div> +</template> + +<script> +import Student from "@/models/student"; + +export default { + name: "CreateStudent.vue", + + data(){ + return { + message: "", + student: new Student('', '', '', '', '', '', '', '', '', '', '', '', ''), + } + }, + + methods: { + validateBeforeSubmit() { + this.$validator.validate().then(isValid => { + if (isValid) { + console.log("isvalid"); + this.$store.dispatch('student/insert', this.student).then( + data => { + this.$router.push('/students'); + this.message = data.message; + this.successful = true; + }, + error => { + this.message = (error.response && error.response.data) || error.message || error.toString(); + this.successful = false; + } + ); + } else { + console.log("not isvalid") + } + }); + } + } +} +</script> + +<style scoped> +div.content { + background-color: whitesmoke; + position: fixed; + padding: 1px 16px; + height: 1000px; + overflow-y: auto; +} + +.formTitle { + font-size: 14px; + font-weight: 500; + color: #6B6C6F; +} + +.inputField { + height: 44px; + margin-top: 10px; + padding-left: 70px; + padding-right: 70px; + border-color: #DFE2E6; + border-width: 2px; + border-radius: 10px; +} + +.input_container { + position:relative; +} + +.btn { + margin-bottom: 200px; +} +</style> \ No newline at end of file diff --git a/src/components/SideMenu.vue b/src/components/SideMenu.vue index 5e81e2e..5b83c80 100644 --- a/src/components/SideMenu.vue +++ b/src/components/SideMenu.vue @@ -4,12 +4,12 @@ <img class="natlab-logo col-md-12" id="natlab-logo" src="../assets/natlab-logo.png" alt="NatLab Logo"> <br> <div> - <li :class="[currentPage.includes('students') ? activeClass: '', 'navButton']"> - <router-link style="margin-bottom: -25px;" to="/students" class="navA">Studentenübersicht</router-link><br> - </li> <li style="margin-top: 50px;" :class="[currentPage.includes('courses') ? activeClass: '', 'navButton']"> <router-link style="margin-bottom: -25px;" to="/courses" class="navA">Kursübersicht</router-link><br> </li> + <li :class="[currentPage.includes('students') ? activeClass: '', 'navButton']"> + <router-link style="margin-bottom: -25px;" to="/students" class="navA">Studentenübersicht</router-link><br> + </li> <li :class="[currentPage.includes('teachers') ? activeClass: '', 'navButton']"> <router-link style="margin-bottom: -25px;" to="/teachers" class="navA">Lehrbeauftragtenübersicht</router-link><br> </li> diff --git a/src/components/Student.vue b/src/components/Student.vue index d3fc5d2..bab198a 100644 --- a/src/components/Student.vue +++ b/src/components/Student.vue @@ -117,9 +117,10 @@ export default { async loadData(){ await this.$store.dispatch('student/getAll').then( (data) => { + console.log(data); let x; for(x = 0; x < data.length; x++){ - this.rows.push({id: data[x].id, coursenumber: data[x].course_number, courseoffer: data[x].course_offer, coursename: data[x].course_name, eventtype: data[x].event_type, coursedate: data[x].course_datetime, topic: data[x].course_topic, courselocation: data[x].course_location, accompanyingteacher: data[x].accompanyingTeacher, supervisingstudents: data[x].supervisingStudents, presentstudents: data[x].presentStudents, registeredstudents: data[x].registeredStudents, instructor: data[x].instructor, notefield: data[x].noteField, anzahlung: data[x].anzahlung, honorar: data[x].honorar, status: data[x].status}); + this.rows.push({id: data[x].id, anrede: data[x].anrede, firstname: data[x].firstName, lastname: data[x].lastname, street: data[x].street, zip: data[x].postcode, city: data[x].ort, sommeruni17: data[x].summerUni_17, sommeruni18: data[x].summerUni_18, sommeruni19: data[x].summerUni_19, sommeruni20: data[x].summerUni_20, natuerlich20: data[x].natuerlich, status: data[x].status}); } }, error => { diff --git a/src/models/student.js b/src/models/student.js index adacc01..fda9fa8 100644 --- a/src/models/student.js +++ b/src/models/student.js @@ -1,6 +1,6 @@ export default class Student { - constructor(id, anrede, firstname, lastname, street, zip, ctiy, sommeruni17, sommeruni18, sommeruni19, sommeruni20, natuerlich20, status) { + constructor(id, anrede, firstname, lastname, street, zip, city, sommeruni17, sommeruni18, sommeruni19, sommeruni20, natuerlich20, status) { this.id = id; this.anrede = anrede; this.firstname = firstname; diff --git a/src/router.js b/src/router.js index 6490528..9e6beef 100644 --- a/src/router.js +++ b/src/router.js @@ -17,6 +17,7 @@ import Certifications from "@/components/Certifications"; import CreateCertification from "@/components/CreateEditComponents/CreateCertification"; import EditCertificate from "@/components/CreateEditComponents/EditCertificate"; import Student from "@/components/Student"; +import CreateStudent from "@/components/CreateEditComponents/CreateStudent"; Vue.use(Router) @@ -36,6 +37,18 @@ const router = new Router({ component: EditCourse }, + // Button from Students + { + path: '/createstudent', + name: 'neuen Eintrag hinzufügen', + component: CreateStudent + }, + { + path: '/editstudent', + name: 'Eintrag bearbeiten', + //component: EditStudent + }, + // Button from Teachers { path: '/createteacher', diff --git a/src/store/index.js b/src/store/index.js index 6094008..22e670c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4,6 +4,7 @@ import Vuex from 'vuex'; import { auth } from './auth.module'; import { user } from './user.module'; import { course } from './course.module'; +import { student } from './student.module'; import { teacher } from './teacher.module'; import { event } from './event.module'; import { certification } from './certification.module'; @@ -15,6 +16,7 @@ export default new Vuex.Store({ auth, user, course, + student, event, teacher, certification -- GitLab