feat: add commentaire field to licence modal

This commit is contained in:
2026-07-05 12:38:39 +02:00
parent 19cee92437
commit 6dd45deb8c
4 changed files with 20 additions and 2 deletions
@@ -41,6 +41,9 @@ public class Licence {
@Column(name = "type_licence", length = 50) @Column(name = "type_licence", length = 50)
private String typeLicence; private String typeLicence;
@Column(columnDefinition = "TEXT")
private String commentaire;
@OneToMany(mappedBy = "licence", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "licence", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Paiement> paiements = new ArrayList<>(); private List<Paiement> paiements = new ArrayList<>();
@@ -128,6 +131,9 @@ public class Licence {
public String getTypeLicence() { return typeLicence; } public String getTypeLicence() { return typeLicence; }
public void setTypeLicence(String typeLicence) { this.typeLicence = typeLicence; } public void setTypeLicence(String typeLicence) { this.typeLicence = typeLicence; }
public String getCommentaire() { return commentaire; }
public void setCommentaire(String commentaire) { this.commentaire = commentaire; }
public List<Paiement> getPaiements() { return paiements; } public List<Paiement> getPaiements() { return paiements; }
public void setPaiements(List<Paiement> paiements) { this.paiements = paiements; } public void setPaiements(List<Paiement> paiements) { this.paiements = paiements; }
@@ -0,0 +1 @@
ALTER TABLE licence ADD COLUMN commentaire TEXT;
@@ -49,6 +49,7 @@ public class LicenceController {
@RequestParam(required = false) String numeroLicence, @RequestParam(required = false) String numeroLicence,
@RequestParam(required = false) String typeDemande, @RequestParam(required = false) String typeDemande,
@RequestParam(required = false) String typeLicence, @RequestParam(required = false) String typeLicence,
@RequestParam(required = false) String commentaire,
@RequestParam(required = false) Long equipeId) { @RequestParam(required = false) Long equipeId) {
Adherent adherent = adherentRepository.findById(id) Adherent adherent = adherentRepository.findById(id)
@@ -73,6 +74,7 @@ public class LicenceController {
licence.setNumeroLicence(numeroLicence); licence.setNumeroLicence(numeroLicence);
licence.setTypeDemande(typeDemande); licence.setTypeDemande(typeDemande);
licence.setTypeLicence(typeLicence); licence.setTypeLicence(typeLicence);
licence.setCommentaire(commentaire);
if (equipeId != null) { if (equipeId != null) {
Equipe equipe = equipeRepository.findById(equipeId) Equipe equipe = equipeRepository.findById(equipeId)
@@ -97,6 +99,7 @@ public class LicenceController {
@RequestParam(required = false) String numeroLicence, @RequestParam(required = false) String numeroLicence,
@RequestParam(required = false) String typeDemande, @RequestParam(required = false) String typeDemande,
@RequestParam(required = false) String typeLicence, @RequestParam(required = false) String typeLicence,
@RequestParam(required = false) String commentaire,
@RequestParam(required = false) Long equipeId) { @RequestParam(required = false) Long equipeId) {
Licence licence = licenceRepository.findById(licenceId) Licence licence = licenceRepository.findById(licenceId)
@@ -110,6 +113,7 @@ public class LicenceController {
licence.setNumeroLicence(numeroLicence); licence.setNumeroLicence(numeroLicence);
licence.setTypeDemande(typeDemande); licence.setTypeDemande(typeDemande);
licence.setTypeLicence(typeLicence); licence.setTypeLicence(typeLicence);
licence.setCommentaire(commentaire);
if (equipeId != null) { if (equipeId != null) {
Equipe equipe = equipeRepository.findById(equipeId) Equipe equipe = equipeRepository.findById(equipeId)
@@ -259,7 +259,8 @@
th:data-type-demande="${lic.typeDemande}" th:data-type-demande="${lic.typeDemande}"
th:data-type-licence="${lic.typeLicence}" th:data-type-licence="${lic.typeLicence}"
th:data-equipe-id="${lic.equipe != null ? lic.equipe.id : ''}" th:data-equipe-id="${lic.equipe != null ? lic.equipe.id : ''}"
onclick="openLicenceModal(this.getAttribute('data-licence-id'), this.getAttribute('data-categorie-id'), this.getAttribute('data-numero-licence'), this.getAttribute('data-etat'), this.getAttribute('data-type-demande'), this.getAttribute('data-type-licence'), this.getAttribute('data-equipe-id'))" th:data-commentaire="${lic.commentaire}"
onclick="openLicenceModal(this.getAttribute('data-licence-id'), this.getAttribute('data-categorie-id'), this.getAttribute('data-numero-licence'), this.getAttribute('data-etat'), this.getAttribute('data-type-demande'), this.getAttribute('data-type-licence'), this.getAttribute('data-equipe-id'), this.getAttribute('data-commentaire'))"
class="text-blue-600 hover:text-blue-800 font-medium bg-blue-50 px-3 py-1 rounded-lg">Modifier</button> class="text-blue-600 hover:text-blue-800 font-medium bg-blue-50 px-3 py-1 rounded-lg">Modifier</button>
<button th:if="${lic.getResteAPayer() > 0}" <button th:if="${lic.getResteAPayer() > 0}"
type="button" type="button"
@@ -513,6 +514,10 @@
<option value="Payée">Payée</option> <option value="Payée">Payée</option>
</select> </select>
</div> </div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Commentaire</label>
<textarea id="licenceCommentaireInput" name="commentaire" rows="3" class="w-full border border-gray-300 rounded-lg px-4 py-2 text-sm focus:ring-2 focus:ring-blue-500 outline-none" placeholder="Commentaire optionnel..."></textarea>
</div>
<div class="items-center px-4 py-3 flex justify-end space-x-2"> <div class="items-center px-4 py-3 flex justify-end space-x-2">
<button type="button" onclick="closeLicenceModal()" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50">Annuler</button> <button type="button" onclick="closeLicenceModal()" class="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50">Annuler</button>
<button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700">Enregistrer</button> <button type="submit" class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700">Enregistrer</button>
@@ -603,7 +608,7 @@
</div> </div>
<script th:inline="javascript"> <script th:inline="javascript">
function openLicenceModal(licenceId = null, categorieId = '', numeroLicence = '', etat = 'Brouillon', typeDemande = '', typeLicence = '', equipeId = '') { function openLicenceModal(licenceId = null, categorieId = '', numeroLicence = '', etat = 'Brouillon', typeDemande = '', typeLicence = '', equipeId = '', commentaire = '') {
document.getElementById('licenceModal').classList.remove('hidden'); document.getElementById('licenceModal').classList.remove('hidden');
const form = document.getElementById('licenceForm'); const form = document.getElementById('licenceForm');
const title = document.getElementById('licenceModalTitle'); const title = document.getElementById('licenceModalTitle');
@@ -622,6 +627,7 @@
document.getElementById('etatSelect').value = etat; document.getElementById('etatSelect').value = etat;
document.getElementById('typeDemandeSelect').value = typeDemande; document.getElementById('typeDemandeSelect').value = typeDemande;
document.getElementById('typeLicenceSelect').value = typeLicence; document.getElementById('typeLicenceSelect').value = typeLicence;
document.getElementById('licenceCommentaireInput').value = commentaire || '';
// Fetch and populate teams // Fetch and populate teams
if (categorieId) { if (categorieId) {
@@ -637,6 +643,7 @@
form.action = '/adherents/' + adherentId + '/licences'; form.action = '/adherents/' + adherentId + '/licences';
document.getElementById('numeroLicenceInput').value = ''; document.getElementById('numeroLicenceInput').value = '';
document.getElementById('etatSelect').value = 'Brouillon'; document.getElementById('etatSelect').value = 'Brouillon';
document.getElementById('licenceCommentaireInput').value = '';
// Pré-remplissage du type de demande // Pré-remplissage du type de demande
const adherentTypeDemande = document.getElementById('typeDemande') ? document.getElementById('typeDemande').value : ''; const adherentTypeDemande = document.getElementById('typeDemande') ? document.getElementById('typeDemande').value : '';