1
0
forked from PGL/Clyde

Remove course

This commit is contained in:
Wawilski 2024-03-13 17:48:48 +01:00 committed by Wal
parent 354793a29f
commit 7d8e1113cc

View File

@ -14,18 +14,30 @@ const cursus=[
"name": "Operating Systems", "name": "Operating Systems",
"credits": 8, "credits": 8,
"faculty": "science", "faculty": "science",
"teacher": 14, "teacher": 62,
"Assistants": []}, "Assistants": []},
{ {
"id": 52, "id": 52,
"name": "Fonctionnement des ordinateurs", "name": "Fonctionnement des ordinateurs",
"credits": 11, "credits": 11,
"faculty": "science", "faculty": "science",
"teacher": 42, "teacher": 59,
"Assistants": []}, "Assistants": []},
] ]
const profList=[42,45,62,84,59]
const createMod = ref(false)
const deleteMod = ref(false)
const editElementID = ref("");
function editItem(id){
editElementID = id;
}
//Juste pour montrer le Create Mode
const pattern = { const pattern = {
"id": 0, "id": 0,
@ -35,73 +47,107 @@ const cursus=[
"teacher": null, "teacher": null,
"Assistants": []} "Assistants": []}
const profList=[42,45,62,84,59]
const createMod = ref(false)
const deleteMod = ref(false)
const editElementID = ref("");
let toAdd = Object.assign({}, pattern); let toAdd = Object.assign({}, pattern);
function addToCourse (){ function addToCourse (){
toAdd.id=(cursus[cursus.length-1].id)-1; if (cursus.length>0){
toAdd.id=(cursus[cursus.length-1].id)-1;}
else{
toAdd.id=0;
}
let isnull= false; let isnull= false;
for(const [key, value] of Object.entries(toAdd)){ for(const [key, value] of Object.entries(toAdd)){
console.log(value)
if(value === null){ if(value === null){
isnull=true; isnull=true;
} }
console.log(isnull)
} }
console.log(toAdd)
if (!isnull){ if (!isnull){
cursus.push(toAdd); cursus.push(toAdd);
} }
toAdd= Object.assign({},pattern); toAdd= Object.assign({},pattern);
} }
function editItem(id){
editElementID = id; //Juste pour montrer le Delete Mode
let toRemove;
function removeCourse() {
console.log("ok");
console.log(toRemove);
let rem=-1;
for(const [key, value] of Object.entries(cursus)){
console.log(key);
console.log(value)
if(value.name === toRemove){
rem = key;
break;
}
}
console.log(rem)
if (rem > -1){
cursus.splice(rem, 1);}
console.log(cursus);
} }
</script> </script>
<template> <template>
<div class="body"> <div class="body">
<div class="listTitle buttonGrid"> <div v-if="!deleteMod && !createMod" class="listTitle buttonGrid">
<button class="create" @click="createMod = true" v-if="!deleteMod && !createMod"> <button class="create" @click="createMod = true">
Create Course Create Course
</button> </button>
<button v-if="createMod" class="create" @click="createMod=!createMod; addToCourse();"> Confirm </button> <button class="delete" @click="deleteMod=true" >
<button class="delete" @click="deleteMod=true" v-if="!deleteMod && !createMod">
Delete Course Delete Course
</button> </button>
</div> </div>
<div v-if="createMod"> <div v-if="createMod">
<form class="listElement"> <form class="listElement">
<div> <div style="margin-bottom:20px;">
Name: Name:
<input v-model="toAdd.name"> <input v-model="toAdd.name">
</div> </div>
<div> <div style="margin-bottom:20px;">
Teacher: Teacher:
<select style="max-width:200px;" class="teacher" v-model="toAdd.teacher"> <select style="max-width:200px;" class="teacher" v-model="toAdd.teacher">
<option v-for="item in profList">{{item}}</option> <option v-for="item in profList">{{item}}</option>
</select> </select>
</div> </div>
<div> <div style="margin-bottom:20px;">
Credit: Credits:
<input v-model="toAdd.credits"> <input v-model="toAdd.credits">
</div> </div>
<div> <div style="margin-bottom:20px;">
Faculty: Faculty:
<input v-model="toAdd.faculty"> <input v-model="toAdd.faculty">
</div> </div>
<button class="create" @click="createMod=!createMod; addToCourse();"> Confirm </button>
<button style="float:right;" @click="createMod=!createMod"> Back</button>
</form> </form>
</div> </div>
<div v-if="!createMod" v-for="item in cursus" :key="item.name"> <div v-if="deleteMod">
<form class="listElement">
<div style="margin-bottom:20px;">
Course to delete:
<select style="max-width:200px;" class="teacher" v-model="toRemove">
<option v-for="item in cursus">{{item.name}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
Password:
<input >
</div>
<div style="margin-bottom:20px;">
Confirm Password:
<input>
</div>
<button class="delete" @click="deleteMod=!deleteMod;removeCourse();"> Delete </button>
<button style="float:right;" @click="deleteMod=!deleteMod"> Back</button>
</form>
</div>
<div v-if="!createMod && !deleteMod" v-for="item in cursus" :key="item.name">
<div style ="padding:15px 15px 15px 15px;"> <div style ="padding:15px 15px 15px 15px;">
<button v-if="editElementID !== item.name" @click="editElementID = item.name"> Modify</button> <button v-if="editElementID !== item.name" @click="editElementID = item.name"> Modify</button>
<button v-else @click="editElementID= ''"> Confirm </button> <button v-else @click="editElementID= ''"> Confirm </button>
@ -175,7 +221,7 @@ const profList=[42,45,62,84,59]
} }
input, select{ input, select{
padding:10px 10px 10px 10px;
font-size:25px; font-size:25px;
cursor: pointer; cursor: pointer;
border:none; border:none;