Leo/InscriptionDesEtudiant #161
@ -20,6 +20,7 @@ import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@ -196,4 +197,58 @@ public class RequestsController {
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/changecurriculumreq")
|
||||
public ResponseEntity<ArrayList <ChangeCurriculumRequest>> getAllChangeCurrReq(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<ChangeCurriculumRequest> toReturn = new ArrayList<>();
|
||||
|
||||
changeCurriculumRequestRepository.findAll().forEach(toReturn::add);
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/changecurriculumreq/{id}")
|
||||
public ResponseEntity<ChangeCurriculumRequest> getCCrbyId(@RequestHeader("Authorization") String token, @PathVariable long id){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ChangeCurriculumRequest toReturn = changeCurriculumRequestRepository.findById(id);
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PatchMapping("/changecurriculumreq/{id}/{newState}")
|
||||
public ResponseEntity<String> editCCReq(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newState){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ChangeCurriculumRequest toEdit = changeCurriculumRequestRepository.findById(id);
|
||||
|
||||
toEdit.setState(newState);
|
||||
|
||||
if (newState == RequestState.Accepted){
|
||||
//If actual curriculum is not null then we need to set that the user doesn't follow it anymore
|
||||
User u = toEdit.getUser();
|
||||
if (toEdit.getActualCurriculum() != null){
|
||||
ArrayList<UserCurriculum> listcurr = userCurriculumRepository.findByUserOrderByCurriculum(u);
|
||||
|
||||
for (int i = 0; i < listcurr.size(); i++){
|
||||
if (listcurr.get(i).getCurriculum() == toEdit.getActualCurriculum()){
|
||||
listcurr.get(i).setActual(false);
|
||||
}
|
||||
}
|
||||
|
||||
userCurriculumRepository.saveAll(listcurr);
|
||||
}
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
UserCurriculum userCurriculum = new UserCurriculum(u, toEdit.getDestinationCurriculum(), c.get(Calendar.YEAR), true);
|
||||
userCurriculumRepository.save(userCurriculum);
|
||||
}
|
||||
|
||||
changeCurriculumRequestRepository.save(toEdit);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,6 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.ChangeCurriculumRequest;
|
||||
|
||||
public interface ChangeCurriculumRequestRepository extends CrudRepository<ChangeCurriculumRequest, Long> {
|
||||
ChangeCurriculumRequest findById(long id);
|
||||
}
|
||||
|
||||
|
@ -15,4 +15,5 @@ public interface UserCurriculumRepository extends CrudRepository<UserCurriculum,
|
||||
|
||||
ArrayList<UserCurriculum> findByUserOrderByCurriculum(User student);
|
||||
UserCurriculum findByUserAndCurriculumAndActual(User user, Curriculum curriculum, boolean actual);
|
||||
|
||||
}
|
||||
|
115
frontend/src/Apps/Inscription/AboutChangeCurriculum.vue
Normal file
115
frontend/src/Apps/Inscription/AboutChangeCurriculum.vue
Normal file
@ -0,0 +1,115 @@
|
||||
<script setup>
|
||||
|
||||
import {
|
||||
addUninscReq, editChangeCurrReq,
|
||||
editScholarshipReq,
|
||||
editUnregReq, getChangeCurrReqById,
|
||||
getScholarshipReqById,
|
||||
getUnregisterbyId
|
||||
} from "@/rest/requests.js";
|
||||
import i18n from "@/i18n.js";
|
||||
import {getUser} from "@/rest/Users.js";
|
||||
import {reactive, ref} from "vue";
|
||||
import AboutStudent from "@/Apps/Inscription/AboutStudent.vue";
|
||||
|
||||
const props = defineProps(["reqId"])
|
||||
const req = ref(await getChangeCurrReqById(props.reqId))
|
||||
|
||||
|
||||
//0 liste, 1 profil
|
||||
const windowstate = ref(0);
|
||||
|
||||
const tag = req.value.user.regNo
|
||||
|
||||
async function uploadandrefreshChangeRequest(state){
|
||||
await editChangeCurrReq(req.value.id, state);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="body" v-if="windowstate === 0">
|
||||
<div class="container">
|
||||
<div class="globalInfos">
|
||||
<div class="infosContainer">
|
||||
<div>
|
||||
Firstname/Name : {{req.user.firstName}} {{req.user.lastName}}
|
||||
</div>
|
||||
<div>
|
||||
regNo : {{req.user.regNo}}
|
||||
</div>
|
||||
<div v-if="req.actualCurriculum !== null">
|
||||
From : Bac {{req.actualCurriculum.year}} {{req.actualCurriculum.option}}
|
||||
To : Bac {{req.destinationCurriculum.year}} {{req.destinationCurriculum.option}}
|
||||
</div>
|
||||
<div v-else>
|
||||
Wanted cursus : Bac {{req.destinationCurriculum.year}} {{req.destinationCurriculum.option}}
|
||||
</div>
|
||||
<div>
|
||||
<button @click="windowstate++"> See profile </button>
|
||||
</div>
|
||||
<div>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Accepted';uploadandrefreshChangeRequest('Accepted')">Accept</button>
|
||||
<button v-if="req.state === 'Pending'" @click="req.state='Refused';uploadandrefreshChangeRequest('Refused')" style="margin-left: 2%;">Refuse</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="windowstate === 1">
|
||||
<AboutStudent :target="tag"></AboutStudent>
|
||||
<button @click="windowstate--;">Return to request</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container{
|
||||
min-width:675px;
|
||||
display:grid;
|
||||
grid-template-columns:10vw 50vw;
|
||||
grid-template-rows:200px auto;
|
||||
column-gap:2.7%;
|
||||
row-gap:45px;
|
||||
grid-template-areas:
|
||||
"profilPic globalInfos"
|
||||
"minfos minfos";
|
||||
}
|
||||
|
||||
.profilPic{
|
||||
width:100%;
|
||||
grid-area:profilPic;
|
||||
}
|
||||
|
||||
.globalInfos {
|
||||
grid-area:globalInfos;
|
||||
align-self :center;
|
||||
|
||||
}
|
||||
|
||||
.body {
|
||||
min-width:960px;
|
||||
width:100%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:7%;
|
||||
}
|
||||
|
||||
.subContainter{
|
||||
width:100%;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
border:4px solid black;
|
||||
}
|
||||
|
||||
.infosContainer {
|
||||
min-width:350px;
|
||||
padding-bottom:50px;
|
||||
border:2px solid black;
|
||||
font-size:25px;
|
||||
color:white;
|
||||
padding:20px;
|
||||
background-color:rgb(50,50,50);
|
||||
border-radius:20px;
|
||||
}
|
||||
</style>
|
@ -3,9 +3,15 @@
|
||||
import {ref} from 'vue'
|
||||
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
||||
import AboutRequest from "@/Apps/Inscription/AboutRequest.vue";
|
||||
import {getAllExemptionsRequest, getAllScholarShipsRequest, getAllUnregisters} from "@/rest/requests.js";
|
||||
import {
|
||||
getAllChangeCurrReq,
|
||||
getAllExemptionsRequest,
|
||||
getAllScholarShipsRequest,
|
||||
getAllUnregisters
|
||||
} from "@/rest/requests.js";
|
||||
import AboutScholarship from "@/Apps/Inscription/AboutScholarship.vue";
|
||||
import AboutUnregister from "@/Apps/Inscription/AboutUnregister.vue";
|
||||
import AboutChangeCurriculum from "@/Apps/Inscription/AboutChangeCurriculum.vue";
|
||||
|
||||
const requests = ref(await getAllRegisters());
|
||||
let targetId = "";
|
||||
@ -13,7 +19,7 @@
|
||||
const requestType = ref("inscription");
|
||||
const filterType = ref("None");
|
||||
|
||||
//0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship, 4 manage unregister
|
||||
//0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship, 4 manage unregister, 5 = manage curriculum change
|
||||
let windowsState = ref(0);
|
||||
|
||||
async function upPage(id,review){
|
||||
@ -35,6 +41,9 @@
|
||||
break;
|
||||
case "unregister":
|
||||
requests.value = await getAllUnregisters();
|
||||
break;
|
||||
case "curriculum change":
|
||||
requests.value = await getAllChangeCurrReq();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -53,6 +62,7 @@
|
||||
<option>scholarship</option>
|
||||
<option>exemption</option>
|
||||
<option>unregister</option>
|
||||
<option>curriculum change</option>
|
||||
</select>
|
||||
<span style="margin-left: 5%">
|
||||
Filter :
|
||||
@ -104,6 +114,13 @@
|
||||
<div class="reqState">{{item.state}}</div>
|
||||
<div class="infos"><button @click="windowsState=4;targetId=item.id">More infos</button></div>
|
||||
</div>
|
||||
<div class="container" v-if="requestType === 'curriculum change'" style="grid-template-columns:17% 15% 12% 15%;grid-template-areas:'date reqState regno studentfirstname studentlastname infos';">
|
||||
<div class="date" v-if="item.date != undefined">{{item.date.slice(0,10)}}</div>
|
||||
<div class="studentfirstname">{{item.user.firstName}}</div>
|
||||
<div class="studentlastname">{{item.user.lastName}}</div>
|
||||
<div class="reqState">{{item.state}}</div>
|
||||
<div class="infos"><button @click="windowsState=5;targetId=item.id">More infos</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -121,6 +138,9 @@
|
||||
<div v-if="windowsState === 4">
|
||||
<AboutUnregister :req-id="targetId"></AboutUnregister>
|
||||
</div>
|
||||
<div v-if="windowsState === 5">
|
||||
<AboutChangeCurriculum :req-id="targetId"></AboutChangeCurriculum>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
@ -50,4 +50,16 @@ export async function getAllPayments(){
|
||||
|
||||
export async function postChangeCurrReq(item){
|
||||
return restPost("/changecurriculumreq", item)
|
||||
}
|
||||
|
||||
export async function getAllChangeCurrReq(){
|
||||
return restGet("/changecurriculumreq")
|
||||
}
|
||||
|
||||
export async function getChangeCurrReqById(id){
|
||||
return restGet("/changecurriculumreq/"+id)
|
||||
}
|
||||
|
||||
export async function editChangeCurrReq(id, newState){
|
||||
return restPatch("/changecurriculumreq/"+id+"/"+newState)
|
||||
}
|
Loading…
Reference in New Issue
Block a user