add user html done

This commit is contained in:
adri 2019-01-02 10:29:27 +01:00
parent 6ef79d7673
commit a5d08063d8
3 changed files with 62 additions and 8 deletions

View File

@ -57,6 +57,9 @@ $reponse = $bdd->query('SELECT * FROM projetphp');
<?php <?php
} }
?> ?>
<tr rowspan="2">
<td colspan="6" style="text-align:center"><i class="fas fa-user-plus fa-4x click" ></i></td>
</tr>
</tbody> </tbody>
</table> </table>
</body> </body>

View File

@ -1,7 +1,26 @@
$(function() { htmlAddUser = '<tr class="newRecord">\
<td class="login">\
<input type="text" /></td>\
<td class="datene">\
<input type="date" /></td>\
<td class="email">\
<input type="text" /></td>\
<td class="pw">\
<input type="password" /></td>\
<td class="sl">\
<select>\
<option value="1">1</option>\
<option value="5">5</option>\
<option value="10">10</option>\
</select></td>\
<td><i class="fas fa-check click confirmNewUser"></i><i class="fas fa-trash-alt click delUser"></i></td>\
</tr>';
passwordPatern=/^[a-zA-Z0-9]{8,16}$/; passwordPatern=/^[a-zA-Z0-9]{8,16}$/;
loginPatern=/^[a-z]{8,16}$/ loginPatern=/^[a-z]{8,16}$/
mailPatern=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;//https://emailregex.com/ mailPatern=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;//https://emailregex.com/
$(function() {
$("#allRecord").on("keyup", ".pw input", function(){ $("#allRecord").on("keyup", ".pw input", function(){
if(passwordPatern.test($(this).val()) || $(this).val() == "") if(passwordPatern.test($(this).val()) || $(this).val() == "")
{ {
@ -30,6 +49,7 @@ $("#allRecord").on("keyup", ".email input", function(){
/*~~~~~~~~~~~~~~~~TR TO DEL~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~TR TO DEL~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
$("#allRecord").on("click", ".delUser", function() { $("#allRecord").on("click", ".delUser", function() {
newUser = false;
tr = $(this).parent().parent(); tr = $(this).parent().parent();
var login = ""; var login = "";
var sl = ""; var sl = "";
@ -45,10 +65,16 @@ $("#allRecord").on("click", ".delUser", function() {
} }
else else
{ {
swal("error"); try{
login = "New user "+$('.login input', tr).val();
newUser = true;
}
catch(e)
{
swal("error : "+e);
return ; return ;
} }
console.log(sl); }
if(sl == "10") if(sl == "10")
{ {
swal( "Oops" , "You can't del user with sl 10" , "error" ); swal( "Oops" , "You can't del user with sl 10" , "error" );
@ -64,12 +90,19 @@ $("#allRecord").on("click", ".delUser", function() {
}) })
.then((willDelete) => { .then((willDelete) => {
if (willDelete) { if (willDelete) {
if(!newUser)
$.post("post.php", {userToDel: login}, function(){ $.post("post.php", {userToDel: login}, function(){
tr.remove(); tr.remove();
swal("Poof! "+login+" has been deleted!", { swal("Poof! "+login+" has been deleted!", {
icon: "success", icon: "success",
}); });
}) });
else {
tr.remove();
swal("Poof! "+login+" has been deleted!", {
icon: "success",
});
}
} else { } else {
} }
@ -191,6 +224,19 @@ $("#allRecord").on("click", ".delUser", function() {
else else
swal( "Oops" , "Input don't respect rules !" , "error" ); swal( "Oops" , "Input don't respect rules !" , "error" );
}); });
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~ADD USER~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
$("#allRecord").on("click", ".fa-user-plus", function(){
$(this).parent().parent().before(htmlAddUser);
});
$("#allRecord").on("click", ".confirmNewUser", function(){
});
$("#allRecord").on("click", ".delNewUser", function(){
tr = $(this).parent().parent();
tr.remove();
});
}); });
//J'avais plein d'espace a droite en récupérent mon innerHTML //J'avais plein d'espace a droite en récupérent mon innerHTML

View File

@ -16,3 +16,8 @@
input { input {
margin: 0px; margin: 0px;
} }
select
{
margin-bottom: 0px; !important
}