add event

This commit is contained in:
Valentin CZERYBA 2023-11-12 21:19:50 +01:00
parent 6f32a4d1eb
commit ce3c896947
2 changed files with 82 additions and 38 deletions

View File

@ -126,12 +126,12 @@
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="alert alert-warning alert-dismissible hidden" id="notModifiedAlert" role="alert">
<div>Utilisateur non modifié</div>
<div>Évènement non modifié</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="notAuthorizedAlert" role="alert">
<div>Création d'utilisateur non autorisée avec ce compte</div>
<div>Création d'évènement non autorisée avec ce compte</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
@ -141,7 +141,7 @@
</div>
<div class="alert alert-danger alert-dismissible hidden" id="noContentAlert" role="alert">
<div>Utilisateur non modifié</div>
<div>Évènement non modifié</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
@ -197,13 +197,13 @@
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="dateUpdate">Date de début</span>
<input id="startDateUpdateInput" type="date" class="form-control" placeholder="Date de début" aria-label="Date de début" aria-describedby="startDateUpdate">
<span class="input-group-text" id="start_dateUpdate">Date de début</span>
<input id="start_dateUpdateInput" type="datetime-local" class="form-control" placeholder="Date de début" aria-label="Date de début" aria-describedby="start_dateUpdate">
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="endDateUpdate">Date de fin</span>
<input id="endDateUpdateInput" type="date" class="form-control" placeholder="Date de fin" aria-label="Date de fin" aria-describedby="endDateUpdate">
<span class="input-group-text" id="start_dateUpdate">Date de fin</span>
<input id="end_dateUpdateInput" type="datetime-local" class="form-control" placeholder="Date de fin" aria-label="Date de fin" aria-describedby="start_dateUpdate">
</div>
@ -243,11 +243,11 @@
</select>
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button type="button" class="btn btn-success hidden" id="enableUser" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
<button type="button" class="btn btn-success hidden" id="cancelUser" data-bs-toggle="modal" data-bs-target="#cancelUserModal">Annuler la suppression de l'utilisateur</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateUserModal">Mettre à jour l'utilisateur</button>
<button type="button" class="btn btn-warning hidden" id="disableUser" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
<button type="button" class="btn btn-danger" id="removeUser" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
<button type="button" class="btn btn-success hidden" id="enableUser" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'évènement</button>
<button type="button" class="btn btn-success hidden" id="cancelUser" data-bs-toggle="modal" data-bs-target="#cancelUserModal">Annuler la suppression de l'évènement</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateUserModal">Mettre à jour l'évènement</button>
<button type="button" class="btn btn-warning hidden" id="disableUser" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'évènement</button>
<button type="button" class="btn btn-danger" id="removeUser" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'évènement</button>
</div>
<div class="modal fade" id="updateUserModal" tabindex="-1" aria-labelledby="updateUserModal" aria-hidden="true">
<div class="modal-dialog">
@ -311,7 +311,7 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Voulez-vous activer l'utilisateur ?
Voulez-vous activer l'évènement ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
@ -329,11 +329,11 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Voulez-vous annuller la suppression de l'utilisateur ?
Voulez-vous annuler la suppression de l'évènement ?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="button" class="btn btn-success" id="cancelUserButton">Annuler la suppression de l'utilisateur</button>
<button type="button" class="btn btn-success" id="cancelUserButton">Annuler la suppression de l'évènement</button>
</div>
</div>
</div>

View File

@ -8,7 +8,17 @@ var id = getQuery("id");
if(id.length > 0){
instance.get(pathURL + "s/"+id, {withCredentials: true})
.then(function(response){
var listValue = [ "id", "username", "name", "firstName", "email", "birth"];
switch(pathURL){
case "user":
var listValue = [ "id", "username", "name", "firstName", "email", "birth"];
break;
case "event":
var listValue = [ "id", "name", "place", "start_date", "end_date"];
break;
default:
var listValue = []
break;
}
var listTime = ["connected_at", "created_at", "updated_at", "deleted_at", "disabled_at"];
for (var i=0; i<listValue.length; i++){
if(response.data[listValue[i]] != null){
@ -25,10 +35,12 @@ if(id.length > 0){
var listSelector = ["roles", "status"];
for (var i=0; i<listSelector.length; i++){
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
for (var j=0; j<select.length; j++){
if(select[j].value == response.data[listSelector[i]]){
select[j].setAttribute("selected", true);
if (document.getElementById(listSelector[i]+"Selector") != null){
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
for (var j=0; j<select.length; j++){
if(select[j].value == response.data[listSelector[i]]){
select[j].setAttribute("selected", true);
}
}
}
}
@ -103,7 +115,17 @@ if(id.length > 0){
document.getElementById("updateUserButton").addEventListener("click", function(){
var updateProfil = ["id", "username", "email", "firstName", "birth"];
switch(pathURL){
case "user":
var updateProfil = [ "id", "username", "name", "firstName", "email", "birth"];
break;
case "event":
var updateProfil = [ "id", "name", "place", "start_date", "end_date"];
break;
default:
var updateProfil = []
break;
}
var updateOk = true;
for (var i=0; i<updateProfil.length; i++){
if(document.getElementById(updateProfil[i]+"UpdateInput").value.length == 0){
@ -122,23 +144,45 @@ if(id.length > 0){
}
}
}
switch (pathURL){
case "user":
dataPut = {
"id": document.getElementById("idUpdateInput").value,
"username": document.getElementById("usernameUpdateInput").value,
"email": document.getElementById("emailUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"firstName": document.getElementById("firstNameUpdateInput").value,
"birth": document.getElementById("birthUpdateInput").value,
"status": selector["status"],
"password": document.getElementById("passwordUpdateInput").value,
"roles": selector["roles"],
"created_at": "",
"updated_at": "",
"deleted_at": "",
"disabled_at":"",
"connected_at": ""
dataPut = {
"id": document.getElementById("idUpdateInput").value,
"username": document.getElementById("usernameUpdateInput").value,
"email": document.getElementById("emailUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"firstName": document.getElementById("firstNameUpdateInput").value,
"birth": document.getElementById("birthUpdateInput").value,
"status": selector["status"],
"password": document.getElementById("passwordUpdateInput").value,
"roles": selector["roles"],
"created_at": "",
"updated_at": "",
"deleted_at": "",
"disabled_at":"",
"connected_at": ""
};
break;
case "event":
dataPut = {
"id": document.getElementById("idUpdateInput").value,
"name": document.getElementById("nameUpdateInput").value,
"place": document.getElementById("placeUpdateInput").value,
"start_date": document.getElementById("start_dateUpdateInput").value,
"end_date": document.getElementById("end_dateUpdateInput").value,
"status": selector["status"],
"created_at": "",
"updated_at": "",
"deleted_at": "",
"disabled_at":"",
"connected_at": ""
};
break;
default:
datePut = {};
break;
}
instance({
method : "put",