Commit 1203b7d5 authored by Mat's avatar Mat

nettoyage indentations

parent 0de3b2e6
......@@ -76,75 +76,75 @@
AJAX('GET', ownersURL, function(request)
{
// Récupère le json et boucle pour créer le tableau
let json = JSON.parse(request.responseText);
for (let i = 0; i < json.length; i++)
{
// Récupère le json et boucle pour créer le tableau
let json = JSON.parse(request.responseText);
for (let i = 0; i < json.length; i++)
{
let tr = document.createElement('tr');
let tr = document.createElement('tr');
let td0 = document.createElement('td');
td0.textContent = json[i].id;
tr.appendChild(td0);
let td0 = document.createElement('td');
td0.textContent = json[i].id;
tr.appendChild(td0);
let td1 = document.createElement('td');
td1.textContent = json[i].lastname;
tr.appendChild(td1);
let td1 = document.createElement('td');
td1.textContent = json[i].lastname;
tr.appendChild(td1);
let td2 = document.createElement('td');
td2.textContent = json[i].firstname;
tr.appendChild(td2);
let td2 = document.createElement('td');
td2.textContent = json[i].firstname;
tr.appendChild(td2);
let td3 = document.createElement('td');
td3.textContent = formatStringDate(json[i].created_at);
tr.appendChild(td3);
let td3 = document.createElement('td');
td3.textContent = formatStringDate(json[i].created_at);
tr.appendChild(td3);
let td4 = document.createElement('td');
let td4 = document.createElement('td');
// Boutons edit
let editBtn = document.createElement('button');
editBtn.dataset.ownerId = json[i].id;
editBtn.innerHTML = '<i class="fas fa-edit fa-fw"></i> Editer';
editBtn.classList.add('btn', 'btn-primary');
editBtn.addEventListener('click', function()
{
let ownerId = this.dataset.ownerId;
submitURL = Routing.generate('api_owner_update', {'id': ownerId});
AJAX('GET', submitURL, function(request)
{
let json = JSON.parse(request.responseText);
form.querySelector('#owner_firstname').value = json.firstname;
form.querySelector('#owner_lastname').value = json.lastname;
form.parentNode.classList.remove('hidden');
});
// Boutons edit
let editBtn = document.createElement('button');
editBtn.dataset.ownerId = json[i].id;
editBtn.innerHTML = '<i class="fas fa-edit fa-fw"></i> Editer';
editBtn.classList.add('btn', 'btn-primary');
editBtn.addEventListener('click', function()
{
let ownerId = this.dataset.ownerId;
submitURL = Routing.generate('api_owner_update', {'id': ownerId});
});
td4. appendChild(editBtn);
// Boutons delete
let deleteBtn = document.createElement('button');
deleteBtn.dataset.ownerId = json[i].id;
deleteBtn.innerHTML = '<i class="fas fa-trash fa-fw"></i> Supprimer';
deleteBtn.classList.add('btn', 'btn-danger');
deleteBtn.addEventListener('click', function()
AJAX('GET', submitURL, function(request)
{
let ownerId = this.dataset.ownerId;
let r = confirm('Are you sure ?');
if (r === true) {
let json = JSON.parse(request.responseText);
form.querySelector('#owner_firstname').value = json.firstname;
form.querySelector('#owner_lastname').value = json.lastname;
form.parentNode.classList.remove('hidden');
});
submitURL = Routing.generate('api_owner_delete_one', {'id': ownerId});
});
td4. appendChild(editBtn);
AJAX('DELETE', submitURL, function() {
reloadTableOwner();
});
}
});
td4. appendChild(deleteBtn);
// Boutons delete
let deleteBtn = document.createElement('button');
deleteBtn.dataset.ownerId = json[i].id;
deleteBtn.innerHTML = '<i class="fas fa-trash fa-fw"></i> Supprimer';
deleteBtn.classList.add('btn', 'btn-danger');
deleteBtn.addEventListener('click', function()
{
let ownerId = this.dataset.ownerId;
let r = confirm('Are you sure ?');
if (r === true) {
submitURL = Routing.generate('api_owner_delete_one', {'id': ownerId});
tr.appendChild(td4);
tbody.appendChild(tr);
}
AJAX('DELETE', submitURL, function() {
reloadTableOwner();
});
}
});
td4. appendChild(deleteBtn);
tr.appendChild(td4);
tbody.appendChild(tr);
}
});
}
......@@ -181,8 +181,8 @@
AJAX('POST', submitURL, function()
{
reloadTableOwner();
form.parentNode.classList.add('hidden');
reloadTableOwner();
form.parentNode.classList.add('hidden');
},
form );
......
......@@ -60,13 +60,11 @@ function AJAX(type, url, successCallBack, post = null)
xhr.send((post === null)? null : new FormData(post));
}
// else if (this.status === 500)
// {
// console.log(this.status + ' ' + this.statusText);
// }
// if (post !== null) {
// xhr.send(new FormData(post));
// } else {
// xhr.send(null);
// }
/*
// Faut-il gérer les 500 ou d'autres ???
//
else if (this.status === 500)
{
console.log(this.status + ' ' + this.statusText);
}
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment