MedicalTrainingTracker/src/main/webapp/vue/animal_behavior.jsp

260 lines
18 KiB
Plaintext

<%@page import="fr.geoffrey.medical_training_tracker.dao.bean.Animal"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ page isELIgnored="false" %>
<spring:url value="/animal/${MODEL_MAP_ANIMAL.getId()}/delete/progression" var="animalDeleteProgressionURL" />
<spring:url value="/animal/${MODEL_MAP_ANIMAL.getId()}/edit/progression" var="animalEditProgressionURL" />
<spring:url value="/animal/${MODEL_MAP_ANIMAL.getId()}/add/progression" var="animalAddProgressionURL" />
<%@ include file="base/language.jsp" %>
<!DOCTYPE html>
<html lang="${language}">
<head>
<%@ include file="base/header.jsp" %>
<style type="text/css">
fieldset {
margin: auto;
width: 600px;
margin-top: 30px;
margin-bottom: 10px;
padding: 20px;
text-align: left;
border: 2px solid #aaa;
}
fieldset a {
width: 150px;
margin-bottom: 10px;
float: right;
}
</style>
</head>
<body>
<div class="container">
<%@ include file="base/navbar.jsp" %>
<center><h1>
<fmt:message key="animal_behavior.title">
<fmt:param value="${MODEL_MAP_ANIMAL.getName()}" />
</fmt:message>
</h1></center>
<h3>
<fmt:message key="animal_behavior.subtitle">
<fmt:param value="${MODEL_MAP_ANIMAL.getConsentBehaviorById(MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID).getName()}" />
</fmt:message>
</h3>
<p>${MODEL_MAP_ANIMAL.getConsentBehaviorById(MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID).getDescription()}</p>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><fmt:message key="animal_behavior.table.care"></fmt:message></th>
<th><fmt:message key="animal_behavior.table.executed_by_me"></fmt:message></th>
<th><fmt:message key="animal_behavior.table.executed_by_someone_else"></fmt:message></th>
<th><fmt:message key="animal_behavior.table.executed_by_veterinary"></fmt:message></th>
<th></th>
</tr>
</thead>
<tbody>
<c:forEach items="${MODEL_MAP_ANIMAL.getProgressionList()}" var="progression">
<tr>
<td><a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/care/${progression.getCare().getId()}">${progression.getCare().getName()}</a></td>
<td class="
<c:if test="${progression.getProgressionByMe() == 'TRAINED'}">success</c:if>
<c:if test="${progression.getProgressionByMe() == 'CURRENTLY_TRAINING'}">info</c:if>
<c:if test="${progression.getProgressionByMe() == 'NOT_TRAINED'}">active</c:if>
">
<a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/progression_by_me/${progression.getProgressionByMe()}">
<fmt:message key="progression.value.${progression.getProgressionByMe()}"></fmt:message>
</a>
</td>
<td class="
<c:if test="${progression.getProgressionBySomeoneElse() == 'TRAINED'}">success</c:if>
<c:if test="${progression.getProgressionBySomeoneElse() == 'CURRENTLY_TRAINING'}">info</c:if>
<c:if test="${progression.getProgressionBySomeoneElse() == 'NOT_TRAINED'}">active</c:if>
">
<a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/progression_by_someone_else/${progression.getProgressionBySomeoneElse()}">
<fmt:message key="progression.value.${progression.getProgressionBySomeoneElse()}"></fmt:message>
</a>
</td>
<td class="
<c:if test="${progression.getProgressionByVeterinary() == 'TRAINED'}">success</c:if>
<c:if test="${progression.getProgressionByVeterinary() == 'CURRENTLY_TRAINING'}">info</c:if>
<c:if test="${progression.getProgressionByVeterinary() == 'NOT_TRAINED'}">active</c:if>
">
<a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/progression_by_veterinary/${progression.getProgressionByVeterinary()}">
<fmt:message key="progression.value.${progression.getProgressionByVeterinary()}"></fmt:message>
</a>
</td>
<td>
<form class="pull-right" action="${animalDeleteProgressionURL}/${progression.getId()}" method="POST">
<input value="${progression.getCare().getName()}" hidden />
<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="<fmt:message key="animal_behavior.button.delete.tooltip"></fmt:message>"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
</form>
<form class="pull-right" action="${animalEditProgressionURL}/${progression.getId()}" method="GET">
<input value="${progression.getCare().getId()}" hidden />
<input value="${progression.getCare().getName()}" hidden />
<input value="${progression.getProgressionByMe()}" hidden />
<input value="${progression.getProgressionBySomeoneElse()}" hidden />
<input value="${progression.getProgressionByVeterinary()}" hidden />
<button class="btn btn-default" type="submit" data-toggle="tooltip" data-placement="bottom" title="<fmt:message key="animal_consent_behavior.button.edit.tooltip"></fmt:message>"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></button>
</form>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<hr/>
<h4><fmt:message key="animal_behavior.add_care"></fmt:message></h4>
<c:if test="${MODEL_MAP_LIST_REMAINING_CARES.size() == 0}" >
<p><fmt:message key="animal_behavior.add_care.empty_list"></fmt:message></p>
</c:if>
<c:if test="${MODEL_MAP_LIST_REMAINING_CARES.size() != 0}" >
<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>
<select id="form_care_id" class="form-control" name="care_id">
<c:forEach items="${MODEL_MAP_LIST_REMAINING_CARES}" var="care">
<option value="${care.getId()}">${care.getName()}</option>
</c:forEach>
</select>
<input id="form_care_id" name="care_id" value="${MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID}" hidden />
<button class="btn btn-success" type="submit" data-toggle="tooltip" data-placement="bottom" title="<fmt:message key="animal_behavior.button.add.tooltip"></fmt:message>"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
</form>
</c:if>
<%@ include file="base/footer.jsp" %>
</div>
<div id="modal_delete_animal_progression" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 id="modal_delete_animal_progression_title" class="modal-title"></h4>
</div>
<div class="modal-body">
<p id="modal_delete_animal_progression_body"><fmt:message key="animal_cares_and_behaviors.delete.modal_body.care"></fmt:message></p>
</div>
<div class="modal-footer">
<form id="modal_delete_animal_progression_validate_delete" class="pull-right" action="" method="POST">
<button type="button" class="btn btn-default" data-dismiss="modal"><fmt:message key="modal_button.cancel"></fmt:message></button>
<button type="submit" class="btn btn-danger"><fmt:message key="modal_button.delete"></fmt:message></button>
<input id="form_page" name="page" value="consent_behavior" hidden />
<input id="form_consent_behavior_id" name="redirect_id" value="${MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID}" hidden />
</form>
</div>
</div>
</div>
</div>
<div id="modal_edit_animal_progression" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 id="modal_edit_animal_progression_title" class="modal-title"></h4>
</div>
<div class="modal-body">
<form id="modal_edit_animal_progression_validate" action="" method="POST">
<label for="modal_edit_consent_behavior_form_progression_by_me"><fmt:message key="animal_behavior.table.executed_by_me"></fmt:message></label>
<select id="modal_edit_consent_behavior_form_progression_by_me" name="progression_by_me" class="form-control">
<option value="NOT_TRAINED"><fmt:message key="progression.value.NOT_TRAINED"></fmt:message></option>
<option value="CURRENTLY_TRAINING"><fmt:message key="progression.value.CURRENTLY_TRAINING"></fmt:message></option>
<option value="TRAINED"><fmt:message key="progression.value.TRAINED"></fmt:message></option>
<option value="NOT_USED"><fmt:message key="progression.value.NOT_USED"></fmt:message></option>
</select>
<label for="modal_edit_consent_behavior_form_progression_by_someone_else"><fmt:message key="animal_behavior.table.executed_by_someone_else"></fmt:message></label>
<select id="modal_edit_consent_behavior_form_progression_by_someone_else" name="progression_by_someone_else" class="form-control">
<option value="NOT_TRAINED"><fmt:message key="progression.value.NOT_TRAINED"></fmt:message></option>
<option value="CURRENTLY_TRAINING"><fmt:message key="progression.value.CURRENTLY_TRAINING"></fmt:message></option>
<option value="TRAINED"><fmt:message key="progression.value.TRAINED"></fmt:message></option>
<option value="NOT_USED"><fmt:message key="progression.value.NOT_USED"></fmt:message></option>
</select>
<label for="modal_edit_consent_behavior_form_progression_by_veterinary"><fmt:message key="animal_behavior.table.executed_by_veterinary"></fmt:message></label>
<select id="modal_edit_consent_behavior_form_progression_by_veterinary" name="progression_by_veterinary" class="form-control">
<option value="NOT_TRAINED"><fmt:message key="progression.value.NOT_TRAINED"></fmt:message></option>
<option value="CURRENTLY_TRAINING"><fmt:message key="progression.value.CURRENTLY_TRAINING"></fmt:message></option>
<option value="TRAINED"><fmt:message key="progression.value.TRAINED"></fmt:message></option>
<option value="NOT_USED"><fmt:message key="progression.value.NOT_USED"></fmt:message></option>
</select>
<input name="page" value="consent_behavior" hidden />
<input id="modal_edit_consent_behavior_form_care_id" name="care_id" value="" hidden />
<input name="consent_behavior_id" value="${MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID}" hidden />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><fmt:message key="modal_button.cancel"></fmt:message></button>
<button form="modal_edit_animal_progression_validate" type="submit" class="btn btn-primary"><fmt:message key="modal_button.edit"></fmt:message></button>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript">
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
$("form").submit(function (event) {
var formUrl = $(this).attr('action');
if (formUrl.startsWith('${animalDeleteProgressionURL}')) {
if ($(this).attr('id') !== 'modal_delete_animal_progression_validate_delete') {
// Only for deleting care or behavior forms
var behaviorName = $(this).find('input')[0].value;
$('#modal_delete_animal_progression_title').text(behaviorName);
$('#modal_delete_animal_progression_validate_delete').attr('action', formUrl);
$('#modal_delete_animal_progression').modal({
show: true
});
event.preventDefault();
}
} else if (formUrl.startsWith('${animalEditProgressionURL}')) {
if ($(this).attr('id') !== 'modal_edit_animal_progression_validate') {
// Only for deleting care or behavior forms
var data = $(this).find('input');
var careId = data[0].value;
var careName = data[1].value;
var progressionByMe = data[2].value;
var progressionBySomeoneElse = data[3].value;
var progressionByVeterinary = data[4].value;
$('#modal_edit_consent_behavior_form_care_id').val(careId);
$('#modal_edit_animal_progression_title').text(careName);
$('#modal_edit_consent_behavior_form_progression_by_me').val(progressionByMe);
$('#modal_edit_consent_behavior_form_progression_by_someone_else').val(progressionBySomeoneElse);
$('#modal_edit_consent_behavior_form_progression_by_veterinary').val(progressionByVeterinary);
$('#modal_edit_animal_progression_validate').attr('action', formUrl);
$('#modal_edit_animal_progression').modal({
show: true
});
event.preventDefault();
}
}
});
});
</script>
</html>