feat(#145): lien co-parent cliquable dans la fiche parent.
Même UX que les responsables de la fiche enfant : ouverture de AdminParentEditModal au clic sur le nom du co-parent. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
faa50f637c
commit
09386f8aa6
@ -113,10 +113,73 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
|||||||
return '$fn $ln'.trim();
|
return '$fn $ln'.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
String? _coParentSubtitle() {
|
String? _coParentName() {
|
||||||
final name = _coParent?.fullName.trim() ?? '';
|
final name = _coParent?.fullName.trim() ?? '';
|
||||||
if (name.isEmpty) return null;
|
return name.isEmpty ? null : name;
|
||||||
return 'Co-parent : $name';
|
}
|
||||||
|
|
||||||
|
Future<void> _openCoParent() async {
|
||||||
|
if (_saving) return;
|
||||||
|
final co = _coParent;
|
||||||
|
final id = (co?.id ?? '').trim();
|
||||||
|
if (co == null || id.isEmpty) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final parent = await UserService.getParent(id);
|
||||||
|
if (!mounted) return;
|
||||||
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AdminParentEditModal(
|
||||||
|
parent: parent,
|
||||||
|
onSaved: () async {
|
||||||
|
try {
|
||||||
|
final refreshed = await UserService.getParent(widget.parent.user.id);
|
||||||
|
if (!mounted) return;
|
||||||
|
setState(() => _coParent = refreshed.coParent);
|
||||||
|
} catch (_) {}
|
||||||
|
widget.onSaved?.call();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (!mounted) return;
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text(e.toString().replaceFirst('Exception: ', ''))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget? _coParentSubtitle() {
|
||||||
|
final name = _coParentName();
|
||||||
|
if (name == null) return null;
|
||||||
|
|
||||||
|
return Wrap(
|
||||||
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Co-parent : ',
|
||||||
|
style: TextStyle(fontSize: 13, color: Colors.black54),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: _saving ? null : _openCoParent,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 2),
|
||||||
|
child: Text(
|
||||||
|
name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: ValidationModalTheme.primaryActionBackground,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
decorationColor: ValidationModalTheme.primaryActionBackground
|
||||||
|
.withValues(alpha: 0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _save() async {
|
Future<void> _save() async {
|
||||||
@ -395,13 +458,7 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
|||||||
),
|
),
|
||||||
if (_coParentSubtitle() != null) ...[
|
if (_coParentSubtitle() != null) ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
_coParentSubtitle()!,
|
||||||
_coParentSubtitle()!,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: Colors.black54,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user