From 4e7b7c7d7d7ad1af97cf79e46db1a095e9c6476e Mon Sep 17 00:00:00 2001 From: Akshath Sai Pittala Date: Thu, 9 May 2024 19:25:43 +0530 Subject: [PATCH] - Developed remove button for clearing watchlist items --- .../web/controllers/WatchListController.java | 12 ++++++++---- src/main/resources/templates/watchlistitems.html | 11 ++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/akshathsaipittala/streamspace/web/controllers/WatchListController.java b/src/main/java/com/akshathsaipittala/streamspace/web/controllers/WatchListController.java index 117a906..ee8c641 100644 --- a/src/main/java/com/akshathsaipittala/streamspace/web/controllers/WatchListController.java +++ b/src/main/java/com/akshathsaipittala/streamspace/web/controllers/WatchListController.java @@ -8,10 +8,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; import java.sql.Date; import java.time.LocalDate; @@ -50,4 +47,11 @@ public ResponseEntity addToWatchList(@RequestParam("movie-title") String return ResponseEntity.ok(" Added!"); } + @HxRequest + @DeleteMapping("/{id}") + public ResponseEntity deleteFromWatchList(@PathVariable("id") int id) { + watchListRepository.deleteById(id); + return ResponseEntity.ok("Deleted!"); + } + } diff --git a/src/main/resources/templates/watchlistitems.html b/src/main/resources/templates/watchlistitems.html index 66e2fe9..19eef9e 100644 --- a/src/main/resources/templates/watchlistitems.html +++ b/src/main/resources/templates/watchlistitems.html @@ -1,6 +1,6 @@
-
+
+
+