Show placeholder row if no invoice items are left

This commit is contained in:
Ramon Gutierrez 2018-01-17 20:47:49 +08:00
parent 3132812308
commit 0615ae0dc8
2 changed files with 11 additions and 3 deletions

View file

@ -104,7 +104,7 @@ span.has-danger,
font-weight: 400; font-weight: 400;
} }
.placeholder-row { .placeholder-row td {
background-color: #fff !important; background-color: #fff !important;
padding: 32px 0 !important; padding: 32px 0 !important;
text-align: center; text-align: center;

View file

@ -266,8 +266,8 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr class="placeholder-row">
<td colspan="14" class="placeholder-row"> <td colspan="14">
No items to display. No items to display.
</td> </td>
</tr> </tr>
@ -682,6 +682,7 @@ $(function() {
// remove from invoice table // remove from invoice table
$(document).on("click", ".btn-invoice-delete", function() { $(document).on("click", ".btn-invoice-delete", function() {
var tbody = $("#invoice-table tbody");
var row = $(this).closest('tr'); var row = $(this).closest('tr');
var qty = row.find('.col-quantity').html(); var qty = row.find('.col-quantity').html();
var unitPrice = row.find('.col-unit-price').html(); var unitPrice = row.find('.col-unit-price').html();
@ -702,6 +703,13 @@ $(function() {
// remove from table // remove from table
row.remove(); row.remove();
// get total item rows and show placeholder if needed
var visibleRows = tbody.find('tr:not(.placeholder-row)').length;
if (visibleRows === 0) {
tbody.find('.placeholder-row').removeClass('hide');
}
}); });
}); });
</script> </script>