Skip to content
Snippets Groups Projects
Commit fd48eeaa authored by Rhys Evans's avatar Rhys Evans
Browse files

Further work on form integration

parent de63fae0
No related branches found
No related tags found
1 merge request!42Resolve "As a site administrator I want to be able to review submitted trail checkpoints by business owners, so that they might be added to the existing trails
This commit is part of merge request !42. Comments created here will be created in the context of that merge request.
......@@ -96,6 +96,11 @@ public class LocationRepositoryJDBC implements LocationRepository {
}
public int nametoLocationID(String name){
}
// public JdbcTemplate getJdbc() {
// return jdbc;
// }
......
......@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
//import jakarta.validation.Valid;
@Controller
......@@ -40,7 +42,6 @@ public class LandmarksController {
} else{
// converts valid response using Location constructor into a submittable format to the sql table
Location loc= new Location(landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
System.out.println(loc);
locationRepository.addLocation(loc); // adds valid landmark to locations table
ModelAndView modelAndView = new ModelAndView("redirect:/home");
return modelAndView;
......@@ -52,17 +53,36 @@ public class LandmarksController {
@Autowired
private PlacesCoordinatesRepository placesCoordinatesRepo;
@Autowired
private LocationsCoordinates locationsCoordinates;
@GetMapping("/checkpointApproval")
public ModelAndView adminCheckpointApproval(){
ModelAndView modelAndView1 = new ModelAndView("Landmarks/locationApprovalFormTh.html");
modelAndView1.addObject("locationCoord", new LocationsCoordinates());
return modelAndView1;
List<Location> unapprovedLocations = locationRepository.getAllLocation(); //change to unauthorised once merger 68 accepted!! todo
ModelAndView modelAndView = new ModelAndView("Landmarks/locationApprovalFormTh.html");
modelAndView.addObject("uLocs", unapprovedLocations);
modelAndView.addObject("locationCoord", new LocationsCoordinates());
return modelAndView;
}
@PostMapping("/checkpointSubmitted")
public ModelAndView checkpointSent(@Valid @ModelAttribute("locationCoord") LocationsCoordinates locCoord, BindingResult bindingResult, Model model ) {
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("Landmarks/locationApprovalFormTh.html", model.asMap());
return modelAndView;
} else{
// converts valid response using Location constructor into a submittable format to the sql table
LocationsCoordinates ALocCoord = new LocationsCoordinates(locCoord.getLocationID(),locCoord.getLocationCoordsLat(),locCoord.getLocationCoordsLong());
placesCoordinatesRepo.addLocationCoord(ALocCoord); // adds valid landmark to locations table
ModelAndView modelAndView = new ModelAndView("redirect:/home"); //todo redirect to trails?
return modelAndView;
}
}
}
......@@ -85,6 +85,11 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
// }
public boolean checkInputtedCoordsMatchTown(String inpLatCoords, String inpLongCoords, String townName){
PlacesCoordinatesRepositoryJDBC jbdcsecond = new PlacesCoordinatesRepositoryJDBC(jdbc);
List<TownWithTrails> allTowns = jbdcsecond.getAllTownCoords();
......
......@@ -5,6 +5,29 @@
<title>Title</title>
</head>
<body>
<main>
<form action="/checkpointSubmitted" method="post" th:object="${locationCoord}">
<label> Location To Be Approved:
<select >
<!-- <select th:field="*{locationName}">-->
<option value="" hidden="true">Select Location</option>
<option value="" selected disabled>Select Location</option>
<option th:each="uloc:${uLocs}" th:value="${uloc.getLocationName()}" th:text="${uloc.getLocationName()}">
</option>
</select>
</label>
<br><label> Location Latitude:
<input type="text" th:field="*{locationCoordsLat}" placeholder="Latitude Here">
<br><label> Location Longitude:
<input type="text" th:field="*{locationCoordsLong}" placeholder="Latitude Here">
</label><br>
<input type="submit">
</form>
</main>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment