fix(#173): actions en pilules + modales, fin des libellés À traiter

Arrêt maladie reste visible jusqu’à la date de fin ; accepter /
refuser / ack passent par une confirmation modale.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-01 17:10:41 +02:00
co-authored by Cursor
parent 2832499d3e
commit 535af3b146
3 changed files with 187 additions and 61 deletions
+21
View File
@@ -101,6 +101,27 @@ class CarteBulle {
} }
} }
bool get isArretMaladie => typeCode == 'arret_maladie_am';
bool get isCongeAm => typeCode == 'conge_am';
/// Fin de période (jour inclus). Null si dates absentes / invalides.
DateTime? get dateFinJour {
final raw = dateFin;
if (raw == null || raw.isEmpty) return null;
final dt = DateTime.tryParse(raw);
if (dt == null) return null;
return DateTime(dt.year, dt.month, dt.day);
}
/// Vrai tant que la date de fin n’est pas dépassée (jour courant inclus).
bool get periodeEncoreActive {
final fin = dateFinJour;
if (fin == null) return true;
final today = DateTime.now();
final todayDay = DateTime(today.year, today.month, today.day);
return !todayDay.isAfter(fin);
}
/// Asset horizontal pastel (palette `assets/cards/` uniquement). /// Asset horizontal pastel (palette `assets/cards/` uniquement).
String get backgroundAsset { String get backgroundAsset {
final key = (couleur ?? '').trim().toLowerCase(); final key = (couleur ?? '').trim().toLowerCase();
+153 -49
View File
@@ -94,24 +94,95 @@ class _CartesFeedState extends State<CartesFeed> {
} }
} }
Future<void> _onAccept(CarteBulle card) async {
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
title: Text(
'Accepter la demande ?',
style: GoogleFonts.merienda(fontWeight: FontWeight.w600),
),
content: Text(
'Confirmez-vous l’acceptation de « ${card.titreAffiche} » '
'(${_periodeCourte(card)}) ?',
style: GoogleFonts.merriweather(fontSize: 14, height: 1.4),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
child: const Text('Annuler'),
),
FilledButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text('Confirmer'),
),
],
),
);
if (ok == true) {
await _respond(card, action: 'accept');
}
}
Future<void> _onAck(CarteBulle card) async {
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
title: Text(
'Prise en compte',
style: GoogleFonts.merienda(fontWeight: FontWeight.w600),
),
content: Text(
'Confirmez-vous avoir bien reçu cet arrêt maladie '
'(${_periodeCourte(card)}) ?',
style: GoogleFonts.merriweather(fontSize: 14, height: 1.4),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
child: const Text('Annuler'),
),
FilledButton(
onPressed: () => Navigator.pop(ctx, true),
child: const Text('Bien reçu'),
),
],
),
);
if (ok == true) {
await _respond(card, action: 'ack');
}
}
Future<void> _onRefuse(CarteBulle card) async { Future<void> _onRefuse(CarteBulle card) async {
final controller = TextEditingController(); final controller = TextEditingController();
final ok = await showDialog<bool>( final ok = await showDialog<bool>(
context: context, context: context,
builder: (ctx) => AlertDialog( builder: (ctx) => AlertDialog(
title: Text( title: Text(
'Motiver le refus', 'Refuser la demande',
style: GoogleFonts.merienda(fontWeight: FontWeight.w600), style: GoogleFonts.merienda(fontWeight: FontWeight.w600),
), ),
content: TextField( content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Indiquez le motif du refus pour « ${card.titreAffiche} ».',
style: GoogleFonts.merriweather(fontSize: 14, height: 1.4),
),
const SizedBox(height: 12),
TextField(
controller: controller, controller: controller,
maxLines: 3, maxLines: 3,
autofocus: true, autofocus: true,
decoration: const InputDecoration( decoration: const InputDecoration(
hintText: 'Expliquez le motif du refus…', hintText: 'Motif du refus…',
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
), ),
],
),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => Navigator.pop(ctx, false), onPressed: () => Navigator.pop(ctx, false),
@@ -137,6 +208,21 @@ class _CartesFeedState extends State<CartesFeed> {
controller.dispose(); controller.dispose();
} }
static String _periodeCourte(CarteBulle card) {
final d = card.dateDebut;
final f = card.dateFin;
String fmt(String? iso) {
if (iso == null || iso.isEmpty) return '…';
final dt = DateTime.tryParse(iso);
if (dt == null) return iso;
return '${dt.day.toString().padLeft(2, '0')}/'
'${dt.month.toString().padLeft(2, '0')}/${dt.year}';
}
if (d == null && f == null) return 'période non précisée';
if (d != null && f != null && d == f) return fmt(d);
return '${fmt(d)} → ${fmt(f)}';
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
@@ -229,8 +315,8 @@ class _CartesFeedState extends State<CartesFeed> {
return _BulleTile( return _BulleTile(
card: card, card: card,
busy: _busyCardId == card.id, busy: _busyCardId == card.id,
onAccept: () => _respond(card, action: 'accept'), onAccept: () => _onAccept(card),
onAck: () => _respond(card, action: 'ack'), onAck: () => _onAck(card),
onRefuse: () => _onRefuse(card), onRefuse: () => _onRefuse(card),
); );
}, },
@@ -271,22 +357,26 @@ class _BulleTile extends StatelessWidget {
return '$jj/$mm/${dt.year}'; return '$jj/$mm/${dt.year}';
} }
String get _statutLabel { /// Pas de « À traiter / Traité » : seulement un indice utile (refus / attente créateur).
switch (card.statut) { String? get _indice {
case CarteStatut.ouverte: if (card.statut == CarteStatut.refusee) return 'Refusé';
return card.isCreator ? 'En attente' : 'À traiter'; if (card.statut == CarteStatut.ouverte && card.isCreator) {
case CarteStatut.refusee: return 'En attente de réponse';
return 'Refusé';
case CarteStatut.traitee:
return 'Traité';
} }
return null;
}
/// Arrêt maladie : reste opaque tant que la période n’est pas finie.
bool get _attenuee {
if (card.isArretMaladie && card.periodeEncoreActive) return false;
return card.statut == CarteStatut.traitee;
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final treated = card.statut == CarteStatut.traitee; final indice = _indice;
return Opacity( return Opacity(
opacity: treated ? 0.55 : 1, opacity: _attenuee ? 0.55 : 1,
child: Carte( child: Carte(
assetPath: card.backgroundAsset, assetPath: card.backgroundAsset,
constraints: const BoxConstraints(minHeight: 96), constraints: const BoxConstraints(minHeight: 96),
@@ -295,6 +385,7 @@ class _BulleTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
@@ -308,8 +399,9 @@ class _BulleTile extends StatelessWidget {
), ),
), ),
), ),
if (indice != null)
Text( Text(
_statutLabel, indice,
style: GoogleFonts.merriweather( style: GoogleFonts.merriweather(
fontSize: 11, fontSize: 11,
color: QuotidienTheme.muted, color: QuotidienTheme.muted,
@@ -344,7 +436,7 @@ class _BulleTile extends StatelessWidget {
card.lastRefuseComment!.trim().isNotEmpty) ...[ card.lastRefuseComment!.trim().isNotEmpty) ...[
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
'Motif refus : ${card.lastRefuseComment}', 'Motif : ${card.lastRefuseComment}',
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: GoogleFonts.merriweather( style: GoogleFonts.merriweather(
@@ -355,10 +447,10 @@ class _BulleTile extends StatelessWidget {
), ),
], ],
if (card.peutRepondre) ...[ if (card.peutRepondre) ...[
const SizedBox(height: 8), const SizedBox(height: 10),
if (busy) if (busy)
const Align( const Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerRight,
child: SizedBox( child: SizedBox(
width: 18, width: 18,
height: 18, height: 18,
@@ -366,25 +458,30 @@ class _BulleTile extends StatelessWidget {
), ),
) )
else else
Wrap( Row(
spacing: 8, mainAxisAlignment: MainAxisAlignment.end,
runSpacing: 4,
children: [ children: [
if (card.responseMode == if (card.responseMode ==
CarteResponseMode.acceptRefuse) ...[ CarteResponseMode.acceptRefuse) ...[
_ActionChip( _ActionPill(
label: 'Accepter', asset: QuotidienTheme.pillTurquoiseAsset,
iconAsset: 'assets/images/coche.png',
tooltip: 'Accepter',
onTap: onAccept, onTap: onAccept,
), ),
_ActionChip( const SizedBox(width: 10),
label: 'Refuser', _ActionPill(
asset: QuotidienTheme.pillCorailAsset,
iconAsset: 'assets/images/red_cross2.png',
tooltip: 'Refuser',
onTap: onRefuse, onTap: onRefuse,
destructive: true,
), ),
], ],
if (card.responseMode == CarteResponseMode.ack) if (card.responseMode == CarteResponseMode.ack)
_ActionChip( _ActionPill(
label: 'Bien reçu', asset: QuotidienTheme.pillTurquoiseAsset,
iconAsset: 'assets/images/coche.png',
tooltip: 'Bien reçu',
onTap: onAck, onTap: onAck,
), ),
], ],
@@ -397,36 +494,43 @@ class _BulleTile extends StatelessWidget {
} }
} }
class _ActionChip extends StatelessWidget { /// Bouton pilule dessiné (fond pastel + coche / croix).
final String label; class _ActionPill extends StatelessWidget {
final String asset;
final String iconAsset;
final String tooltip;
final VoidCallback onTap; final VoidCallback onTap;
final bool destructive;
const _ActionChip({ const _ActionPill({
required this.label, required this.asset,
required this.iconAsset,
required this.tooltip,
required this.onTap, required this.onTap,
this.destructive = false,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Material( return Tooltip(
color: Colors.white.withValues(alpha: 0.55), message: tooltip,
borderRadius: BorderRadius.circular(16),
child: InkWell( child: InkWell(
onTap: onTap, onTap: onTap,
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(20),
child: Padding( child: SizedBox(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), width: 52,
child: Text( height: 32,
label, child: Stack(
style: GoogleFonts.merriweather( alignment: Alignment.center,
fontSize: 12, children: [
fontWeight: FontWeight.w600, Positioned.fill(
color: destructive child: Image.asset(asset, fit: BoxFit.fill),
? const Color(0xFFB00020)
: QuotidienTheme.ink,
), ),
Image.asset(
iconAsset,
height: 18,
width: 18,
fit: BoxFit.contain,
),
],
), ),
), ),
), ),
@@ -49,6 +49,7 @@ abstract final class QuotidienTheme {
'assets/images/bg_turquoise_pill.png'; 'assets/images/bg_turquoise_pill.png';
static const String pillLavenderAsset = static const String pillLavenderAsset =
'assets/images/bg_lavender_pill.png'; 'assets/images/bg_lavender_pill.png';
static const String pillCorailAsset = 'assets/images/bg_corail_pill.png';
/// Trait crayon gris (2400×28, transparent) : séparateurs bandeau / corps / /// Trait crayon gris (2400×28, transparent) : séparateurs bandeau / corps /
/// footer. Version verticale (28×2400) entre les colonnes. /// footer. Version verticale (28×2400) entre les colonnes.