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),
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
// Code
|
// Code technique — auto-généré par le backend depuis le libellé.
|
||||||
TextFormField(
|
// En mode édition, afficher en lecture seule pour information.
|
||||||
controller: _codeCtrl,
|
if (isEdit && _codeCtrl.text.isNotEmpty) ...[
|
||||||
decoration: InputDecoration(
|
Container(
|
||||||
labelText: 'Code technique *',
|
width: double.infinity,
|
||||||
hintText: 'Ex: ASSOCIATION',
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
decoration: BoxDecoration(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
isDense: true,
|
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é
|
// Libellé
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -531,8 +541,9 @@ class _OrgTypeFormSheetState extends State<_OrgTypeFormSheet> {
|
|||||||
ordreAffichage: widget.existing!.ordreAffichage,
|
ordreAffichage: widget.existing!.ordreAffichage,
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
|
// Code technique auto-généré par le backend depuis le libellé — pas envoyé en création
|
||||||
widget.bloc.add(CreateOrgTypeEvent(
|
widget.bloc.add(CreateOrgTypeEvent(
|
||||||
code: _codeCtrl.text.trim(),
|
code: '', // auto-généré côté backend
|
||||||
libelle: _libelleCtrl.text.trim(),
|
libelle: _libelleCtrl.text.trim(),
|
||||||
description: _descCtrl.text.trim().isEmpty ? null : _descCtrl.text.trim(),
|
description: _descCtrl.text.trim().isEmpty ? null : _descCtrl.text.trim(),
|
||||||
couleur: _selectedColor,
|
couleur: _selectedColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user