forked from v4l3n71n/covas-bo
additem with events
This commit is contained in:
parent
df40e849a2
commit
f5135eb85a
@ -183,8 +183,7 @@
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="placeUpdate">Lieu</span>
|
||||
<input id="placeUpdateInput" type="text" class="form-control" placeholder="Lieu" aria-label="Lieu" aria-describedby="placeUpdate">
|
||||
<div id="geocoder"></div>
|
||||
<div id="placeUpdateInput"></div>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="start_dateUpdate">Date de début de l'évènement</span>
|
||||
@ -213,6 +212,7 @@
|
||||
|
||||
<script src="../js/config.js"></script>
|
||||
<script src="../js/library.js"></script>
|
||||
<script src="../js/addItem.js"></script>
|
||||
<script src="../js/geosearch.js"></script>
|
||||
<script src="../js/addItem.js"></script>
|
||||
|
||||
</body></html>
|
@ -5,10 +5,25 @@ pathURL = document.location.pathname.split("/")[document.location.pathname.split
|
||||
|
||||
|
||||
document.getElementById("addUser").addEventListener("click", function(){
|
||||
var updateProfil = ["username", "email", "firstName", "birth", "password"];
|
||||
switch (pathURL){
|
||||
case "users":
|
||||
var updateProfil = ["username", "email", "firstName", "birth", "password"];
|
||||
break;
|
||||
case "events":
|
||||
var updateProfil = ["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){
|
||||
if(updateProfile[i] == "place"){
|
||||
size = document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value.length
|
||||
} else {
|
||||
size= document.getElementById(updateProfil[i]+"UpdateInput").value.length
|
||||
}
|
||||
if(size == 0){
|
||||
updateOk = false;
|
||||
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
|
||||
}
|
||||
@ -24,15 +39,30 @@ document.getElementById("addUser").addEventListener("click", function(){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataPut = {
|
||||
"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,
|
||||
"password": document.getElementById("passwordUpdateInput").value,
|
||||
"roles": selector["roles"]
|
||||
switch(pathURL){
|
||||
case "users":
|
||||
dataPut = {
|
||||
"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,
|
||||
"password": document.getElementById("passwordUpdateInput").value,
|
||||
"roles": selector["roles"]
|
||||
};
|
||||
break;
|
||||
case "events":
|
||||
dataPut = {
|
||||
"name": document.getElementById("nameUpdateInput").value,
|
||||
"place": document.getElementsByClassName("mapboxgl-ctrl-geocoder--input")[0].value,
|
||||
"start_date": document.getElementById("start_dateUpdateInput").value,
|
||||
"end_date": document.getElementById("end_dateUpdateInput").value,
|
||||
};
|
||||
break;
|
||||
default:
|
||||
dataPut = {};
|
||||
break;
|
||||
|
||||
}
|
||||
instance({
|
||||
method : "put",
|
||||
@ -65,7 +95,7 @@ document.getElementById("addUser").addEventListener("click", function(){
|
||||
for(var i=0; i<listExist.length; i++){
|
||||
if(error.response.data[listExist[i]]){
|
||||
document.getElementById(listExist[i]+"ExistAlert").classList.remove("hidden");
|
||||
}
|
||||
}1
|
||||
}
|
||||
idAlert="notAuthorized";
|
||||
break;
|
||||
|
@ -4,4 +4,4 @@ accessToken: mapboxgl.accessToken,
|
||||
types: 'country,region,place,postcode,locality,neighborhood'
|
||||
});
|
||||
|
||||
geocoder.addTo('#geocoder');
|
||||
geocoder.addTo('#placeUpdateInput');
|
Loading…
x
Reference in New Issue
Block a user