-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCourseSettings.vue
More file actions
148 lines (129 loc) · 3.36 KB
/
CourseSettings.vue
File metadata and controls
148 lines (129 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<template>
<div class="form">
<div class="group">
<label for="course-settings-title"> Class Title: </label>
<input id="course-settings-title" type="text" v-model="newCourse.class_name">
</div>
<div v-if="false" class="group">
<label for="course-settings-sections"> Section Names: </label>
<input id="course-settings-sections" type="text" v-model="sections">
</div>
<div class="group">
<label for="course-settings-description"> Description: </label>
<input id="course-settings-description" type="text" v-model="newCourse.description">
</div>
<div class="group">
<label for="course-settings-term"> Term: </label>
<input id="course-settings-term" type="text" v-model="newCourse.term" placeholder="Spring 2021">
</div>
<div class="group">
<label for="course-settings-contact"> Contact Email: </label>
<input id="course-settings-contact" type="text" v-model="newCourse.contact_email">
</div>
<div v-if="message" class="message">{{ message }}</div>
<button class="submit" :disabled="!submitEnabled" @click="edit">
Update
</button>
</div>
</template>
<script>
import axios from "axios"
import 'vue-simple-suggest/dist/styles.css'
import VueSimpleSuggest from 'vue-simple-suggest'
import 'vue-good-table/dist/vue-good-table.css'
import { VueGoodTable } from 'vue-good-table'
export default {
name: 'CourseSettings',
props: {
course: Object
},
data() {
return {
newCourse: {
class_name: "",
id: "",
/* institution: "",
contact_email: "",
term: "",
description: "" */
},
sections: "",
message: null
}
},
computed: {
submitEnabled: function() {
return this.newCourse && this.newCourse.class_name &&
this.newCourse.class_name.length > 0
}
},
mounted: function(){
this.newCourse = this.course
},
methods: {
edit: function() {
axios.post("/api/classes/edit", {course: this.newCourse, sections: this.sections})
.then(() => {
location.reload();
})
.catch(err => {
if (err.response.status === 401) {
this.message = "Invalid course data. Try again!"
}
console.error(`Edit failed: ${err.response.data.error}`)
})
}
},
components: {
}
}
</script>
<style scoped>
.form {
width: 380px;
display: flex;
flex-direction: column;
padding: 20px;
}
.form .title {
margin: 0;
padding: 10px 0 20px 0;
}
.form .group {
display: flex;
align-items: center;
padding-bottom: 15px;
}
.form .group label {
margin-right: 5px;
}
.form .group input {
padding: 4px 6px;
border-radius: 3px;
border: solid 1px #aaa;
font-size: 16px;
flex-grow: 1;
}
.form .message {
color: #cf000f;
font-size: 14px;
}
button.submit {
width: 80px;
align-self: flex-end;
padding: 6px 0;
border-radius: 5px;
border: solid 1px #007bff;
background-color: #007bff;
color: #fff;
font-size: 16px;
cursor: pointer;
}
button.submit:disabled {
cursor: not-allowed;
opacity: 0.5;
}
button.submit:enabled:hover {
background-color: #0069d9;
}
</style>