From 09386f8aa640e3b77a18b93f120c131a25d75222 Mon Sep 17 00:00:00 2001 From: Julien Martin Date: Fri, 17 Jul 2026 14:56:32 +0200 Subject: [PATCH] feat(#145): lien co-parent cliquable dans la fiche parent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../admin/common/admin_parent_edit_modal.dart | 77 ++++++++++++++++--- 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/frontend/lib/widgets/admin/common/admin_parent_edit_modal.dart b/frontend/lib/widgets/admin/common/admin_parent_edit_modal.dart index b1fe436..85c70a6 100644 --- a/frontend/lib/widgets/admin/common/admin_parent_edit_modal.dart +++ b/frontend/lib/widgets/admin/common/admin_parent_edit_modal.dart @@ -113,10 +113,73 @@ class _AdminParentEditModalState extends State { return '$fn $ln'.trim(); } - String? _coParentSubtitle() { + String? _coParentName() { final name = _coParent?.fullName.trim() ?? ''; - if (name.isEmpty) return null; - return 'Co-parent : $name'; + return name.isEmpty ? null : name; + } + + Future _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( + 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 _save() async { @@ -395,13 +458,7 @@ class _AdminParentEditModalState extends State { ), if (_coParentSubtitle() != null) ...[ const SizedBox(height: 4), - Text( - _coParentSubtitle()!, - style: const TextStyle( - fontSize: 13, - color: Colors.black54, - ), - ), + _coParentSubtitle()!, ], ], ),