Added CRUD for 'Client' entity. Added common templates and demo data populator.

This commit is contained in:
2019-05-04 23:45:41 +03:00
parent 22f1ebf607
commit b541e69885
14 changed files with 363 additions and 26 deletions
@@ -3,11 +3,58 @@
layout:decorate="~{main}">
<head>
<title th:text="#{default.title}"></title>
<script th:inline="javascript">
function deleteClientById(id) {
const confirmationResult = confirm("Are you sure to delete?");
if (confirmationResult) {
const url = /*[[@{/client/delete/}]]*/;
$.ajax({
url: url + id,
type: 'DELETE',
success: function () {
$('#client-row-' + id).remove();
}
});
}
}
</script>
</head>
<body>
<div layout:fragment="content">
<h1 th:text="#{client.title}"></h1>
<div class="pull-right">
<a class="btn btn-success" th:href="@{/client/create}">Create</a>
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Phone No</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr th:each="client : ${clientList}" th:id="'client-row-' + ${client.id}">
<td th:text="${client.firstName}"></td>
<td th:text="${client.middleName}"></td>
<td th:text="${client.lastName}"></td>
<td th:text="${client.phoneNo}"></td>
<td>
<div class="btn-group pull-right">
<a th:href="@{/client/edit/{id}(id=${client.id})}" class="btn btn-default">Edit</a>
<button type="button" class="btn btn-danger" th:onclick="'deleteClientById(' + ${client.id} + ')'">Delete</button>
</div>
</td>
</tr>
</tbody>
</table>
<div th:replace="common::pagination(@{/client/}, ${page}, ${totalPages})"></div>
</div>
</body>