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">
|
<div class="input-group mb-3">
|
||||||
<span class="input-group-text" id="placeUpdate">Lieu</span>
|
<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="placeUpdateInput"></div>
|
||||||
<div id="geocoder"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<span class="input-group-text" id="start_dateUpdate">Date de début de l'évènement</span>
|
<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/config.js"></script>
|
||||||
<script src="../js/library.js"></script>
|
<script src="../js/library.js"></script>
|
||||||
<script src="../js/addItem.js"></script>
|
|
||||||
<script src="../js/geosearch.js"></script>
|
<script src="../js/geosearch.js"></script>
|
||||||
|
<script src="../js/addItem.js"></script>
|
||||||
|
|
||||||
</body></html>
|
</body></html>
|
@ -5,10 +5,25 @@ pathURL = document.location.pathname.split("/")[document.location.pathname.split
|
|||||||
|
|
||||||
|
|
||||||
document.getElementById("addUser").addEventListener("click", function(){
|
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;
|
var updateOk = true;
|
||||||
for (var i=0; i<updateProfil.length; i++){
|
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;
|
updateOk = false;
|
||||||
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
|
document.getElementById(updateProfil[i]+"Alert").classList.remove("hidden");
|
||||||
}
|
}
|
||||||
@ -24,15 +39,30 @@ document.getElementById("addUser").addEventListener("click", function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch(pathURL){
|
||||||
dataPut = {
|
case "users":
|
||||||
"username": document.getElementById("usernameUpdateInput").value,
|
dataPut = {
|
||||||
"email": document.getElementById("emailUpdateInput").value,
|
"username": document.getElementById("usernameUpdateInput").value,
|
||||||
"name": document.getElementById("nameUpdateInput").value,
|
"email": document.getElementById("emailUpdateInput").value,
|
||||||
"firstName": document.getElementById("firstNameUpdateInput").value,
|
"name": document.getElementById("nameUpdateInput").value,
|
||||||
"birth": document.getElementById("birthUpdateInput").value,
|
"firstName": document.getElementById("firstNameUpdateInput").value,
|
||||||
"password": document.getElementById("passwordUpdateInput").value,
|
"birth": document.getElementById("birthUpdateInput").value,
|
||||||
"roles": selector["roles"]
|
"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({
|
instance({
|
||||||
method : "put",
|
method : "put",
|
||||||
@ -65,7 +95,7 @@ document.getElementById("addUser").addEventListener("click", function(){
|
|||||||
for(var i=0; i<listExist.length; i++){
|
for(var i=0; i<listExist.length; i++){
|
||||||
if(error.response.data[listExist[i]]){
|
if(error.response.data[listExist[i]]){
|
||||||
document.getElementById(listExist[i]+"ExistAlert").classList.remove("hidden");
|
document.getElementById(listExist[i]+"ExistAlert").classList.remove("hidden");
|
||||||
}
|
}1
|
||||||
}
|
}
|
||||||
idAlert="notAuthorized";
|
idAlert="notAuthorized";
|
||||||
break;
|
break;
|
||||||
|
@ -4,4 +4,4 @@ accessToken: mapboxgl.accessToken,
|
|||||||
types: 'country,region,place,postcode,locality,neighborhood'
|
types: 'country,region,place,postcode,locality,neighborhood'
|
||||||
});
|
});
|
||||||
|
|
||||||
geocoder.addTo('#geocoder');
|
geocoder.addTo('#placeUpdateInput');
|
Loading…
x
Reference in New Issue
Block a user