Aggiunta campo "note"
This commit is contained in:
11
script.js
11
script.js
@@ -11,7 +11,7 @@ function listPizze(){
|
|||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((pizze) => {
|
.then((pizze) => {
|
||||||
// Creiamo la tabella
|
// Creiamo la tabella
|
||||||
let table = '<table><tr><th>ID</th><th>Nome</th><th>Prezzo</th><th>Azioni</th></tr>';
|
let table = '<table><tr><th>ID</th><th>Nome</th><th>Prezzo</th><th>Note</th><th>Azioni</th></tr>';
|
||||||
|
|
||||||
// Aggiungiamo ogni pizza come riga della tabella
|
// Aggiungiamo ogni pizza come riga della tabella
|
||||||
pizze.pizze.forEach(pizza => {
|
pizze.pizze.forEach(pizza => {
|
||||||
@@ -19,6 +19,7 @@ function listPizze(){
|
|||||||
<td>${pizza.id}</td>
|
<td>${pizza.id}</td>
|
||||||
<td>${pizza.nome}</td>
|
<td>${pizza.nome}</td>
|
||||||
<td>${pizza.prezzo.toFixed(2)}€</td>
|
<td>${pizza.prezzo.toFixed(2)}€</td>
|
||||||
|
<td>${pizza.note}</td>
|
||||||
<td><button class="editBtn" onclick="editPizza(${pizza.id})">Modifica</button>
|
<td><button class="editBtn" onclick="editPizza(${pizza.id})">Modifica</button>
|
||||||
<button class="delBtn" onclick="deletePizza(${pizza.id})">X</button></td>
|
<button class="delBtn" onclick="deletePizza(${pizza.id})">X</button></td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
@@ -84,13 +85,14 @@ function editPizza(id){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPizza(nome, prezzo){
|
function addPizza(nome, prezzo, note){
|
||||||
const myHeaders = new Headers();
|
const myHeaders = new Headers();
|
||||||
myHeaders.append("Content-Type", "application/json");
|
myHeaders.append("Content-Type", "application/json");
|
||||||
|
|
||||||
const raw = JSON.stringify({
|
const raw = JSON.stringify({
|
||||||
"nome": nome,
|
"nome": nome,
|
||||||
"prezzo": prezzo
|
"prezzo": prezzo,
|
||||||
|
"note": note
|
||||||
});
|
});
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
@@ -117,6 +119,7 @@ function handleAddPizza(event){
|
|||||||
|
|
||||||
const nome = document.getElementById("name").value;
|
const nome = document.getElementById("name").value;
|
||||||
const prezzo = document.getElementById("price").value;
|
const prezzo = document.getElementById("price").value;
|
||||||
|
const note = document.getElementById("notes").value;
|
||||||
|
|
||||||
addPizza(nome, prezzo);
|
addPizza(nome, prezzo, note);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user