mirror of
https://github.com/Prominence/car-repair-site.git
synced 2026-07-03 03:06:47 +03:00
Added CRUD for 'Client' entity. Added common templates and demo data populator.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<!doctype html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{main}">
|
||||
<head>
|
||||
<title th:text="#{default.title}"></title>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<h1 th:text="#{client.title}"></h1>
|
||||
|
||||
<form th:action="'/client/' + ${client.id != null ? 'update/' + client.id : 'create'}" th:object="${client}" method="post">
|
||||
<div class="form-group row">
|
||||
<label for="clientFirstName" class="col-sm-2 col-form-label">First Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="firstName" class="form-control" id="clientFirstName" th:field="*{firstName}" th:errorclass="fieldError" th:value="${client.firstName}">
|
||||
<div th:replace="common::errors('firstName')"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="clientMiddleName" class="col-sm-2 col-form-label">Middle Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="middleName" class="form-control" id="clientMiddleName" th:field="*{middleName}" th:errorclass="fieldError" th:value="${client.middleName}">
|
||||
<div th:replace="common::errors('middleName')"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="clientLastName" class="col-sm-2 col-form-label">Last Name</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="lastName" class="form-control" id="clientLastName" th:field="*{lastName}" th:errorclass="fieldError" th:value="${client.lastName}">
|
||||
<div th:replace="common::errors('lastName')"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="clientPhoneNo" class="col-sm-2 col-form-label">Phone No</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="phoneNo" class="form-control" id="clientPhoneNo" th:field="*{phoneNo}" th:errorclass="fieldError" th:value="${client.phoneNo}">
|
||||
<div th:replace="common::errors('phoneNo')"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row pull-right">
|
||||
<div class="col-sm-12">
|
||||
<a href="/client" class="btn btn-default">Back</a>
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -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> </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>
|
||||
|
||||
Reference in New Issue
Block a user