Redirect on the roght page after adding/deletind care/consent behavior.

This commit is contained in:
Geoffrey POUZET 2020-10-17 22:01:50 +02:00
parent 498eaa02cb
commit 7d9bbbaa56
3 changed files with 37 additions and 8 deletions

View File

@ -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;
}

View File

@ -67,8 +67,11 @@
<c:if test="${progression.getProgressionByVeterinary() == 'NOT_TRAINED'}">active</c:if>
">${progression.getProgressionByVeterinary()}</td>
<td>
<!--TODO MODIFICATION-->
<form class="pull-right" action="${animalDeleteProgressionURL}/${progression.getId()}" method="POST">
<label class="sr-only" for="form_page">Page</label>
<input id="form_page" name="page" value="consent_behavior" hidden />
<label class="sr-only" for="form_consent_behavior_id">Consent behavior ID</label>
<input id="form_consent_behavior_id" name="redirect_id" value="${MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID}" hidden />
<button class="btn btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</form>
</td>
@ -80,6 +83,8 @@
<hr/>
<h4>Ajouter un soins pour ce comportement de consentement</h4>
<form class="form-inline" action="${animalAddProgressionURL}" method="POST">
<label class="sr-only" for="form_page">Page</label>
<input id="form_page" name="page" value="consent_behavior" hidden />
<label class="sr-only" for="form_consent_behavior_id">Consent Behavior ID</label>
<input id="form_consent_behavior_id" name="consent_behavior_id" value="${MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID}" hidden />
<label class="sr-only" for="form_care_id">Care ID</label>

View File

@ -71,8 +71,11 @@
<c:if test="${progression.getProgressionByVeterinary() == 'NOT_TRAINED'}">active</c:if>
"><fmt:message key="progression.value.${progression.getProgressionByVeterinary()}"></fmt:message></td>
<td>
<!--TODO MODIFICATION-->
<form class="pull-right" action="${animalDeleteProgressionURL}/${progression.getId()}" method="POST">
<label class="sr-only" for="form_page">Page</label>
<input id="form_page" name="page" value="care" hidden />
<label class="sr-only" for="form_care_id">Care ID</label>
<input id="form_care_id" name="redirect_id" value="${MODEL_MAP_ANIMAL_CARE_ID}" hidden />
<button class="btn btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</form>
</td>
@ -84,6 +87,8 @@
<hr/>
<h4>Ajouter un comportement de consentement pour ce soin</h4>
<form class="form-inline" action="${animalAddProgressionURL}" method="POST">
<label class="sr-only" for="form_page">Page</label>
<input id="form_page" name="page" value="care" hidden />
<label class="sr-only" for="form_care_id">Care ID</label>
<input id="form_care_id" name="care_id" value="${MODEL_MAP_ANIMAL_CARE_ID}" hidden />
<label class="sr-only" for="form_consent_behavior_id">Consent Behavior ID</label>