From 7d9bbbaa56e99060da38b8219e97555d75f41f8b Mon Sep 17 00:00:00 2001 From: Geoffrey POUZET Date: Sat, 17 Oct 2020 22:01:50 +0200 Subject: [PATCH] Redirect on the roght page after adding/deletind care/consent behavior. --- .../controller/AnimalController.java | 31 +++++++++++++++---- src/main/webapp/vue/animal_behavior.jsp | 7 ++++- src/main/webapp/vue/animal_care.jsp | 7 ++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/geoffrey/medical_training_tracker/controller/AnimalController.java b/src/main/java/fr/geoffrey/medical_training_tracker/controller/AnimalController.java index 91e6798..e5c5eee 100644 --- a/src/main/java/fr/geoffrey/medical_training_tracker/controller/AnimalController.java +++ b/src/main/java/fr/geoffrey/medical_training_tracker/controller/AnimalController.java @@ -223,7 +223,8 @@ public class AnimalController { public String doPostAddProgression(final ModelMap pModel, HttpSession httpSession, @PathVariable(value = "animal_id") final int animalId, @RequestParam(name = "care_id", required = true) int careId, - @RequestParam(name = "consent_behavior_id", required = true) int consentBehaviorId) { + @RequestParam(name = "consent_behavior_id", required = true) int consentBehaviorId, + @RequestParam(value = "page", required = true) final String pageFrom) { String ret; if (LoginController.isUserAlreadyAuth(httpSession)) { @@ -235,8 +236,16 @@ public class AnimalController { serviceAnimal.addProgression(animalId, careId, consentBehaviorId); } - // TODO Where do redirection ? - ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_CARES_AND_BEHAVIORS_LIST.replaceAll("\\{animal_id\\}", animalId + ""); + if (pageFrom.equals("care")) { + ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_CARE + .replaceAll("\\{care_id\\}", careId + ""); + } else if (pageFrom.equals("consent_behavior")) { + ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_BEHAVIOR + .replaceAll("\\{consent_behavior_id\\}", consentBehaviorId + ""); + } else { + ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_CARES_AND_BEHAVIORS_LIST; + } + ret = ret.replaceAll("\\{animal_id\\}", animalId + ""); } else { ret = IndexController.URL_REDIRECT + IndexController.URL_LOGIN; } @@ -247,7 +256,9 @@ public class AnimalController { @RequestMapping(value = IndexController.URL_ANIMAL_PROGRESSION_DELETE, method = RequestMethod.POST) public String doPostDeleteProgression(final ModelMap pModel, HttpSession httpSession, @PathVariable(value = "animal_id") final int animalId, - @PathVariable(value = "progression_id") final int progressionId) { + @PathVariable(value = "progression_id") final int progressionId, + @RequestParam(value = "page", required = true) final String pageFrom, + @RequestParam(value = "redirect_id", required = true) final int redirectId) { String ret; if (LoginController.isUserAlreadyAuth(httpSession)) { @@ -259,8 +270,16 @@ public class AnimalController { serviceAnimal.deleteAnimalProgression(animalId, userDetails.getUsername(), progressionId); } - // TODO Where do redirection ? - ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_CARES_AND_BEHAVIORS_LIST.replaceAll("\\{animal_id\\}", animalId + ""); + if (pageFrom.equals("care")) { + ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_CARE + .replaceAll("\\{care_id\\}", redirectId + ""); + } else if (pageFrom.equals("consent_behavior")) { + ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_BEHAVIOR + .replaceAll("\\{consent_behavior_id\\}", redirectId + ""); + } else { + ret = IndexController.URL_REDIRECT + IndexController.URL_ANIMAL_CARES_AND_BEHAVIORS_LIST; + } + ret = ret.replaceAll("\\{animal_id\\}", animalId + ""); } else { ret = IndexController.URL_REDIRECT + IndexController.URL_LOGIN; } diff --git a/src/main/webapp/vue/animal_behavior.jsp b/src/main/webapp/vue/animal_behavior.jsp index b5f5137..7b89862 100644 --- a/src/main/webapp/vue/animal_behavior.jsp +++ b/src/main/webapp/vue/animal_behavior.jsp @@ -67,8 +67,11 @@ active ">${progression.getProgressionByVeterinary()} -
+ + + +
@@ -80,6 +83,8 @@

Ajouter un soins pour ce comportement de consentement

+ + diff --git a/src/main/webapp/vue/animal_care.jsp b/src/main/webapp/vue/animal_care.jsp index bf43da8..eb54112 100644 --- a/src/main/webapp/vue/animal_care.jsp +++ b/src/main/webapp/vue/animal_care.jsp @@ -71,8 +71,11 @@ active "> - + + + +
@@ -84,6 +87,8 @@

Ajouter un comportement de consentement pour ce soin

+ +