Skip to content

Commit a31f2f6

Browse files
authored
Nivell 3 Corrections
2 parents 0ee4b58 + a819f26 commit a31f2f6

File tree

6 files changed

+41
-50
lines changed

6 files changed

+41
-50
lines changed

src/main/java/com/itacademy/CrudEmpleats/controller/ControllerWeb.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/main/java/com/itacademy/CrudEmpleats/exceptions/IdNotFound.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
public class IdNotFound extends RuntimeException {
44

5+
private static final long serialVersionUID = 1L;
6+
57
private int id;
68

79
public IdNotFound(int id) {

src/main/resources/static/custom_bootstrap.min.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ pre code {
554554

555555
.table thead th {
556556
vertical-align: bottom;
557+
background-color: white;
557558
border-bottom: 2px solid #dee2e6;
558559
}
559560

@@ -588,9 +589,13 @@ pre code {
588589
}
589590

590591
.table-striped tbody tr:nth-of-type(odd) {
591-
background-color: rgba(0, 0, 0, 0.05);
592+
background-color: rgba(0, 0, 0, 0.10);
592593
}
593594

595+
.table-striped tbody tr:nth-of-type(even) {
596+
background-color: rgb(255, 255, 255);
597+
598+
}
594599
.table-hover tbody tr:hover {
595600
color: #212529;
596601
background-color: rgba(0, 0, 0, 0.075);

src/main/resources/static/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
body::after {
22
content: "";
33
background: url(background.jpeg);
4-
opacity: 0.6;
4+
opacity: 0.5;
55
top: 0;
66
left: 0;
77
bottom: 0;

src/main/resources/static/index.js

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ $(document).ready(function () {
22
updateTable();
33
});
44

5-
var table=$('#employeeTable').DataTable({
6-
columnDefs: [
7-
{targets: '_all',classname: 'dt-center' }
8-
]
9-
});
5+
var table = $('#employeeTable').DataTable({
6+
columnDefs: [
7+
{ targets: '_all', className: 'text-center' }]
8+
});
109

1110
//Read employee List & Update the table
1211
function updateTable() {
@@ -16,19 +15,19 @@ function updateTable() {
1615
table.row.add(createRow(employee)).draw();
1716
});
1817
});
19-
};
18+
}
2019

2120
//create Row for DataTables Format
22-
function createRow(employee){
21+
function createRow(employee) {
2322
return [
2423
employee.id,
2524
employee.name,
2625
employee.job,
2726
employee.salary,
28-
"<button type='button' class='btn btn-light' data-toggle='modal' data-target='#modal' onclick='editEmployee(" + employee.id + ")'>Modificar</button>" +
29-
"<button type='button' class='btn btn-danger' onclick='deleteEmployee(" + employee.id + ")'>Eliminar</button>"
30-
];
31-
};
27+
"<button type='button' class='btn btn-light' data-toggle='modal' data-target='#modal' onclick='editEmployee(" + employee.id + ")'>Modificar</button>" +
28+
"<button type='button' class='btn btn-danger' onclick='deleteEmployee(" + employee.id + ")'>Eliminar</button>"
29+
];
30+
}
3231

3332
//Create & update
3433
function sendEmployee() {
@@ -43,7 +42,7 @@ function sendEmployee() {
4342
"job": $('#job').val()
4443
}),
4544
success: function (data, textStatus, jQxhr) {
46-
table.row.add(createRow(data)).order( [ 0, 'asc' ] ).page('last').draw(false);
45+
table.row.add(createRow(data)).order([0, 'asc']).page('last').draw(false);
4746
},
4847
error: function (xhr, textStatus, errorThrown) {
4948
console.log(textStatus);
@@ -72,7 +71,7 @@ function sendEmployee() {
7271
$('#EmployeeForm').trigger('reset');
7372
$('#action').val('Afegir');
7473
$('#formType').html('Afegir nou');
75-
};
74+
}
7675

7776
//Delete employee
7877
function deleteEmployee(id) {
@@ -91,27 +90,27 @@ function deleteEmployee(id) {
9190
}
9291
},
9392
callback: function (result) {
94-
if (result == true) {
93+
if (result === true) {
9594
$.ajax({
9695
type: "DELETE",
9796
url: "/EmployeeList/" + id,
9897
success: function (data, textStatus, jQxhr) {
9998
var indexes = table
100-
.rows()
101-
.indexes()
102-
.filter( function ( value, index ) {
103-
return id === table.row(value).data()[0];
104-
} );
105-
table.rows(indexes).remove().draw(false);
99+
.rows()
100+
.indexes()
101+
.filter(function (value, index) {
102+
return id === table.row(value).data()[0];
103+
});
104+
table.rows(indexes).remove().draw(false);
106105
},
107106
error: function (xhr, textStatus, errorThrown) {
108107
console.log(textStatus);
109108
}
110109
});
111110
}
112111
}
113-
})
114-
};
112+
});
113+
}
115114

116115
//Read one employee info and put in the modifier form.
117116
function editEmployee(id) {
@@ -122,7 +121,7 @@ function editEmployee(id) {
122121
});
123122
$('#action').val('Actualitzar');
124123
$('#formType').html('Actualizar');
125-
};
124+
}
126125

127126
//Set Form in New Employee Mode
128127
function newEmployee() {
@@ -146,4 +145,4 @@ function getJobCode(job) {
146145
} else {
147146
return "Default";
148147
}
149-
}
148+
}

src/main/resources/templates/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ <h6>Exercici realitzat utilitzant: Spring Api Rest, Javascript, jquery i Bootstr
5959
<th style="width:22%">Accions</th>
6060
</tr>
6161
</thead>
62-
<tbody></tbody>
62+
<tbody>
63+
<td>id</td>
64+
<td>nom</td>
65+
<td>carreg</td>
66+
<td>sou</td>
67+
<td><button type="button" class="btn btn-primary add" data-toggle="modal" data-target="#modal" onclick="newEmployee();">
68+
Nou Empleat</button></td>
69+
70+
</tbody>
6371
</table>
6472
</div>
6573
</div>

0 commit comments

Comments
 (0)