- methods: {
- redirect: function(code) {
- document.location.href = "/" + initials + "/" + code;
- },
- addCourse: function() {
- if (!admin)
- return;
- // modal, fill code and description
- let error = Validator.checkObject({code:this.newCourse.code}, "Course");
- if (!!error)
- return alert(error);
- else
- $('#newCourse').modal('close');
- $.ajax("/add/course",
+ addCourse: function() {
+ if (!admin)
+ return;
+ // modal, fill code and description
+ let error = Validator.checkObject({code:this.newCourse.code}, "Course");
+ if (!!error)
+ return alert(error);
+ else
+ $('#newCourse').modal('close');
+ $.ajax("/add/course",
+ {
+ method: "GET",
+ data: this.newCourse,
+ dataType: "json",
+ success: res => {
+ if (!res.errmsg)
+ {
+ this.newCourse["code"] = "";
+ this.newCourse["description"] = "";
+ this.courseArray.push(res);
+ }
+ else
+ alert(res.errmsg);
+ },
+ }
+ );
+ },
+ deleteCourse: function(course) {
+ if (!admin)
+ return;
+ if (confirm("Delete course '" + course.code + "' ?"))
+ $.ajax("/remove/course",