Skip to content

Commit

Permalink
Added edit and delete buttons on model list / search screen
Browse files Browse the repository at this point in the history
  • Loading branch information
surajcm committed Apr 24, 2024
1 parent d863813 commit a741c42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/main/java/com/poseidon/user/web/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public String listByPage(final @PathVariable(name = "pageNumber") int pageNumber
@PostMapping("/user/saveUser")
public @ResponseBody
Set<User> saveUser(
@RequestParam(value = "thumbnail", required = false) final MultipartFile thumbnail,
@RequestParam("selectName") final String name,
@RequestParam("selectLogin") final String email,
@RequestParam("selectRole") final Set<Long> roles,
@RequestParam(name = "thumbnail", value = "thumbnail", required = false) final MultipartFile thumbnail,
@RequestParam(name = "selectName") final String name,
@RequestParam(name = "selectLogin") final String email,
@RequestParam(name = "selectRole") final Set<Long> roles,
final RedirectAttributes redirectAttributes) throws IOException {
logger.info("SaveUser method of user controller ");
logger.info("inputs are : name {}, email {}, role {}", name, email, roles);
Expand Down Expand Up @@ -205,11 +205,12 @@ private User removePassword(final User user) {

@PutMapping("/user/updateUser")
public @ResponseBody
Set<User> updateUser(@RequestParam(value = "thumbnail", required = false) final MultipartFile thumbnail,
@RequestParam("id") final String id,
@RequestParam("name") final String name,
@RequestParam("email") final String email,
@RequestParam("roles") final Set<Long> roles,
Set<User> updateUser(@RequestParam(name = "thumbnail", value = "thumbnail", required = false)
final MultipartFile thumbnail,
@RequestParam(name = "id") final String id,
@RequestParam(name = "name") final String name,
@RequestParam(name = "email") final String email,
@RequestParam(name = "roles") final Set<Long> roles,
final RedirectAttributes redirectAttributes) {
var sanitizedId = CommonUtils.sanitizedString(id);
var sanitizedName = CommonUtils.sanitizedString(name);
Expand Down
13 changes: 13 additions & 0 deletions src/main/resources/templates/model/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="stylesheet" href="/css/core/bootstrap-5.3.1/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="/css/custom.css" type="text/css" />
<link rel="stylesheet" href="/css/core/flag-icon.min.css" type="text/css" />
<link rel="stylesheet" href="/css/core/fontawesome-6.2.1/css/all.min.css" type="text/css" />
<title>Make and Model List</title>
<script type="text/javascript" src="/js/common-scripts.js"></script>
<script type="text/javascript" src="/js/model-scripts.js"></script>
Expand Down Expand Up @@ -108,6 +109,7 @@
<th scope="col">id</th>
<th scope="col">Make Name</th>
<th scope="col">Model Name</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
Expand All @@ -116,6 +118,17 @@
th:value="${model.id}" /></th>
<td><span th:text="${model.make.makeName}"></span></td>
<td><span th:text="${model.modelName}"></span></td>
<td>
<a class="fa-regular fa-pen-to-square" href="" data-bs-toggle="modal" data-bs-target="#editModal"
th:onclick="'javascript:editModelNew(' + ${model.id} + ');'" title="Edit this model"></a>
&nbsp;
<a class="fa-solid fa-trash"
th:href="@{'/model/delete/'+${model.id}}"
th:makeId="${model.id}"
title="Delete this model"
data-bs-toggle="modal"
data-bs-target="#confirmModal"></a>
</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit a741c42

Please sign in to comment.