From f74f13c1742a782c7239fe45dd897089821df8f1 Mon Sep 17 00:00:00 2001 From: dahoud <41957584+DahoudG@users.noreply.github.com> Date: Thu, 16 Apr 2026 10:21:43 +0000 Subject: [PATCH] =?UTF-8?q?feat(org-types):=20retirer=20le=20champ=20code?= =?UTF-8?q?=20du=20formulaire=20de=20cr=C3=A9ation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le code technique est désormais auto-généré par le backend depuis le libellé. Création : le champ code est supprimé du formulaire. Le backend génère automatiquement un code UPPER_SNAKE_CASE depuis le libellé saisi. Édition : le code existant est affiché en lecture seule (container gris monospace) pour information — non modifiable (les types système sont protégés). Le paramètre code: '' est envoyé en création (le backend détecte le vide et auto-génère). --- .../presentation/pages/org_types_page.dart | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/features/organizations/presentation/pages/org_types_page.dart b/lib/features/organizations/presentation/pages/org_types_page.dart index 60d2fb2..cb1fdbe 100644 --- a/lib/features/organizations/presentation/pages/org_types_page.dart +++ b/lib/features/organizations/presentation/pages/org_types_page.dart @@ -422,21 +422,31 @@ class _OrgTypeFormSheetState extends State<_OrgTypeFormSheet> { ), const SizedBox(height: 14), - // Code - TextFormField( - controller: _codeCtrl, - decoration: InputDecoration( - labelText: 'Code technique *', - hintText: 'Ex: ASSOCIATION', - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), - isDense: true, + // Code technique — auto-généré par le backend depuis le libellé. + // En mode édition, afficher en lecture seule pour information. + if (isEdit && _codeCtrl.text.isNotEmpty) ...[ + Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHighest, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: Theme.of(context).colorScheme.outline.withOpacity(0.3)), + ), + child: Row( + children: [ + Icon(Icons.code, size: 14, color: textSecondary), + const SizedBox(width: 8), + Text( + _codeCtrl.text, + style: TextStyle(fontSize: 11, fontWeight: FontWeight.w600, + color: textSecondary, fontFamily: 'monospace'), + ), + ], + ), ), - textCapitalization: TextCapitalization.characters, - style: const TextStyle(fontSize: 12), - validator: (v) => (v == null || v.trim().isEmpty) ? 'Code requis' : null, - ), - const SizedBox(height: 10), + const SizedBox(height: 10), + ], // Libellé TextFormField( @@ -531,8 +541,9 @@ class _OrgTypeFormSheetState extends State<_OrgTypeFormSheet> { ordreAffichage: widget.existing!.ordreAffichage, )); } else { + // Code technique auto-généré par le backend depuis le libellé — pas envoyé en création widget.bloc.add(CreateOrgTypeEvent( - code: _codeCtrl.text.trim(), + code: '', // auto-généré côté backend libelle: _libelleCtrl.text.trim(), description: _descCtrl.text.trim().isEmpty ? null : _descCtrl.text.trim(), couleur: _selectedColor,