feat(org-types): retirer le champ code du formulaire de création
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).
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user