From 5e306287a1bc21cf1168a1f57442a60f3ea536c4 Mon Sep 17 00:00:00 2001
From: Rhys Evans <EvansRM17@cardiff.ac.uk>
Date: Fri, 1 Dec 2023 23:11:20 +0000
Subject: [PATCH] cleared code, made addLocations element name easier to
 distinguish, fixed bug with landamrk form not defaulting to select
 location/trail disabled selection dropdown option by default

---
 src/main/java/Team5/SmartTowns/Data/location.java   |  9 +--------
 .../Team5/SmartTowns/Data/locationRepository.java   |  2 +-
 .../SmartTowns/Data/locationRepositoryJDBC.java     |  4 ++--
 .../Landmarks/LandmarkSuccessDialogue.java          |  2 --
 .../SmartTowns/Landmarks/LandmarksController.java   | 13 +------------
 .../templates/Landmarks/LandmarkFormTh.html         |  4 +++-
 6 files changed, 8 insertions(+), 26 deletions(-)
 delete mode 100644 src/main/java/Team5/SmartTowns/Landmarks/LandmarkSuccessDialogue.java

diff --git a/src/main/java/Team5/SmartTowns/Data/location.java b/src/main/java/Team5/SmartTowns/Data/location.java
index 268babdb..660a7f96 100644
--- a/src/main/java/Team5/SmartTowns/Data/location.java
+++ b/src/main/java/Team5/SmartTowns/Data/location.java
@@ -53,12 +53,5 @@ public class location {
         return locationTrailID;
     }
 
-//    public location(int locationID, String locationName, String locationEmail, String locationDescription, String locationPlace, int locationTrailID) {
-//        this.locationID = locationID;
-//        this.locationName = locationName;
-//        this.locationEmail = locationEmail;
-//        this.locationDescription = locationDescription;
-//        this.locationPlace = locationPlace;
-//        this.locationTrailID = locationTrailID;
-//    }
+
 }
diff --git a/src/main/java/Team5/SmartTowns/Data/locationRepository.java b/src/main/java/Team5/SmartTowns/Data/locationRepository.java
index f09d1f64..47c2f327 100644
--- a/src/main/java/Team5/SmartTowns/Data/locationRepository.java
+++ b/src/main/java/Team5/SmartTowns/Data/locationRepository.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 public interface locationRepository {
     List<location> getAllLocation();
-    void addLocation(location llocation);
+    void addLocation(location loc);
 
 
 }
diff --git a/src/main/java/Team5/SmartTowns/Data/locationRepositoryJDBC.java b/src/main/java/Team5/SmartTowns/Data/locationRepositoryJDBC.java
index e6cc200e..3f86131a 100644
--- a/src/main/java/Team5/SmartTowns/Data/locationRepositoryJDBC.java
+++ b/src/main/java/Team5/SmartTowns/Data/locationRepositoryJDBC.java
@@ -34,10 +34,10 @@ public class locationRepositoryJDBC implements locationRepository {
     }
 
     @Override // intended implementation at current: user data from templates/Landmarks/LandmarkFormTh.html is added to the location table, todo change location class to Location as its better code grammar and looks funky otherwise.
-    public void addLocation(location llocation) {
+    public void addLocation(location loc) {
         String sql = "insert into locations(locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) values (?,?,?,?,?,?)";
 
-        jdbc.update(sql, llocation.getLocationID(),llocation.getLocationName(),llocation.getLocationEmail(),llocation.getLocationDescription(),llocation.getLocationPlace(),llocation.getLocationTrailID());
+        jdbc.update(sql, loc.getLocationID(),loc.getLocationName(),loc.getLocationEmail(),loc.getLocationDescription(),loc.getLocationPlace(),loc.getLocationTrailID());
     }
 
 
diff --git a/src/main/java/Team5/SmartTowns/Landmarks/LandmarkSuccessDialogue.java b/src/main/java/Team5/SmartTowns/Landmarks/LandmarkSuccessDialogue.java
deleted file mode 100644
index 49bb86bf..00000000
--- a/src/main/java/Team5/SmartTowns/Landmarks/LandmarkSuccessDialogue.java
+++ /dev/null
@@ -1,2 +0,0 @@
-package Team5.SmartTowns.Landmarks;
-
diff --git a/src/main/java/Team5/SmartTowns/Landmarks/LandmarksController.java b/src/main/java/Team5/SmartTowns/Landmarks/LandmarksController.java
index 22a344bc..36cf4c6c 100644
--- a/src/main/java/Team5/SmartTowns/Landmarks/LandmarksController.java
+++ b/src/main/java/Team5/SmartTowns/Landmarks/LandmarksController.java
@@ -32,7 +32,7 @@ public class LandmarksController {
     @Autowired
     private locationRepository locationRepository;
     @PostMapping("/landmarkSub")
-    public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes ) {
+    public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) {
 
 
         if (bindingResult.hasErrors()) {
@@ -40,21 +40,10 @@ public class LandmarksController {
             return modelAndView;
 
         } else{
-            System.out.println(landmarks);
-//            JFrame frame = new JFrame("Main Window");
-//
-//            JOptionPane.showMessageDialog(frame, "Message for the dialog box goes here.","Error", JOptionPane.ERROR_MESSAGE);
-//
-//            frame.setSize(350,350);
-//            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-//            frame.setVisible(true);
 
             location loc= new location(landmarks.getLandmarkID(),landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID());
             System.out.println(loc);
             locationRepository.addLocation(loc);
-//            redirectAttributes.addFlashAttribute("notification",
-//                    String.format("Contractor \"%s\" successfully saved"));
-//            redirectAttributes.addFlashAttribute("msg", "Success");
             ModelAndView modelAndView = new ModelAndView("redirect:/home");
             return modelAndView;
 
diff --git a/src/main/resources/templates/Landmarks/LandmarkFormTh.html b/src/main/resources/templates/Landmarks/LandmarkFormTh.html
index 9690356f..a8f42293 100644
--- a/src/main/resources/templates/Landmarks/LandmarkFormTh.html
+++ b/src/main/resources/templates/Landmarks/LandmarkFormTh.html
@@ -30,7 +30,8 @@
         </label><br><br>
         <label>Your Location:
             <select th:field="*{landmarkLocation}">
-                <option value="" disabled selected>Select Location</option>
+                <option value="" hidden="true">Select Location</option>
+                <option value=""  selected disabled>Select Location</option>
                 <option value="Caerphilly">Caerphilly</option>
                 <option value="Risca">Risca</option>
                 <option value="Penarth">Penarth</option>
@@ -38,6 +39,7 @@
         </label><br><br>
         <label>Trail:
             <select th:field="*{trailID}">
+                <option value=0 hidden="true">Select Trail</option>
                 <option value=0 disabled selected>Select Trail</option>
                 <option value=0101>(Caerphilly) Castle Trail</option>
                 <option value=0102>(Caerphilly) Pub Trail</option>
-- 
GitLab