2024-03-12 11:10:14 +01:00
|
|
|
<script setup>
|
2024-03-14 21:27:03 +01:00
|
|
|
import i18n from "@/i18n.js"
|
2024-03-13 15:07:17 +01:00
|
|
|
import {ref} from 'vue'
|
2024-03-16 14:31:44 +01:00
|
|
|
import { getCourses,deleteCourse,alterCourse,createCourse } from "@/rest/courses.js"
|
2024-03-13 18:22:28 +01:00
|
|
|
import { getTeachers } from "@/rest/Users.js"
|
2024-03-12 11:10:14 +01:00
|
|
|
|
2024-03-16 12:01:44 +01:00
|
|
|
const curriculum = await getCourses()
|
2024-03-13 15:07:17 +01:00
|
|
|
|
2024-03-13 18:22:28 +01:00
|
|
|
const profList = getTeachers()
|
2024-03-13 17:48:48 +01:00
|
|
|
|
|
|
|
const createMod = ref(false)
|
|
|
|
const deleteMod = ref(false)
|
|
|
|
|
2024-03-13 18:22:28 +01:00
|
|
|
const editElementID = ref("")
|
2024-03-13 17:48:48 +01:00
|
|
|
|
|
|
|
function editItem(id){
|
|
|
|
editElementID = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Juste pour montrer le Create Mode
|
2024-03-13 15:07:17 +01:00
|
|
|
const pattern = {
|
|
|
|
"name": null,
|
|
|
|
"credits": null,
|
|
|
|
"faculty": null,
|
|
|
|
"teacher": null,
|
|
|
|
"Assistants": []}
|
|
|
|
|
|
|
|
|
|
|
|
let toAdd = Object.assign({}, pattern);
|
|
|
|
|
2024-03-16 14:31:44 +01:00
|
|
|
function addToCourse(){
|
|
|
|
if (curriculum.length>0){
|
|
|
|
let isnull= false;
|
|
|
|
for(const [key, value] of Object.entries(toAdd)){
|
|
|
|
if(value === null){
|
|
|
|
isnull=true;
|
|
|
|
}
|
2024-03-13 15:07:17 +01:00
|
|
|
}
|
2024-03-16 14:31:44 +01:00
|
|
|
if (!isnull){
|
|
|
|
createCourse(toAdd.name,toAdd.credits,toAdd.faculty,toAdd.teacher,toAdd.Assistants);
|
|
|
|
}
|
|
|
|
toAdd= Object.assign({},pattern);
|
|
|
|
}
|
|
|
|
}
|
2024-03-13 17:48:48 +01:00
|
|
|
//Juste pour montrer le Delete Mode
|
|
|
|
let toRemove;
|
|
|
|
|
2024-03-16 14:31:44 +01:00
|
|
|
function removeCourse(course) {
|
|
|
|
deleteCourse(course.id)
|
|
|
|
}
|
2024-03-13 15:07:17 +01:00
|
|
|
|
2024-03-12 11:10:14 +01:00
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div class="body">
|
2024-03-13 17:48:48 +01:00
|
|
|
<div v-if="!deleteMod && !createMod" class="listTitle buttonGrid">
|
|
|
|
<button class="create" @click="createMod = true">
|
2024-03-14 22:33:16 +01:00
|
|
|
{{i18n("courses.createCourse")}}
|
2024-03-13 15:07:17 +01:00
|
|
|
</button>
|
2024-03-13 17:48:48 +01:00
|
|
|
<button class="delete" @click="deleteMod=true" >
|
2024-03-14 22:33:16 +01:00
|
|
|
{{i18n("courses.deleteCourse")}}
|
2024-03-13 15:07:17 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div v-if="createMod">
|
|
|
|
<form class="listElement">
|
2024-03-13 17:48:48 +01:00
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("name")}} :
|
2024-03-13 15:07:17 +01:00
|
|
|
<input v-model="toAdd.name">
|
|
|
|
</div>
|
2024-03-13 17:48:48 +01:00
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("teacher")}} :
|
2024-03-13 15:07:17 +01:00
|
|
|
<select style="max-width:200px;" class="teacher" v-model="toAdd.teacher">
|
|
|
|
<option v-for="item in profList">{{item}}</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2024-03-13 17:48:48 +01:00
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("credits")}} :
|
2024-03-13 15:07:17 +01:00
|
|
|
<input v-model="toAdd.credits">
|
|
|
|
</div>
|
2024-03-13 17:48:48 +01:00
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("faculty")}} :
|
2024-03-13 15:07:17 +01:00
|
|
|
<input v-model="toAdd.faculty">
|
|
|
|
</div>
|
2024-03-14 21:27:03 +01:00
|
|
|
<button class="create" @click="createMod=!createMod; addToCourse();"> {{i18n("courses.confirm")}} </button>
|
|
|
|
<button style="float:right;" @click="createMod=!createMod">{{i18n("courses.back")}}</button>
|
2024-03-13 17:48:48 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div v-if="deleteMod">
|
|
|
|
<form class="listElement">
|
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("courses.toDelete")}} :
|
2024-03-13 17:48:48 +01:00
|
|
|
<select style="max-width:200px;" class="teacher" v-model="toRemove">
|
2024-03-16 10:17:04 +01:00
|
|
|
<option v-for="item in curriculum">{{item.name}}</option>
|
2024-03-13 17:48:48 +01:00
|
|
|
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("login.password")}}:
|
2024-03-13 17:48:48 +01:00
|
|
|
<input >
|
|
|
|
</div>
|
|
|
|
<div style="margin-bottom:20px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
{{i18n("login.cPassword")}} :
|
2024-03-13 17:48:48 +01:00
|
|
|
<input>
|
|
|
|
</div>
|
2024-03-16 14:31:44 +01:00
|
|
|
<button class="delete" @click="deleteMod=!deleteMod;removeCourse(toRemove);"> {{i18n("courses.deleteCourse")}} </button>
|
2024-03-14 21:27:03 +01:00
|
|
|
<button style="float:right;" @click="deleteMod=!deleteMod"> {{i18n("courses.back")}}</button>
|
2024-03-13 15:07:17 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
2024-03-13 17:48:48 +01:00
|
|
|
|
2024-03-16 10:17:04 +01:00
|
|
|
<div v-if="!createMod && !deleteMod" v-for="item in curriculum" :key="item.name">
|
2024-03-13 15:07:17 +01:00
|
|
|
<div style ="padding:15px 15px 15px 15px;">
|
2024-03-14 21:27:03 +01:00
|
|
|
<button v-if="editElementID !== item.name" @click="editElementID = item.name">
|
|
|
|
{{i18n("courses.modify")}}
|
|
|
|
</button>
|
|
|
|
<button v-else @click="editElementID= ''"> {{i18n("courses.confirm")}} </button>
|
2024-03-13 15:07:17 +01:00
|
|
|
</div>
|
|
|
|
<div class="listElement" >
|
|
|
|
<div class="containerElement" v-if="editElementID !== item.name" >
|
|
|
|
|
2024-03-12 11:10:14 +01:00
|
|
|
<div class="name"> {{item.name}} </div>
|
|
|
|
<div class="teacher">{{item.teacher}}</div>
|
2024-03-14 21:27:03 +01:00
|
|
|
<div class="credits">{{i18n("credits")}}:{{item.credits}}</div>
|
2024-03-12 11:10:14 +01:00
|
|
|
</div>
|
2024-03-13 15:07:17 +01:00
|
|
|
<div class="containerElement"v-else>
|
|
|
|
<input style="max-width:200px;" class="name" v-model="item.name">
|
|
|
|
<select style="max-width:200px;" class="teacher" v-model="item.teacher">
|
|
|
|
<option v-for="item in profList">{{item}}</option>
|
|
|
|
</select>
|
|
|
|
<input style="max-width:100px;"class="credits" v-model="item.credits">
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-03-12 11:10:14 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.body {
|
|
|
|
width:100%;
|
|
|
|
margin-bottom:10px;
|
|
|
|
}
|
|
|
|
.containerElement{
|
|
|
|
justify-content:center;
|
|
|
|
display:grid;
|
|
|
|
grid-template-columns:350px 350px 200px;
|
|
|
|
grid-template-areas:
|
|
|
|
"name teacher credits";
|
|
|
|
column-gap:10px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
|
|
|
grid-area:name;
|
|
|
|
align-self:center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.teacher{
|
|
|
|
grid-area:teacher;
|
|
|
|
align-self:center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.credits{
|
|
|
|
grid-area:credits;
|
|
|
|
align-self:center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.listElement{
|
|
|
|
border:2px solid black;
|
|
|
|
font-size:25px;
|
|
|
|
color:white;
|
|
|
|
padding:20px;
|
|
|
|
background-color:rgb(50,50,50);
|
|
|
|
border-radius:20px;
|
|
|
|
margin-bottom:10px;
|
|
|
|
}
|
2024-03-13 15:07:17 +01:00
|
|
|
|
|
|
|
.modify{
|
|
|
|
font-size:25px;
|
|
|
|
padding:10px 10px 10px 10px;
|
|
|
|
background-color: rgb(239,60,168);
|
|
|
|
cursor: pointer;
|
|
|
|
border:none;
|
|
|
|
border-radius:15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
input, select{
|
2024-03-13 17:48:48 +01:00
|
|
|
padding:10px 10px 10px 10px;
|
2024-03-13 15:07:17 +01:00
|
|
|
font-size:25px;
|
|
|
|
cursor: pointer;
|
|
|
|
border:none;
|
|
|
|
border-radius:15px;
|
|
|
|
}
|
|
|
|
button{
|
|
|
|
font-size:15px;
|
|
|
|
height:50px;
|
|
|
|
width:100px;
|
|
|
|
border:none;
|
|
|
|
border-radius:20px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.buttonGrid{
|
|
|
|
display:grid;
|
|
|
|
grid-template-columns: auto auto;
|
|
|
|
column-gap:50px;
|
|
|
|
grid-template-areas:
|
|
|
|
"create delete";
|
|
|
|
}
|
|
|
|
|
|
|
|
.create{
|
|
|
|
grid-area:create;
|
|
|
|
|
|
|
|
background-color:rgb(0,200,0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.delete{
|
|
|
|
grid-area:delete;
|
|
|
|
background-color:rgb(200,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
.listTitle{
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
width:400px;
|
|
|
|
margin-left:auto;
|
|
|
|
margin-right:auto;
|
|
|
|
border:2px solid black;
|
|
|
|
font-size:25px;
|
|
|
|
color:white;
|
|
|
|
padding:20px;
|
|
|
|
background-color:rgb(50,50,50);
|
|
|
|
border-radius:20px;margin-bottom:10px;
|
|
|
|
|
|
|
|
button:hover{
|
|
|
|
opacity:0.8;
|
|
|
|
}
|
|
|
|
}
|
2024-03-12 11:10:14 +01:00
|
|
|
</style>
|