From 9a09f9e7ee8f8860647a25d8eec35b2401a972c5 Mon Sep 17 00:00:00 2001
From: Yvon <yvon.kerdoncuff@gmail.com>
Date: Mon, 22 Apr 2024 12:35:57 +0200
Subject: [PATCH] hide fix balance fields by default and show them on click on a btn

---
 assets/js/admin.js          |  8 ++++++++
 src/Admin/AdherentAdmin.php |  9 ++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/assets/js/admin.js b/assets/js/admin.js
index cbea209..28d0f99 100644
--- a/assets/js/admin.js
+++ b/assets/js/admin.js
@@ -10,6 +10,7 @@ require('../css/admin.css');
 require('bootstrap');
 require('../css/common.css');
 require('../js/geoloc.js');
+const $ = require("jquery");
 
 $('#flash-messages').flashNotification('init');
 
@@ -130,4 +131,11 @@ $(document).ready(function() {
 		}
 		actionOnRecevoirUnRappelChange();
 	}
+
+	if($(".fixBalanceAdherentFormPart").length > 0) {
+		$(".fixBalanceAdherentFormPart").parent().parent().hide();
+		$("div[id$='_idmlc']").append(
+			"<br/><input type='button' id='showFieldsToFixBalance' onclick='$(\".fixBalanceAdherentFormPart\").parent().parent().show();' value='Afficher les champs pour corriger le solde'> </input>"
+		);
+	}
 });
diff --git a/src/Admin/AdherentAdmin.php b/src/Admin/AdherentAdmin.php
index 22bdb60..dc356e3 100644
--- a/src/Admin/AdherentAdmin.php
+++ b/src/Admin/AdherentAdmin.php
@@ -371,14 +371,16 @@ class AdherentAdmin extends AbstractAdmin
                                     'mapped' => false,
                                     'required' => false,
                                     'attr' => [
-                                        'autocomplete' => 'off'
+                                        'autocomplete' => 'off',
+                                        'class' => 'fixBalanceAdherentFormPart'
                                     ]
                                 ])
                                 ->add('justification', TextType::class, [
                                     'mapped' => false,
                                     'required' => false,
                                     'attr' => [
-                                        'autocomplete' => 'off'
+                                        'autocomplete' => 'off',
+                                        'class' => 'fixBalanceAdherentFormPart'
                                     ]
                                 ])
                                 ->add('password', PasswordType::class, [
@@ -387,7 +389,8 @@ class AdherentAdmin extends AbstractAdmin
                                     'required' => false,
                                     'data' => "",
                                     'attr' => [
-                                        'autocomplete' => 'off'
+                                        'autocomplete' => 'off',
+                                        'class' => 'fixBalanceAdherentFormPart'
                                     ]
                                 ])
                             ->end()
--
libgit2 0.26.0