|
|
|
@ -3,7 +3,7 @@
|
|
|
|
|
import {reactive , ref} from 'vue'
|
|
|
|
|
import { getCourses,deleteCourse,alterCourse,createCourse } from "@/rest/courses.js"
|
|
|
|
|
import {getUser, getSelf, getTeachers } from "@/rest/Users.js"
|
|
|
|
|
import {getAllCurriculums} from "@/rest/curriculum.js";
|
|
|
|
|
import {addCourseToCurriculum, getAllCurriculums, getCurriculumsByCourse} from "@/rest/curriculum.js";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const self = await getSelf();
|
|
|
|
@ -11,11 +11,16 @@
|
|
|
|
|
const curriculum = ref(await getCourses(self.role));
|
|
|
|
|
const profList = await getTeachers();
|
|
|
|
|
const allCurriculums = ref(await getAllCurriculums());
|
|
|
|
|
const curriculumToAdd = ref();
|
|
|
|
|
|
|
|
|
|
const createMod = ref(false)
|
|
|
|
|
const deleteMod = ref(false)
|
|
|
|
|
|
|
|
|
|
const editElementID = ref("")
|
|
|
|
|
const editAddCourse = ref("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const curriculumToAddId = ref()
|
|
|
|
|
|
|
|
|
|
const pattern = {
|
|
|
|
|
"id":null,
|
|
|
|
@ -45,7 +50,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
async function setAddToCurriculum(item){
|
|
|
|
|
let temp = [];
|
|
|
|
|
let courseCurriculum = await getCurriculumsByCourse(item.courseID);
|
|
|
|
|
let isIn = false;
|
|
|
|
|
for (let element in allCurriculums.value){
|
|
|
|
|
for (let item in courseCurriculum){
|
|
|
|
|
if((courseCurriculum[item].option == allCurriculums.value[element].option) && (courseCurriculum[item].year == allCurriculums.value[element].year) ){
|
|
|
|
|
isIn = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(!isIn){
|
|
|
|
|
temp.push(allCurriculums.value[element])
|
|
|
|
|
}
|
|
|
|
|
isIn = false;
|
|
|
|
|
}
|
|
|
|
|
curriculumToAdd.value = temp.slice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function addToCurriculum(item){
|
|
|
|
|
await addCourseToCurriculum(curriculumToAddId.value,item.courseID);
|
|
|
|
|
curriculumToAddId.value = null;
|
|
|
|
|
curriculumToAdd.value = null;
|
|
|
|
|
allCurriculums.value = await getAllCurriculums();
|
|
|
|
|
}
|
|
|
|
|
function setModify(item){
|
|
|
|
|
for(const el in profList){
|
|
|
|
|
|
|
|
|
@ -93,7 +123,7 @@
|
|
|
|
|
<button class="create" @click="editElementID= '';createMod = true;">
|
|
|
|
|
{{i18n("courses.createCourse")}}
|
|
|
|
|
</button>
|
|
|
|
|
<button class="delete" @click="deleteMod=true" >
|
|
|
|
|
<button class="delete" @click="deleteMod=true">
|
|
|
|
|
{{i18n("courses.deleteCourse")}}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
@ -138,24 +168,39 @@
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="!createMod && !deleteMod" v-for="item in curriculum" :key="item.title" style="width:50%;margin-left:auto; margin-right:auto;">
|
|
|
|
|
<div v-if="editElementID !== item.title" style ="padding:15px 15px 15px 15px;">
|
|
|
|
|
<button @click="editElementID = item.title; setModify(item); ">
|
|
|
|
|
<div v-if="editElementID !== item.title && editAddCourse !== item.title" style ="padding:15px 15px 15px 15px;">
|
|
|
|
|
<button @click="editElementID = item.title; editAddCourse = ''; setModify(item); ">
|
|
|
|
|
{{i18n("courses.modify")}}
|
|
|
|
|
</button>
|
|
|
|
|
<button v-if="self.role !== 'Teacher'"@click="editAddCourse = item.title; editElementID ='';setAddToCurriculum(item)">Add to a new Curriculum</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<div v-if="editElementID == item.title">
|
|
|
|
|
<button @click="editElementID= '';patchCourse(item)"> {{i18n("courses.confirm")}} </button>
|
|
|
|
|
<button @click="editElementID= '';"> {{i18n("courses.back")}} </button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="listElement" >
|
|
|
|
|
<div v-if="editAddCourse == item.title">
|
|
|
|
|
<button @click="editAddCourse= '';addToCurriculum(item)"> {{i18n("courses.confirm")}} </button>
|
|
|
|
|
<button @click="editAddCourse= '';"> {{i18n("courses.back")}} </button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="listElement">
|
|
|
|
|
|
|
|
|
|
<div class="containerElement" v-if="editElementID !== item.title" >
|
|
|
|
|
<div class="containerElement" v-if="editElementID !== item.title && editAddCourse !== item.title" >
|
|
|
|
|
|
|
|
|
|
<div class="name"> {{item.title}} </div>
|
|
|
|
|
<div class="teacher">{{item.owner.lastName}}</div>
|
|
|
|
|
<div class="credits">{{i18n("Credits")}}:{{item.credits}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="containerElement"v-else>
|
|
|
|
|
|
|
|
|
|
<div class="containerElement" v-if="editAddCourse == item.title" >
|
|
|
|
|
{{i18n("Curriculum")}}:
|
|
|
|
|
<select v-model="curriculumToAddId">
|
|
|
|
|
<option v-for="element in curriculumToAdd" :value="element.curriculumId">
|
|
|
|
|
{{element.option}}-{{element.year}}
|
|
|
|
|
</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="containerElement" v-if="editElementID == item.title">
|
|
|
|
|
|
|
|
|
|
<input style="max-width:200px;" class="name" v-model="toModify.title">
|
|
|
|
|
<select v-if="self.role != 'Secretary'" style="max-width:200px;" class="teacher" v-model="toModify.owner">
|
|
|
|
|
<option v-for="(item,index) in profList" :value='item'>{{item.lastName}}</option>
|
|
|
|
@ -164,6 +209,8 @@
|
|
|
|
|
<input v-if="self.role !='Secretary'"style="max-width:100px;"class="credits" v-model="toModify.credits">
|
|
|
|
|
<div v-else class="credits">{{i18n("Credits")}}:{{item.credits}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|