Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d84cc7e13e | ||
|
|
38af471054 | ||
|
|
7f554e2ba3 | ||
|
|
d05a5e22b2 | ||
|
|
e6be1dffc4 | ||
|
|
cec1fc2ba7 | ||
|
|
1c0ff71f26 |
@@ -0,0 +1,87 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { Users } from './users.entity';
|
||||
|
||||
/** Aligné sur type_evenement_agenda_type (évite import circulaire avec EvenementsAgenda). */
|
||||
export enum AgendaLotTypeType {
|
||||
ABSENCE_ENFANT = 'absence_enfant',
|
||||
CONGE_AM = 'conge_am',
|
||||
ARRET_MALADIE_AM = 'arret_maladie_am',
|
||||
SOIN_ENFANT = 'soin_enfant',
|
||||
}
|
||||
|
||||
export enum AgendaLotStatutType {
|
||||
EN_ATTENTE = 'en_attente',
|
||||
ACCEPTE = 'accepte',
|
||||
REFUSE = 'refuse',
|
||||
ANNULE = 'annule',
|
||||
}
|
||||
|
||||
/**
|
||||
* Lot collectif Agenda (congé / arrêt / absence groupés) — cycle versionné.
|
||||
* Ticket #214 (B0).
|
||||
*/
|
||||
@Entity('agenda_lots', { schema: 'public' })
|
||||
export class AgendaLots {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: AgendaLotTypeType,
|
||||
enumName: 'type_evenement_agenda_type',
|
||||
name: 'type',
|
||||
})
|
||||
type: AgendaLotTypeType;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: AgendaLotStatutType,
|
||||
enumName: 'agenda_lot_statut_type',
|
||||
name: 'statut',
|
||||
default: AgendaLotStatutType.EN_ATTENTE,
|
||||
})
|
||||
statut: AgendaLotStatutType;
|
||||
|
||||
@Column({ name: 'revision', type: 'int', default: 1 })
|
||||
revision: number;
|
||||
|
||||
@Column({ name: 'soumis_le', type: 'timestamptz', default: () => 'now()' })
|
||||
soumis_le: Date;
|
||||
|
||||
@Column({ name: 'verrouille_le', type: 'timestamptz', nullable: true })
|
||||
verrouille_le?: Date;
|
||||
|
||||
@Column({ name: 'refuse_le', type: 'timestamptz', nullable: true })
|
||||
refuse_le?: Date;
|
||||
|
||||
@Column({ name: 'annule_le', type: 'timestamptz', nullable: true })
|
||||
annule_le?: Date;
|
||||
|
||||
@Column({ name: 'annule_par', type: 'uuid', nullable: true })
|
||||
annule_par?: string;
|
||||
|
||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'annule_par', referencedColumnName: 'id' })
|
||||
annulePar?: Users;
|
||||
|
||||
@Column({ name: 'cree_par', type: 'uuid', nullable: true })
|
||||
cree_par?: string;
|
||||
|
||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'cree_par', referencedColumnName: 'id' })
|
||||
createdBy?: Users;
|
||||
|
||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||
cree_le: Date;
|
||||
|
||||
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
||||
modifie_le: Date;
|
||||
}
|
||||
@@ -14,16 +14,19 @@ import { Users } from './users.entity';
|
||||
import { CardType } from './card_types.entity';
|
||||
import { CardAudienceMember } from './card_audience_members.entity';
|
||||
import { CardResponse } from './card_responses.entity';
|
||||
import { AgendaLots } from './agenda_lots.entity';
|
||||
|
||||
export enum CardInstanceStatutType {
|
||||
OUVERTE = 'ouverte',
|
||||
REFUSEE = 'refusee',
|
||||
TRAITEE = 'traitee',
|
||||
ANNULEE = 'annulee',
|
||||
}
|
||||
|
||||
export enum CardOperationType {
|
||||
CREATE = 'create',
|
||||
UPDATE = 'update',
|
||||
CANCEL = 'cancel',
|
||||
}
|
||||
|
||||
@Entity('card_instances', { schema: 'public' })
|
||||
@@ -83,6 +86,27 @@ export class CardInstance {
|
||||
@Column({ name: 'purge_at', type: 'timestamptz' })
|
||||
purge_at: Date;
|
||||
|
||||
@Column({ name: 'id_lot', type: 'uuid', nullable: true })
|
||||
id_lot?: string;
|
||||
|
||||
@ManyToOne(() => AgendaLots, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'id_lot', referencedColumnName: 'id' })
|
||||
lot?: AgendaLots;
|
||||
|
||||
@Column({ name: 'annule_le', type: 'timestamptz', nullable: true })
|
||||
annule_le?: Date;
|
||||
|
||||
@Column({ name: 'annule_par', type: 'uuid', nullable: true })
|
||||
annule_par?: string;
|
||||
|
||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'annule_par', referencedColumnName: 'id' })
|
||||
annulePar?: Users;
|
||||
|
||||
/** Réanimation dans le fil (tri COALESCE(remonte_le, cree_le)). */
|
||||
@Column({ name: 'remonte_le', type: 'timestamptz', nullable: true })
|
||||
remonte_le?: Date;
|
||||
|
||||
@OneToMany(() => CardAudienceMember, (m) => m.card)
|
||||
audience: CardAudienceMember[];
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ export class CardResponse {
|
||||
@Column({ name: 'comment', type: 'text', nullable: true })
|
||||
comment?: string;
|
||||
|
||||
/** Doit matcher agenda_lots.revision pour compter dans l'unanimité (#214). */
|
||||
@Column({ name: 'revision_lot', type: 'int', default: 1 })
|
||||
revision_lot: number;
|
||||
|
||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||
cree_le: Date;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from 'typeorm';
|
||||
import { AmChildren } from './am_children.entity';
|
||||
import { Users } from './users.entity';
|
||||
import { AgendaLots } from './agenda_lots.entity';
|
||||
|
||||
export enum TypeEvenementAgendaType {
|
||||
ABSENCE_ENFANT = 'absence_enfant',
|
||||
@@ -21,12 +22,13 @@ export enum StatutEvenementAgendaType {
|
||||
EN_ATTENTE = 'en_attente',
|
||||
ACCEPTE = 'accepte',
|
||||
REFUSE = 'refuse',
|
||||
ANNULE = 'annule',
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérité métier agenda par couple AM↔enfant (placement).
|
||||
* Types V1 : absences / congés / arrêts ; extensible (soins, école, mairie…).
|
||||
* Les cartes collectent ; cette table historise. Ticket #205.
|
||||
* Les cartes collectent ; cette table historise. Tickets #205 / #214.
|
||||
*/
|
||||
@Entity('evenements_agenda', { schema: 'public' })
|
||||
export class EvenementsAgenda {
|
||||
@@ -74,13 +76,40 @@ export class EvenementsAgenda {
|
||||
@JoinColumn({ name: 'cree_par', referencedColumnName: 'id' })
|
||||
createdBy?: Users;
|
||||
|
||||
/** Réf. carte de collecte (FK quand module Cartes existera). */
|
||||
/** Réf. carte de collecte (module Cartes). */
|
||||
@Column({ name: 'id_card_instance', type: 'uuid', nullable: true })
|
||||
id_card_instance?: string;
|
||||
|
||||
@Column({ name: 'motif', type: 'text', nullable: true })
|
||||
motif?: string;
|
||||
|
||||
/** Heure métier (soin) — durable hors payload carte. */
|
||||
@Column({ name: 'heure', type: 'time', nullable: true })
|
||||
heure?: string;
|
||||
|
||||
@Column({ name: 'id_lot', type: 'uuid', nullable: true })
|
||||
id_lot?: string;
|
||||
|
||||
@ManyToOne(() => AgendaLots, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'id_lot', referencedColumnName: 'id' })
|
||||
lot?: AgendaLots;
|
||||
|
||||
@Column({ name: 'verrouille_le', type: 'timestamptz', nullable: true })
|
||||
verrouille_le?: Date;
|
||||
|
||||
@Column({ name: 'refuse_le', type: 'timestamptz', nullable: true })
|
||||
refuse_le?: Date;
|
||||
|
||||
@Column({ name: 'annule_le', type: 'timestamptz', nullable: true })
|
||||
annule_le?: Date;
|
||||
|
||||
@Column({ name: 'annule_par', type: 'uuid', nullable: true })
|
||||
annule_par?: string;
|
||||
|
||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'annule_par', referencedColumnName: 'id' })
|
||||
annulePar?: Users;
|
||||
|
||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||
cree_le: Date;
|
||||
|
||||
|
||||
@@ -177,6 +177,10 @@ export class Users {
|
||||
@Column({ nullable: true, name: 'numero_dossier', length: 20 })
|
||||
numero_dossier?: string;
|
||||
|
||||
/** Préférences UI (ex. jours_affiches_semaine) — #214 */
|
||||
@Column({ name: 'preferences', type: 'jsonb', default: {} })
|
||||
preferences: Record<string, unknown>;
|
||||
|
||||
@ManyToOne(() => Relais, relais => relais.gestionnaires, { nullable: true })
|
||||
@JoinColumn({ name: 'relais_id' })
|
||||
relais?: Relais;
|
||||
|
||||
+43
-3
@@ -42,7 +42,12 @@ DO $$ BEGIN
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'statut_evenement_agenda_type') THEN
|
||||
CREATE TYPE statut_evenement_agenda_type AS ENUM (
|
||||
'en_attente', 'accepte', 'refuse'
|
||||
'en_attente', 'accepte', 'refuse', 'annule'
|
||||
);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'agenda_lot_statut_type') THEN
|
||||
CREATE TYPE agenda_lot_statut_type AS ENUM (
|
||||
'en_attente', 'accepte', 'refuse', 'annule'
|
||||
);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'statut_validation_type') THEN
|
||||
@@ -109,7 +114,8 @@ CREATE TABLE utilisateurs (
|
||||
ville VARCHAR(150),
|
||||
code_postal VARCHAR(10),
|
||||
profession VARCHAR(150),
|
||||
situation_familiale situation_familiale_type
|
||||
situation_familiale situation_familiale_type,
|
||||
preferences JSONB NOT NULL DEFAULT '{}'::jsonb
|
||||
);
|
||||
|
||||
CREATE INDEX idx_utilisateurs_token_creation_mdp
|
||||
@@ -321,9 +327,31 @@ CREATE TABLE avenants_contrats (
|
||||
modifie_le TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
-- ==========================================================
|
||||
-- Table : agenda_lots (cycles collectifs versionnés — #214)
|
||||
-- ==========================================================
|
||||
CREATE TABLE agenda_lots (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
type type_evenement_agenda_type NOT NULL,
|
||||
statut agenda_lot_statut_type NOT NULL DEFAULT 'en_attente',
|
||||
revision INT NOT NULL DEFAULT 1,
|
||||
soumis_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
verrouille_le TIMESTAMPTZ,
|
||||
refuse_le TIMESTAMPTZ,
|
||||
annule_le TIMESTAMPTZ,
|
||||
annule_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
modifie_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT chk_agenda_lots_revision CHECK (revision >= 1)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_agenda_lots_type_statut ON agenda_lots (type, statut);
|
||||
CREATE INDEX idx_agenda_lots_soumis_le ON agenda_lots (soumis_le);
|
||||
|
||||
-- ==========================================================
|
||||
-- Table : evenements_agenda (vérité métier agenda (absences/congés/arrêt + futurs types))
|
||||
-- 1 ligne = 1 période ; rattachement = placement AM↔enfant (#193)
|
||||
-- 1 ligne = 1 période ; rattachement = placement AM↔enfant (#193 / #214)
|
||||
-- ==========================================================
|
||||
CREATE TABLE evenements_agenda (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
@@ -337,6 +365,12 @@ CREATE TABLE evenements_agenda (
|
||||
cree_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
id_card_instance UUID,
|
||||
motif TEXT,
|
||||
heure TIME,
|
||||
id_lot UUID REFERENCES agenda_lots(id) ON DELETE SET NULL,
|
||||
verrouille_le TIMESTAMPTZ,
|
||||
refuse_le TIMESTAMPTZ,
|
||||
annule_le TIMESTAMPTZ,
|
||||
annule_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
modifie_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT chk_evenements_agenda_dates CHECK (date_fin >= date_debut)
|
||||
@@ -349,6 +383,12 @@ CREATE INDEX idx_evenements_agenda_placement_type_statut
|
||||
CREATE INDEX idx_evenements_agenda_expire_at
|
||||
ON evenements_agenda (expire_at)
|
||||
WHERE statut IN ('en_attente', 'refuse');
|
||||
CREATE INDEX idx_evenements_agenda_id_lot
|
||||
ON evenements_agenda (id_lot)
|
||||
WHERE id_lot IS NOT NULL;
|
||||
CREATE INDEX idx_evenements_agenda_placement_dates_actif
|
||||
ON evenements_agenda (id_placement, date_debut, date_fin)
|
||||
WHERE statut IS DISTINCT FROM 'annule';
|
||||
|
||||
-- ==========================================================
|
||||
-- Table : signalements_bugs
|
||||
|
||||
+17
-2
@@ -119,7 +119,7 @@ Ce document recense **toutes les valeurs énumérées** utilisées dans la base
|
||||
|
||||
---
|
||||
|
||||
## 8) Statut d’absence de garde — `statut`
|
||||
## 8) Statut d’événement agenda — `statut`
|
||||
|
||||
**Tables/colonnes** : `evenements_agenda.statut`
|
||||
**Valeurs autorisées** :
|
||||
@@ -128,7 +128,22 @@ Ce document recense **toutes les valeurs énumérées** utilisées dans la base
|
||||
|---|---|
|
||||
| `en_attente` | En attente de validation / ack |
|
||||
| `accepte` | Accepté / acté (conservé en historique métier) |
|
||||
| `refuse` | Refusé (temporaire ; purge TTL) |
|
||||
| `refuse` | Refusé (temporaire ; visible barré puis soft-cancel) |
|
||||
| `annule` | Annulation douce (#214) — hors vues normales, auditable |
|
||||
|
||||
---
|
||||
|
||||
## 8bis) Statut de lot agenda — `agenda_lots.statut`
|
||||
|
||||
**Enum** : `agenda_lot_statut_type`
|
||||
**Valeurs** : `en_attente` · `accepte` · `refuse` · `annule` (issue globale du lot versionné, #214)
|
||||
|
||||
---
|
||||
|
||||
## 8ter) Cartes — soft-cancel / opération
|
||||
|
||||
**`card_instance_statut_type`** : `ouverte` · `refusee` · `traitee` · `annulee` (#214)
|
||||
**`card_operation_type`** : `create` · `update` · `cancel` (#214)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
-- Ticket #214 — Agenda B0 : lots versionnés, soft-cancel, prefs, remonte_le
|
||||
-- Migration base live. Idempotent.
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 1. Enums
|
||||
-- ---------------------------------------------------------------------------
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'agenda_lot_statut_type') THEN
|
||||
CREATE TYPE agenda_lot_statut_type AS ENUM (
|
||||
'en_attente', 'accepte', 'refuse', 'annule'
|
||||
);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- PG : ADD VALUE IF NOT EXISTS (hors sous-transaction fragile)
|
||||
ALTER TYPE statut_evenement_agenda_type ADD VALUE IF NOT EXISTS 'annule';
|
||||
ALTER TYPE card_instance_statut_type ADD VALUE IF NOT EXISTS 'annulee';
|
||||
ALTER TYPE card_operation_type ADD VALUE IF NOT EXISTS 'cancel';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 2. Table agenda_lots
|
||||
-- ---------------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS agenda_lots (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
type type_evenement_agenda_type NOT NULL,
|
||||
statut agenda_lot_statut_type NOT NULL DEFAULT 'en_attente',
|
||||
revision INT NOT NULL DEFAULT 1,
|
||||
soumis_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
verrouille_le TIMESTAMPTZ,
|
||||
refuse_le TIMESTAMPTZ,
|
||||
annule_le TIMESTAMPTZ,
|
||||
annule_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_par UUID REFERENCES utilisateurs(id) ON DELETE SET NULL,
|
||||
cree_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
modifie_le TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT chk_agenda_lots_revision CHECK (revision >= 1)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agenda_lots_type_statut
|
||||
ON agenda_lots (type, statut);
|
||||
CREATE INDEX IF NOT EXISTS idx_agenda_lots_soumis_le
|
||||
ON agenda_lots (soumis_le);
|
||||
|
||||
COMMENT ON TABLE agenda_lots IS
|
||||
'Lots collectifs Agenda (congé/arrêt/absence groupés) — cycle versionné (#214).';
|
||||
COMMENT ON COLUMN agenda_lots.revision IS
|
||||
'Incrémenté à chaque resoumission ; les card_responses.revision_lot doivent correspondre.';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 3. evenements_agenda — soft-cancel + lot + heure
|
||||
-- ---------------------------------------------------------------------------
|
||||
ALTER TABLE evenements_agenda
|
||||
ADD COLUMN IF NOT EXISTS annule_le TIMESTAMPTZ,
|
||||
ADD COLUMN IF NOT EXISTS annule_par UUID,
|
||||
ADD COLUMN IF NOT EXISTS verrouille_le TIMESTAMPTZ,
|
||||
ADD COLUMN IF NOT EXISTS refuse_le TIMESTAMPTZ,
|
||||
ADD COLUMN IF NOT EXISTS heure TIME,
|
||||
ADD COLUMN IF NOT EXISTS id_lot UUID;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = 'evenements_agenda_annule_par_fkey'
|
||||
) THEN
|
||||
ALTER TABLE evenements_agenda
|
||||
ADD CONSTRAINT evenements_agenda_annule_par_fkey
|
||||
FOREIGN KEY (annule_par) REFERENCES utilisateurs(id) ON DELETE SET NULL;
|
||||
END IF;
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = 'evenements_agenda_id_lot_fkey'
|
||||
) THEN
|
||||
ALTER TABLE evenements_agenda
|
||||
ADD CONSTRAINT evenements_agenda_id_lot_fkey
|
||||
FOREIGN KEY (id_lot) REFERENCES agenda_lots(id) ON DELETE SET NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_evenements_agenda_id_lot
|
||||
ON evenements_agenda (id_lot)
|
||||
WHERE id_lot IS NOT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_evenements_agenda_verrouille_le
|
||||
ON evenements_agenda (verrouille_le)
|
||||
WHERE verrouille_le IS NOT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_evenements_agenda_refuse_le
|
||||
ON evenements_agenda (refuse_le)
|
||||
WHERE refuse_le IS NOT NULL;
|
||||
|
||||
COMMENT ON COLUMN evenements_agenda.heure IS
|
||||
'Heure métier (soin) — durable hors payload carte purgeable.';
|
||||
COMMENT ON COLUMN evenements_agenda.verrouille_le IS
|
||||
'Écrit à la soumission/resoumission — jamais pendant un GET.';
|
||||
COMMENT ON COLUMN evenements_agenda.id_lot IS
|
||||
'Lot collectif optionnel (unanimité congé / envoi groupé arrêt-absence).';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 4. card_instances — soft-cancel + id_lot + remonte_le
|
||||
-- ---------------------------------------------------------------------------
|
||||
ALTER TABLE card_instances
|
||||
ADD COLUMN IF NOT EXISTS id_lot UUID,
|
||||
ADD COLUMN IF NOT EXISTS annule_le TIMESTAMPTZ,
|
||||
ADD COLUMN IF NOT EXISTS annule_par UUID,
|
||||
ADD COLUMN IF NOT EXISTS remonte_le TIMESTAMPTZ;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = 'card_instances_id_lot_fkey'
|
||||
) THEN
|
||||
ALTER TABLE card_instances
|
||||
ADD CONSTRAINT card_instances_id_lot_fkey
|
||||
FOREIGN KEY (id_lot) REFERENCES agenda_lots(id) ON DELETE SET NULL;
|
||||
END IF;
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = 'card_instances_annule_par_fkey'
|
||||
) THEN
|
||||
ALTER TABLE card_instances
|
||||
ADD CONSTRAINT card_instances_annule_par_fkey
|
||||
FOREIGN KEY (annule_par) REFERENCES utilisateurs(id) ON DELETE SET NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_card_instances_id_lot
|
||||
ON card_instances (id_lot)
|
||||
WHERE id_lot IS NOT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_card_instances_remonte_le
|
||||
ON card_instances (remonte_le DESC NULLS LAST);
|
||||
|
||||
COMMENT ON COLUMN card_instances.remonte_le IS
|
||||
'Renseigné uniquement à la réanimation d''une carte sortie du fil ; tri fil = COALESCE(remonte_le, cree_le).';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 5. card_responses — revision_lot
|
||||
-- ---------------------------------------------------------------------------
|
||||
ALTER TABLE card_responses
|
||||
ADD COLUMN IF NOT EXISTS revision_lot INT NOT NULL DEFAULT 1;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint WHERE conname = 'chk_card_responses_revision_lot'
|
||||
) THEN
|
||||
ALTER TABLE card_responses
|
||||
ADD CONSTRAINT chk_card_responses_revision_lot CHECK (revision_lot >= 1);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_card_responses_card_revision
|
||||
ON card_responses (id_card, revision_lot);
|
||||
|
||||
COMMENT ON COLUMN card_responses.revision_lot IS
|
||||
'Doit matcher agenda_lots.revision courante pour compter dans l''unanimité.';
|
||||
|
||||
-- Backfill : réponses existantes = revision 1 (déjà DEFAULT)
|
||||
UPDATE card_responses SET revision_lot = 1 WHERE revision_lot IS NULL;
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 6. utilisateurs.preferences
|
||||
-- ---------------------------------------------------------------------------
|
||||
ALTER TABLE utilisateurs
|
||||
ADD COLUMN IF NOT EXISTS preferences JSONB NOT NULL DEFAULT '{}'::jsonb;
|
||||
|
||||
COMMENT ON COLUMN utilisateurs.preferences IS
|
||||
'Préférences UI (ex. jours_affiches_semaine). PATCH fusionne les clés.';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- 7. Index lecture Agenda (statut hors annule côté app ; index utile quand même)
|
||||
-- ---------------------------------------------------------------------------
|
||||
CREATE INDEX IF NOT EXISTS idx_evenements_agenda_placement_dates_actif
|
||||
ON evenements_agenda (id_placement, date_debut, date_fin)
|
||||
WHERE statut IS DISTINCT FROM 'annule';
|
||||
@@ -79,12 +79,42 @@ LEFT JOIN avenants_contrats a ON a.id_contrat = c.id
|
||||
GROUP BY c.id, c.id_dossier, c.statut
|
||||
ORDER BY c.cree_le DESC;
|
||||
|
||||
\echo '=== 9) Absences_garde (30 derniers jours) ====================='
|
||||
SELECT ag.id, ag.type, ag.id_placement, ag.date_debut, ag.date_fin, ag.statut, ag.expire_at
|
||||
\echo '=== 9) Événements agenda (30 derniers jours) ==================='
|
||||
SELECT ag.id, ag.type, ag.id_placement, ag.date_debut, ag.date_fin, ag.statut,
|
||||
ag.id_lot, ag.heure, ag.verrouille_le, ag.expire_at
|
||||
FROM evenements_agenda ag
|
||||
WHERE ag.date_debut >= (NOW()::date - INTERVAL '30 days')
|
||||
ORDER BY ag.date_debut DESC;
|
||||
|
||||
\echo '=== 9b) Agenda B0 (#214) — schéma lots / soft-cancel / prefs ==='
|
||||
SELECT COUNT(*) AS nb_lots FROM agenda_lots;
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'evenements_agenda'
|
||||
AND column_name IN ('id_lot', 'heure', 'verrouille_le', 'refuse_le', 'annule_le', 'annule_par')
|
||||
ORDER BY column_name;
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'card_instances'
|
||||
AND column_name IN ('id_lot', 'annule_le', 'annule_par', 'remonte_le')
|
||||
ORDER BY column_name;
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'card_responses' AND column_name = 'revision_lot';
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'utilisateurs' AND column_name = 'preferences';
|
||||
SELECT enumlabel
|
||||
FROM pg_enum e
|
||||
JOIN pg_type t ON t.oid = e.enumtypid
|
||||
WHERE t.typname IN (
|
||||
'statut_evenement_agenda_type',
|
||||
'agenda_lot_statut_type',
|
||||
'card_instance_statut_type',
|
||||
'card_operation_type'
|
||||
)
|
||||
ORDER BY t.typname, e.enumsortorder;
|
||||
|
||||
\echo '=== 10) Uploads & notifications récentes ======================='
|
||||
SELECT u.courriel, up.fichier_url, up.type_fichier, up.cree_le
|
||||
FROM uploads up
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 202 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 217 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
@@ -13,6 +13,7 @@ enum CarteStatut {
|
||||
switch (raw) {
|
||||
case 'refusee':
|
||||
return CarteStatut.refusee;
|
||||
case 'fermee':
|
||||
case 'traitee':
|
||||
return CarteStatut.traitee;
|
||||
case 'ouverte':
|
||||
@@ -110,6 +111,57 @@ class CarteBulle {
|
||||
String? get dateFin => payload['date_fin']?.toString();
|
||||
String? get motif => payload['motif']?.toString();
|
||||
|
||||
/// Heure de relevé (payload soins), format API `HH:mm`.
|
||||
String? get heureReleve => payload['heure_releve']?.toString();
|
||||
|
||||
/// Heure affichable `18h19` (depuis `heure_releve`).
|
||||
String? get heureReleveAffichee {
|
||||
final h = heureReleve?.trim();
|
||||
if (h == null || h.isEmpty) return null;
|
||||
final parts = h.split(':');
|
||||
if (parts.length < 2) return h;
|
||||
return '${parts[0]}h${parts[1]}';
|
||||
}
|
||||
|
||||
/// Ligne détail soin (sans date/heure) — sous la ligne agenda.
|
||||
String? get detailSoin {
|
||||
if (!isSoinEnfant) return null;
|
||||
final st = payload['sous_type']?.toString();
|
||||
if (st == 'fievre') {
|
||||
final t = payload['temperature_c'];
|
||||
final med = payload['medicament_donne']?.toString().trim();
|
||||
String? temp;
|
||||
if (t is num) {
|
||||
temp = t.toStringAsFixed(1).replaceAll('.', ',');
|
||||
} else if (t != null) {
|
||||
temp = t.toString().replaceAll('.', ',');
|
||||
}
|
||||
if (temp == null || temp.isEmpty) return motif;
|
||||
var s = '$temp °C';
|
||||
if (med != null && med.isNotEmpty) {
|
||||
s += ' (Médicament : $med)';
|
||||
}
|
||||
return s;
|
||||
}
|
||||
if (st == 'bobo') {
|
||||
final nature = payload['bobo_nature']?.toString() ?? 'bobo';
|
||||
final desc = payload['description']?.toString().trim();
|
||||
if (desc != null && desc.isNotEmpty) {
|
||||
return 'Bobo ($nature) : $desc';
|
||||
}
|
||||
return 'Bobo ($nature)';
|
||||
}
|
||||
if (st == 'medicament') {
|
||||
final nom = payload['medicament_nom']?.toString().trim();
|
||||
final ctx = payload['contexte']?.toString().trim();
|
||||
final label =
|
||||
(nom != null && nom.isNotEmpty) ? 'Médicament ($nom)' : 'Médicament';
|
||||
if (ctx != null && ctx.isNotEmpty) return '$label : $ctx';
|
||||
return label;
|
||||
}
|
||||
return motif;
|
||||
}
|
||||
|
||||
/// Motif de refus : réponse API, sinon motif payload (co-parent / reload).
|
||||
String? get motifRefus {
|
||||
final fromResponse = lastRefuseComment?.trim();
|
||||
@@ -165,7 +217,12 @@ class CarteBulle {
|
||||
case 'absence_enfant':
|
||||
case 'absence_enfant_modif':
|
||||
return 'assets/images/sac_lapin.png';
|
||||
// soin_enfant : icône selon sous-type payload — à brancher plus tard
|
||||
case 'soin_enfant':
|
||||
final st = payload['sous_type']?.toString();
|
||||
if (st == 'fievre') return 'assets/images/thermo_verre.png';
|
||||
if (st == 'bobo') return 'assets/images/pansement.png';
|
||||
if (st == 'medicament') return 'assets/images/flacon.png';
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,18 +49,14 @@ class CarteTypeUi {
|
||||
label: 'Arrêt maladie',
|
||||
motifHint: 'Précisions (optionnel)',
|
||||
),
|
||||
// Point d’extension #soins — visible dès que le back l’émet.
|
||||
'soin_enfant': CarteTypeUi(
|
||||
typeCode: 'soin_enfant',
|
||||
label: 'Soin / bobo',
|
||||
motifHint: 'Décrivez le soin ou le bobo',
|
||||
motifRequired: true,
|
||||
periodeMode: CartePeriodeMode.singleDay,
|
||||
sousTypes: [
|
||||
CarteSousTypeUi(code: 'temperature', label: 'Température'),
|
||||
CarteSousTypeUi(code: 'fievre', label: 'Fièvre'),
|
||||
CarteSousTypeUi(code: 'bobo', label: 'Bobo'),
|
||||
CarteSousTypeUi(code: 'medicament', label: 'Médicament'),
|
||||
CarteSousTypeUi(code: 'autre', label: 'Autre'),
|
||||
],
|
||||
),
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
|
||||
import 'package:p_tits_pas/screens/home/parent_screen/agenda_absences_stub.dart';
|
||||
|
||||
/// Dashboard assistante maternelle – coquille 3 colonnes quotidien (#169).
|
||||
/// Colonne gauche : sélecteur couple (#170) + feed bulles (#174).
|
||||
/// Contexte couple dans le bandeau (#211) ; colonne gauche = feed (#174).
|
||||
/// Création « Ajouter une carte » : modale générique (#175, réutilisée #176).
|
||||
class AmDashboardScreen extends StatefulWidget {
|
||||
const AmDashboardScreen({super.key});
|
||||
@@ -108,16 +108,17 @@ class _AmDashboardScreenState extends State<AmDashboardScreen> {
|
||||
userEmail: _user?.email,
|
||||
onProfileTap: () => _soon('Profil'),
|
||||
onSettingsTap: () => _soon('Paramètres'),
|
||||
// L'AM n'a pas de bouton "Recherche AM" dans le bandeau
|
||||
onSearchAmTap: null,
|
||||
leftColumn: _LeftColumn(
|
||||
contextSelector: CoupleSelectorBandeau(
|
||||
mode: CoupleBandeauMode.assistanteMaternelle,
|
||||
couples: _couples,
|
||||
selectedCoupleId: _selectedCoupleId,
|
||||
loading: _couplesLoading,
|
||||
error: _couplesError,
|
||||
errorMessage: _couplesError,
|
||||
onRetry: _loadCouples,
|
||||
onCoupleSelected: _selectCouple,
|
||||
),
|
||||
leftColumn: _LeftColumn(selectedCoupleId: _selectedCoupleId),
|
||||
centerColumn: const QuotidienColumnPlaceholder(
|
||||
title: 'Blog',
|
||||
subtitle:
|
||||
@@ -139,49 +140,17 @@ class _AmDashboardScreenState extends State<AmDashboardScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Colonne gauche : bandeau couple AM (#170) puis flux de cartes (#174 / #175).
|
||||
/// Colonne gauche : flux de cartes (#174 / #175). Couple = bandeau (#211).
|
||||
class _LeftColumn extends StatelessWidget {
|
||||
final List<CoupleGarde> couples;
|
||||
final String? selectedCoupleId;
|
||||
final bool loading;
|
||||
final String? error;
|
||||
final VoidCallback onRetry;
|
||||
final ValueChanged<CoupleGarde> onCoupleSelected;
|
||||
|
||||
const _LeftColumn({
|
||||
required this.couples,
|
||||
required this.selectedCoupleId,
|
||||
required this.loading,
|
||||
required this.error,
|
||||
required this.onRetry,
|
||||
required this.onCoupleSelected,
|
||||
});
|
||||
const _LeftColumn({required this.selectedCoupleId});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
CoupleSelectorBandeau(
|
||||
mode: CoupleBandeauMode.assistanteMaternelle,
|
||||
couples: couples,
|
||||
selectedCoupleId: selectedCoupleId,
|
||||
loading: loading,
|
||||
errorMessage: error,
|
||||
onRetry: onRetry,
|
||||
onCoupleSelected: onCoupleSelected,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
Expanded(
|
||||
child: CartesFeed(
|
||||
placementId: selectedCoupleId,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CartesFeed(placementId: selectedCoupleId),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
|
||||
import 'package:p_tits_pas/screens/home/parent_screen/agenda_absences_stub.dart';
|
||||
|
||||
/// Tableau de bord parent — coquille 3 colonnes quotidien (#166).
|
||||
/// Colonne gauche : sélecteur de couple (#167) + feed bulles (#173).
|
||||
/// Contexte couple dans le bandeau (#211) ; colonne gauche = feed (#173).
|
||||
class ParentDashboardScreen extends StatefulWidget {
|
||||
const ParentDashboardScreen({super.key});
|
||||
|
||||
@@ -108,14 +108,15 @@ class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
|
||||
onProfileTap: () => _soon('Profil'),
|
||||
onSearchAmTap: () => _soon('Recherche AM'),
|
||||
onSettingsTap: () => _soon('Paramètres'),
|
||||
leftColumn: _LeftColumn(
|
||||
contextSelector: CoupleSelectorBandeau(
|
||||
couples: _couples,
|
||||
selectedCoupleId: _selectedCoupleId,
|
||||
loading: _couplesLoading,
|
||||
error: _couplesError,
|
||||
errorMessage: _couplesError,
|
||||
onRetry: _loadCouples,
|
||||
onCoupleSelected: _selectCouple,
|
||||
),
|
||||
leftColumn: _LeftColumn(selectedCoupleId: _selectedCoupleId),
|
||||
centerColumn: const QuotidienColumnPlaceholder(
|
||||
title: 'Blog',
|
||||
subtitle:
|
||||
@@ -137,47 +138,17 @@ class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Colonne gauche : bandeau couple (#167) puis flux de cartes (#173 / #175).
|
||||
/// Colonne gauche : flux de cartes (#173 / #175). Couple = bandeau (#211).
|
||||
class _LeftColumn extends StatelessWidget {
|
||||
final List<CoupleGarde> couples;
|
||||
final String? selectedCoupleId;
|
||||
final bool loading;
|
||||
final String? error;
|
||||
final VoidCallback onRetry;
|
||||
final ValueChanged<CoupleGarde> onCoupleSelected;
|
||||
|
||||
const _LeftColumn({
|
||||
required this.couples,
|
||||
required this.selectedCoupleId,
|
||||
required this.loading,
|
||||
required this.error,
|
||||
required this.onRetry,
|
||||
required this.onCoupleSelected,
|
||||
});
|
||||
const _LeftColumn({required this.selectedCoupleId});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
CoupleSelectorBandeau(
|
||||
couples: couples,
|
||||
selectedCoupleId: selectedCoupleId,
|
||||
loading: loading,
|
||||
errorMessage: error,
|
||||
onRetry: onRetry,
|
||||
onCoupleSelected: onCoupleSelected,
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
Expanded(
|
||||
child: CartesFeed(
|
||||
placementId: selectedCoupleId,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: CartesFeed(placementId: selectedCoupleId),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ class CardsService {
|
||||
required String dateDebut,
|
||||
required String dateFin,
|
||||
String? motif,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
final response = await http.post(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.cards}'),
|
||||
@@ -101,6 +102,7 @@ class CardsService {
|
||||
'date_debut': dateDebut,
|
||||
'date_fin': dateFin,
|
||||
if (motif != null && motif.trim().isNotEmpty) 'motif': motif.trim(),
|
||||
if (payload != null) 'payload': payload,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -114,6 +116,49 @@ class CardsService {
|
||||
return CarteBulle.fromJson(Map<String, dynamic>.from(decoded as Map));
|
||||
}
|
||||
|
||||
/// Modifier une carte (corriger un soin, dates en attente...).
|
||||
static Future<CarteBulle> maj({
|
||||
required String cardId,
|
||||
String? dateDebut,
|
||||
String? dateFin,
|
||||
String? motif,
|
||||
Map<String, dynamic>? payload,
|
||||
}) async {
|
||||
final response = await http.patch(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.cards}/$cardId'),
|
||||
headers: await _headers(),
|
||||
body: jsonEncode({
|
||||
if (dateDebut != null) 'date_debut': dateDebut,
|
||||
if (dateFin != null) 'date_fin': dateFin,
|
||||
if (motif != null && motif.trim().isNotEmpty) 'motif': motif.trim(),
|
||||
if (payload != null) 'payload': payload,
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception(
|
||||
_extractError(response.body, 'Erreur lors de la mise à jour'),
|
||||
);
|
||||
}
|
||||
|
||||
final decoded = jsonDecode(response.body);
|
||||
return CarteBulle.fromJson(Map<String, dynamic>.from(decoded as Map));
|
||||
}
|
||||
|
||||
/// Supprimer une bulle (AM 24h ou avant traitement).
|
||||
static Future<void> supprimer(String cardId) async {
|
||||
final response = await http.delete(
|
||||
Uri.parse('${ApiConfig.baseUrl}${ApiConfig.cards}/$cardId'),
|
||||
headers: await _headers(),
|
||||
);
|
||||
|
||||
if (response.statusCode != 204 && response.statusCode != 200) {
|
||||
throw Exception(
|
||||
_extractError(response.body, 'Erreur lors de la suppression'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Répondre : accept | refuse | ack.
|
||||
static Future<CarteBulle> repondre({
|
||||
required String cardId,
|
||||
|
||||
@@ -10,19 +10,28 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
|
||||
Future<CarteBulle?> showAjouterCarteModal(
|
||||
BuildContext context, {
|
||||
required String placementId,
|
||||
CarteBulle? carteToEdit,
|
||||
}) {
|
||||
return showDialog<CarteBulle>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (ctx) => AjouterCarteModal(placementId: placementId),
|
||||
builder: (ctx) => AjouterCarteModal(
|
||||
placementId: placementId,
|
||||
carteToEdit: carteToEdit,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Modale générique : types API + catalogue UI, période (pas de motif V1).
|
||||
/// Modale générique : types API + catalogue UI, période, soins
|
||||
class AjouterCarteModal extends StatefulWidget {
|
||||
final String placementId;
|
||||
final CarteBulle? carteToEdit;
|
||||
|
||||
const AjouterCarteModal({super.key, required this.placementId});
|
||||
const AjouterCarteModal({
|
||||
super.key,
|
||||
required this.placementId,
|
||||
this.carteToEdit,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AjouterCarteModal> createState() => _AjouterCarteModalState();
|
||||
@@ -38,6 +47,17 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
bool _submitting = false;
|
||||
String? _error;
|
||||
|
||||
TimeOfDay _heureReleve = TimeOfDay.now();
|
||||
|
||||
// --- Controllers Soins ---
|
||||
final _motifController = TextEditingController();
|
||||
final _temperatureController = TextEditingController();
|
||||
final _medicamentDonneController = TextEditingController();
|
||||
String? _boboNature;
|
||||
final _boboDescriptionController = TextEditingController();
|
||||
final _medicamentNomController = TextEditingController();
|
||||
final _medicamentContexteController = TextEditingController();
|
||||
|
||||
CarteTypeUi get _ui =>
|
||||
_selected?.ui ??
|
||||
CarteTypeUi.resolve(typeCode: _selected?.code ?? 'inconnu');
|
||||
@@ -51,6 +71,67 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
_loadTypes();
|
||||
}
|
||||
|
||||
void _prefillIfEdit(List<CarteTypeEmissible> types) {
|
||||
if (widget.carteToEdit == null) return;
|
||||
final card = widget.carteToEdit!;
|
||||
final type = types.where((t) => t.code == card.typeCode).firstOrNull;
|
||||
if (type != null) {
|
||||
_selected = type;
|
||||
}
|
||||
|
||||
if (card.dateDebut != null) {
|
||||
_dateDebut = DateTime.tryParse(card.dateDebut!) ?? _dateDebut;
|
||||
}
|
||||
if (card.dateFin != null) {
|
||||
_dateFin = DateTime.tryParse(card.dateFin!) ?? _dateFin;
|
||||
}
|
||||
|
||||
_motifController.text = card.motif ?? '';
|
||||
|
||||
if (card.typeCode == 'soin_enfant') {
|
||||
final p = card.payload;
|
||||
_sousTypeCode = p['sous_type']?.toString();
|
||||
final h = p['heure_releve']?.toString();
|
||||
if (h != null && h.contains(':')) {
|
||||
final parts = h.split(':');
|
||||
_heureReleve = TimeOfDay(
|
||||
hour: int.tryParse(parts[0]) ?? 0,
|
||||
minute: int.tryParse(parts[1]) ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
if (_sousTypeCode == 'fievre') {
|
||||
_temperatureController.text = p['temperature_c']?.toString() ?? '';
|
||||
_medicamentDonneController.text = p['medicament_donne']?.toString() ?? '';
|
||||
} else if (_sousTypeCode == 'bobo') {
|
||||
final nature = p['bobo_nature']?.toString() ?? '';
|
||||
final naturesValides = ['Chute', 'Coup', 'Égratignure', 'Piqûre', 'Brûlure', 'Autre'];
|
||||
if (naturesValides.map((n) => n.toLowerCase().replaceAll('é', 'e').replaceAll('û', 'u')).contains(nature.toLowerCase())) {
|
||||
_boboNature = naturesValides.firstWhere(
|
||||
(n) => n.toLowerCase().replaceAll('é', 'e').replaceAll('û', 'u') == nature.toLowerCase().replaceAll('é', 'e').replaceAll('û', 'u'),
|
||||
orElse: () => 'Autre'
|
||||
);
|
||||
} else {
|
||||
_boboNature = 'Autre';
|
||||
}
|
||||
_boboDescriptionController.text = p['description']?.toString() ?? '';
|
||||
} else if (_sousTypeCode == 'medicament') {
|
||||
_medicamentNomController.text = p['medicament_nom']?.toString() ?? '';
|
||||
_medicamentContexteController.text = p['contexte']?.toString() ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_temperatureController.dispose();
|
||||
_medicamentDonneController.dispose();
|
||||
_boboDescriptionController.dispose();
|
||||
_medicamentNomController.dispose();
|
||||
_medicamentContexteController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _loadTypes() async {
|
||||
setState(() {
|
||||
_loadingTypes = true;
|
||||
@@ -66,6 +147,8 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
_loadingTypes = false;
|
||||
if (types.isEmpty) {
|
||||
_error = 'Aucun type de carte disponible pour votre rôle.';
|
||||
} else {
|
||||
_prefillIfEdit(types);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -90,6 +173,22 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
return '$day/$m/${d.year}';
|
||||
}
|
||||
|
||||
Future<void> _pickTime() async {
|
||||
final picked = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: _heureReleve,
|
||||
builder: (context, child) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
|
||||
child: child ?? const SizedBox(),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (picked != null && mounted) {
|
||||
setState(() => _heureReleve = picked);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pickSingleDay() async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
@@ -180,11 +279,63 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// V1 : pas de texte libre ; seul un sous-type catalogue peut alimenter motif.
|
||||
String? _motifOptionnel() => _sousTypeLabel();
|
||||
/// V1 : pas de texte libre pour le motif si la logique change.
|
||||
/// (On retire `motifOptionnel` car le backend va dériver du payload).
|
||||
Map<String, dynamic>? _buildPayload() {
|
||||
if (_selected?.code != 'soin_enfant') {
|
||||
return null;
|
||||
}
|
||||
|
||||
final base = <String, dynamic>{
|
||||
'sous_type': _sousTypeCode,
|
||||
'heure_releve':
|
||||
'${_heureReleve.hour.toString().padLeft(2, '0')}:${_heureReleve.minute.toString().padLeft(2, '0')}',
|
||||
};
|
||||
|
||||
if (_sousTypeCode == 'fievre') {
|
||||
final t = _temperatureController.text.trim().replaceAll(',', '.');
|
||||
if (t.isNotEmpty) {
|
||||
base['temperature_c'] = double.tryParse(t);
|
||||
}
|
||||
base['medicament_donne'] = _medicamentDonneController.text.trim();
|
||||
} else if (_sousTypeCode == 'bobo') {
|
||||
// Normaliser l'enregistrement pour le back :
|
||||
final nature = _boboNature?.toLowerCase().replaceAll('é', 'e').replaceAll('û', 'u') ?? 'autre';
|
||||
base['bobo_nature'] = nature;
|
||||
base['description'] = _boboDescriptionController.text.trim();
|
||||
} else if (_sousTypeCode == 'medicament') {
|
||||
base['medicament_nom'] = _medicamentNomController.text.trim();
|
||||
base['contexte'] = _medicamentContexteController.text.trim();
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
Future<void> _submit() async {
|
||||
if (_selected == null) return;
|
||||
|
||||
// Validations locales spécifiques soins
|
||||
if (_selected?.code == 'soin_enfant') {
|
||||
if (_sousTypeCode == null) {
|
||||
setState(() => _error = 'Veuillez choisir un sous-type.');
|
||||
return;
|
||||
}
|
||||
if (_sousTypeCode == 'fievre') {
|
||||
final t = _temperatureController.text.trim().replaceAll(',', '.');
|
||||
if (t.isNotEmpty && double.tryParse(t) == null) {
|
||||
setState(() => _error = 'La température est invalide.');
|
||||
return;
|
||||
}
|
||||
} else if (_sousTypeCode == 'bobo' && _boboNature == null) {
|
||||
setState(() => _error = 'Veuillez indiquer la nature du bobo.');
|
||||
return;
|
||||
} else if (_sousTypeCode == 'medicament' &&
|
||||
_medicamentNomController.text.trim().isEmpty) {
|
||||
setState(() => _error = 'Le nom du médicament est obligatoire.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_dateFin.isBefore(_dateDebut)) {
|
||||
setState(() => _error = 'La date de fin doit être après la date de début.');
|
||||
return;
|
||||
@@ -195,17 +346,36 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
_error = null;
|
||||
});
|
||||
try {
|
||||
final created = await CardsService.creer(
|
||||
typeCode: _selected!.code,
|
||||
idPlacement: widget.placementId,
|
||||
dateDebut: _fmtIso(_dateDebut),
|
||||
dateFin: _fmtIso(
|
||||
_ui.periodeMode == CartePeriodeMode.singleDay
|
||||
? _dateDebut
|
||||
: _dateFin,
|
||||
),
|
||||
motif: _motifOptionnel(),
|
||||
);
|
||||
final payload = _buildPayload();
|
||||
|
||||
final dynamic created;
|
||||
if (widget.carteToEdit != null) {
|
||||
created = await CardsService.maj(
|
||||
cardId: widget.carteToEdit!.id,
|
||||
dateDebut: _fmtIso(_dateDebut),
|
||||
dateFin: _fmtIso(
|
||||
_ui.periodeMode == CartePeriodeMode.singleDay
|
||||
? _dateDebut
|
||||
: _dateFin,
|
||||
),
|
||||
motif: _selected?.code == 'soin_enfant' ? null : _motifController.text.trim(),
|
||||
payload: payload,
|
||||
);
|
||||
} else {
|
||||
created = await CardsService.creer(
|
||||
typeCode: _selected!.code,
|
||||
idPlacement: widget.placementId,
|
||||
dateDebut: _fmtIso(_dateDebut),
|
||||
dateFin: _fmtIso(
|
||||
_ui.periodeMode == CartePeriodeMode.singleDay
|
||||
? _dateDebut
|
||||
: _dateFin,
|
||||
),
|
||||
motif: _selected?.code == 'soin_enfant' ? null : _motifController.text.trim(),
|
||||
payload: payload,
|
||||
);
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
Navigator.of(context).pop(created);
|
||||
} catch (e) {
|
||||
@@ -255,10 +425,27 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
_buildTypeSelector(),
|
||||
const SizedBox(height: 16),
|
||||
if (_ui.periodeMode == CartePeriodeMode.singleDay)
|
||||
_DateField(
|
||||
label: 'Date',
|
||||
value: _fmtUi(_dateDebut),
|
||||
onTap: _submitting ? null : _pickSingleDay,
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _DateField(
|
||||
label: 'Date',
|
||||
value: _fmtUi(_dateDebut),
|
||||
onTap: _submitting ? null : _pickSingleDay,
|
||||
),
|
||||
),
|
||||
if (_selected?.code == 'soin_enfant') ...[
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _DateField(
|
||||
label: 'Heure',
|
||||
value: _heureReleve.format(context),
|
||||
icon: Icons.access_time,
|
||||
onTap: _submitting ? null : _pickTime,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
)
|
||||
else
|
||||
_DateField(
|
||||
@@ -297,6 +484,26 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
],
|
||||
),
|
||||
],
|
||||
if (_selected?.code == 'soin_enfant') _buildSoinForm(),
|
||||
if (_selected?.code != 'soin_enfant') ...[
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _motifController,
|
||||
enabled: !_submitting,
|
||||
maxLines: 3,
|
||||
decoration: InputDecoration(
|
||||
labelText: _ui.motifRequired ? 'Motif *' : 'Motif',
|
||||
hintText: _ui.motifHint,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
validator: (v) {
|
||||
if (!_ui.motifRequired) return null;
|
||||
final text = v?.trim() ?? '';
|
||||
if (text.isEmpty) return 'Motif obligatoire';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -374,17 +581,106 @@ class _AjouterCarteModalState extends State<AjouterCarteModal> {
|
||||
},
|
||||
);
|
||||
}
|
||||
Widget _buildSoinForm() {
|
||||
if (_sousTypeCode == null) return const SizedBox.shrink();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
if (_sousTypeCode == 'fievre') ...[
|
||||
TextFormField(
|
||||
controller: _temperatureController,
|
||||
enabled: !_submitting,
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Température (°C) *',
|
||||
hintText: 'ex: 38.5',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _medicamentDonneController,
|
||||
enabled: !_submitting,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Médicament donné (optionnel)',
|
||||
hintText: 'ex: Doliprane 2.4kg',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
] else if (_sousTypeCode == 'bobo') ...[
|
||||
DropdownButtonFormField<String>(
|
||||
value: _boboNature,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nature du bobo *',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'Chute', child: Text('Chute')),
|
||||
DropdownMenuItem(value: 'Égratignure', child: Text('Égratignure')),
|
||||
DropdownMenuItem(value: 'Coup', child: Text('Coup')),
|
||||
DropdownMenuItem(value: 'Piqûre', child: Text('Piqûre')),
|
||||
DropdownMenuItem(value: 'Brûlure', child: Text('Brûlure')),
|
||||
DropdownMenuItem(value: 'Autre', child: Text('Autre')),
|
||||
],
|
||||
onChanged: _submitting
|
||||
? null
|
||||
: (val) {
|
||||
setState(() {
|
||||
_boboNature = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _boboDescriptionController,
|
||||
enabled: !_submitting,
|
||||
maxLines: 2,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Description / Zone touchée *',
|
||||
hintText: 'ex: Égratignure sur le genou droit',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
] else if (_sousTypeCode == 'medicament') ...[
|
||||
TextFormField(
|
||||
controller: _medicamentNomController,
|
||||
enabled: !_submitting,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Nom du médicament *',
|
||||
hintText: 'ex: Ventoline',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _medicamentContexteController,
|
||||
enabled: !_submitting,
|
||||
maxLines: 2,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Contexte / Posologie (optionnel)',
|
||||
hintText: 'ex: 2 bouffées suite à une quinte de toux',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DateField extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
final VoidCallback? onTap;
|
||||
final IconData icon;
|
||||
|
||||
const _DateField({
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.onTap,
|
||||
this.icon = Icons.calendar_today_outlined,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -396,7 +692,7 @@ class _DateField extends StatelessWidget {
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: const Icon(Icons.calendar_today_outlined, size: 18),
|
||||
suffixIcon: Icon(icon, size: 18),
|
||||
),
|
||||
child: Text(
|
||||
value,
|
||||
|
||||
@@ -442,17 +442,7 @@ class _CartesFeedState extends State<CartesFeed> {
|
||||
);
|
||||
}
|
||||
if (_items.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
'Aucune bulle pour le moment.\nLa file d’attention est vide — c’est normal.',
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 13,
|
||||
color: QuotidienTheme.muted,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
);
|
||||
return const _CartesEmptyState();
|
||||
}
|
||||
|
||||
return NotificationListener<ScrollMetricsNotification>(
|
||||
@@ -611,8 +601,18 @@ class _BulleTile extends StatelessWidget {
|
||||
return '$jj ${_mois[dt.month - 1]} ${dt.year}';
|
||||
}
|
||||
|
||||
/// Une ligne type maquette : « Du 04 au 06 novembre 2026 ».
|
||||
String _fmtPeriodeUneLigne() {
|
||||
// Soin : « Le 08 octobre 2026 à 18h19 » (détail en italique sous la ligne).
|
||||
if (card.isSoinEnfant) {
|
||||
final jour = card.dateDebut != null
|
||||
? 'Le ${_fmtLong(card.dateDebut)}'
|
||||
: '';
|
||||
final h = card.heureReleveAffichee;
|
||||
if (jour.isEmpty) return h != null ? 'À $h' : '';
|
||||
if (h == null || h.isEmpty) return jour;
|
||||
return '$jour à $h';
|
||||
}
|
||||
|
||||
final d1 = DateTime.tryParse(card.dateDebut ?? '');
|
||||
final d2 = DateTime.tryParse(card.dateFin ?? '');
|
||||
if (d1 == null && d2 == null) return '';
|
||||
@@ -716,8 +716,6 @@ class _BulleTile extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
periode,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -729,14 +727,27 @@ class _BulleTile extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
],
|
||||
if (card.isSoinEnfant &&
|
||||
(card.detailSoin?.trim().isNotEmpty ?? false)) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
card.detailSoin!,
|
||||
softWrap: true,
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 13,
|
||||
fontStyle: FontStyle.italic,
|
||||
height: 1.35,
|
||||
color: encre.ink,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (card.isCongeAm &&
|
||||
card.statut == CarteStatut.refusee &&
|
||||
card.motifRefus != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Motif : ${card.motifRefus}',
|
||||
maxLines: 4,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: true,
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 13,
|
||||
fontStyle: FontStyle.italic,
|
||||
@@ -850,6 +861,11 @@ class _BulleTile extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildGeneric(BuildContext context) {
|
||||
final encre = _Encre.pour(card.colorFamily);
|
||||
final isEdited = card.modifieLe != null && (card.creeLe == null || card.modifieLe!.isAfter(card.creeLe!));
|
||||
final createdAt = card.creeLe ?? DateTime.now();
|
||||
final canEdit = card.isCreator && DateTime.now().difference(createdAt).inHours < 24;
|
||||
|
||||
final memeJour = card.dateDebut != null &&
|
||||
card.dateFin != null &&
|
||||
card.dateDebut == card.dateFin;
|
||||
@@ -870,23 +886,41 @@ class _BulleTile extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
card.titreAffiche,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
card.titreAffiche,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isEdited)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: Text(
|
||||
'(Corrigée)',
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 11,
|
||||
fontStyle: FontStyle.italic,
|
||||
color: QuotidienTheme.ink.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (card.dateDebut != null || card.dateFin != null) ...[
|
||||
if (card.dateDebut != null || card.dateFin != null || card.isSoinEnfant) ...[
|
||||
const SizedBox(height: 10),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: memeJour
|
||||
child: (memeJour || card.isSoinEnfant)
|
||||
? Text(
|
||||
'Le ${_fmtLong(card.dateDebut)}',
|
||||
_fmtPeriodeUneLigne(),
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -960,6 +994,72 @@ class _BulleTile extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
// Edit / Delete buttons for creator if within 24h
|
||||
if (canEdit && !busy) ...[
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.edit, size: 16),
|
||||
label: const Text('Corriger'),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: encre.link,
|
||||
textStyle: GoogleFonts.merriweather(fontSize: 12),
|
||||
),
|
||||
onPressed: () {
|
||||
showAjouterCarteModal(
|
||||
context,
|
||||
placementId: card.idPlacement,
|
||||
carteToEdit: card,
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.delete_outline, size: 16),
|
||||
label: const Text('Supprimer'),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Colors.red[700],
|
||||
textStyle: GoogleFonts.merriweather(fontSize: 12),
|
||||
),
|
||||
onPressed: () async {
|
||||
final confirm = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Supprimer cette carte ?', style: GoogleFonts.merienda()),
|
||||
content: const Text('Cette action est définitive.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: FilledButton.styleFrom(backgroundColor: Colors.red[700]),
|
||||
child: const Text('Supprimer'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirm == true && context.mounted) {
|
||||
try {
|
||||
await CardsService.supprimer(card.id);
|
||||
// The stream will handle the removal locally via card.deleted
|
||||
} catch (e) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Erreur: ${e.toString().replaceFirst('Exception: ', '')}')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
if (card.peutRepondre) ...[
|
||||
const SizedBox(height: 14),
|
||||
if (busy)
|
||||
@@ -1081,6 +1181,65 @@ class _RefuseDialogState extends State<_RefuseDialog> {
|
||||
}
|
||||
}
|
||||
|
||||
/// État vide de la file d'attention — ours endormi (#212).
|
||||
class _CartesEmptyState extends StatelessWidget {
|
||||
const _CartesEmptyState();
|
||||
|
||||
static const _asset = 'assets/images/ours_endormi.png';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final maxW = constraints.maxWidth;
|
||||
// ~160–200 px, réduit si colonne étroite.
|
||||
final imgW =
|
||||
maxW.isFinite ? maxW.clamp(100.0, 200.0) : 180.0;
|
||||
return Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: maxW),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset(
|
||||
_asset,
|
||||
width: imgW,
|
||||
fit: BoxFit.contain,
|
||||
filterQuality: FilterQuality.high,
|
||||
semanticLabel: 'Ours endormi',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'File d’attention au repos.',
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Pas de bulle en attente — on respire.',
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 13,
|
||||
color: QuotidienTheme.muted,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// CTA « Ajouter une carte » — pilule aquarelle en bas du feed (#175).
|
||||
class _AjouterCarteCta extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
|
||||
@@ -8,12 +8,12 @@ import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
|
||||
|
||||
/// Rôle qui consulte le bandeau : côté parent (enfant | nounou) ou côté AM
|
||||
/// (enfant | parent(s)). Le composant est le même, seule la lecture change.
|
||||
/// Ticket #167 (parent) ; #170 réutilise en mode AM.
|
||||
/// Ticket #167 (parent) ; #170 (AM) ; #211 (compact dans le bandeau haut).
|
||||
enum CoupleBandeauMode { parent, assistanteMaternelle }
|
||||
|
||||
/// Bandeau « couple de garde » en haut de la colonne gauche du TdB.
|
||||
/// Sélecteur « couple de garde » compact dans le bandeau haut (#211).
|
||||
///
|
||||
/// - Plusieurs couples → contrôle unique avec chevron (dropdown de bascule).
|
||||
/// - Plusieurs couples → contrôle unique avec chevron (menu de bascule).
|
||||
/// - Un seul couple → affichage informatif (pas de chevron, pas de menu).
|
||||
/// - Aucun couple → état vide discret.
|
||||
class CoupleSelectorBandeau extends StatelessWidget {
|
||||
@@ -25,6 +25,9 @@ class CoupleSelectorBandeau extends StatelessWidget {
|
||||
final String? errorMessage;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
static const double height = 40;
|
||||
static const double avatarSize = 28;
|
||||
|
||||
const CoupleSelectorBandeau({
|
||||
super.key,
|
||||
this.mode = CoupleBandeauMode.parent,
|
||||
@@ -38,7 +41,7 @@ class CoupleSelectorBandeau extends StatelessWidget {
|
||||
|
||||
CoupleGarde? get _selected {
|
||||
if (couples.isEmpty) return null;
|
||||
if (selectedCoupleId != null) {
|
||||
if (selectedCoupleId != null) {
|
||||
for (final c in couples) {
|
||||
if (c.id == selectedCoupleId) return c;
|
||||
}
|
||||
@@ -79,11 +82,12 @@ class CoupleSelectorBandeau extends StatelessWidget {
|
||||
),
|
||||
child: PopupMenuButton<String>(
|
||||
tooltip: 'Changer de garde',
|
||||
// L'offset doit être suffisant pour descendre sous la carte (qui fait 90px).
|
||||
offset: const Offset(0, 95),
|
||||
color: Colors.transparent, // Le fond devient invisible
|
||||
elevation: 0, // Pas d'ombre carrée
|
||||
constraints: BoxConstraints.tightFor(width: constraints.maxWidth),
|
||||
offset: const Offset(0, height + 6),
|
||||
color: Colors.transparent,
|
||||
elevation: 0,
|
||||
constraints: BoxConstraints.tightFor(
|
||||
width: constraints.maxWidth.clamp(180, 320),
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
onSelected: (id) {
|
||||
final chosen = couples.firstWhere((c) => c.id == id);
|
||||
@@ -95,15 +99,14 @@ class CoupleSelectorBandeau extends StatelessWidget {
|
||||
PopupMenuItem<String>(
|
||||
value: c.id,
|
||||
padding: EdgeInsets.zero,
|
||||
height: 100, // Hauteur de la carte (90) + un peu de marge (10)
|
||||
height: height + 8,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: _CoupleCard(
|
||||
mode: mode,
|
||||
couple: c,
|
||||
showChevron: false,
|
||||
selected: false,
|
||||
isMenuItem: true,
|
||||
colorIndex: couples.indexOf(c),
|
||||
),
|
||||
),
|
||||
@@ -116,13 +119,12 @@ class CoupleSelectorBandeau extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// Carte principale : enfant à gauche, séparateur, AM/parents à droite.
|
||||
/// Carte compacte : enfant | AM/parents (+ chevron si multi).
|
||||
class _CoupleCard extends StatelessWidget {
|
||||
final CoupleBandeauMode mode;
|
||||
final CoupleGarde couple;
|
||||
final bool showChevron;
|
||||
final bool selected;
|
||||
final bool isMenuItem;
|
||||
final int colorIndex;
|
||||
|
||||
const _CoupleCard({
|
||||
@@ -130,11 +132,9 @@ class _CoupleCard extends StatelessWidget {
|
||||
required this.couple,
|
||||
required this.showChevron,
|
||||
this.selected = true,
|
||||
this.isMenuItem = false,
|
||||
required this.colorIndex,
|
||||
});
|
||||
|
||||
/// Libellé parents côté AM : « Sophie » ou « Thomas et Claire ».
|
||||
static String _parentsLabel(List<CoupleMembre> parents) {
|
||||
if (parents.isEmpty) return 'Parents';
|
||||
String prenomOf(CoupleMembre p) {
|
||||
@@ -142,20 +142,18 @@ class _CoupleCard extends StatelessWidget {
|
||||
if (prenom.isNotEmpty) return prenom;
|
||||
return p.displayName(fallback: 'Parent');
|
||||
}
|
||||
|
||||
if (parents.length == 1) return prenomOf(parents.first);
|
||||
return '${prenomOf(parents[0])} et ${prenomOf(parents[1])}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Parent mode: enfant | AM (photo + prénom)
|
||||
// AM mode: enfant | parent(s) — texte seul, pas de vignette parent
|
||||
final isParentMode = mode == CoupleBandeauMode.parent;
|
||||
|
||||
Widget amOrParentsWidget;
|
||||
|
||||
final Widget right;
|
||||
if (isParentMode) {
|
||||
amOrParentsWidget = _MembreTile(
|
||||
right = _MembreTile(
|
||||
photoUrl: couple.am?.photoUrl,
|
||||
name: (couple.am?.prenom != null && couple.am!.prenom!.isNotEmpty)
|
||||
? couple.am!.prenom!
|
||||
@@ -163,28 +161,28 @@ class _CoupleCard extends StatelessWidget {
|
||||
fallbackIcon: Icons.volunteer_activism,
|
||||
);
|
||||
} else {
|
||||
amOrParentsWidget = Text(
|
||||
right = Text(
|
||||
_parentsLabel(couple.parents),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Carte.bandeau(
|
||||
assetPath: QuotidienTheme
|
||||
.bandeauColors[colorIndex % QuotidienTheme.bandeauColors.length],
|
||||
height: 90,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 12),
|
||||
return Opacity(
|
||||
opacity: selected ? 1 : 0.92,
|
||||
child: Carte.bandeau(
|
||||
assetPath: QuotidienTheme
|
||||
.bandeauColors[colorIndex % QuotidienTheme.bandeauColors.length],
|
||||
height: CoupleSelectorBandeau.height,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _MembreTile(
|
||||
photoUrl: couple.enfant.photoUrl,
|
||||
name: (couple.enfant.prenom != null &&
|
||||
@@ -194,39 +192,34 @@ class _CoupleCard extends StatelessWidget {
|
||||
fallbackIcon: Icons.child_care,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 8,
|
||||
height: 44,
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(QuotidienTheme.pencilLineVerticalAsset),
|
||||
fit: BoxFit.contain,
|
||||
Container(
|
||||
width: 5,
|
||||
height: 22,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(QuotidienTheme.pencilLineVerticalAsset),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: amOrParentsWidget,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 28,
|
||||
child: showChevron
|
||||
? const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: QuotidienTheme.ink,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
Expanded(child: right),
|
||||
if (showChevron)
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
size: 18,
|
||||
color: QuotidienTheme.ink,
|
||||
)
|
||||
else
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Photo ronde + nom (une moitié du couple).
|
||||
/// Photo ronde + prénom (une moitié du couple).
|
||||
class _MembreTile extends StatelessWidget {
|
||||
final String? photoUrl;
|
||||
final String name;
|
||||
@@ -242,16 +235,20 @@ class _MembreTile extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
_Avatar(photoUrl: photoUrl, fallbackIcon: fallbackIcon, size: 64),
|
||||
const SizedBox(width: 12),
|
||||
_Avatar(
|
||||
photoUrl: photoUrl,
|
||||
fallbackIcon: fallbackIcon,
|
||||
size: CoupleSelectorBandeau.avatarSize,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
),
|
||||
@@ -279,7 +276,7 @@ class _Avatar extends StatelessWidget {
|
||||
width: size,
|
||||
height: size,
|
||||
color: QuotidienTheme.lavender.withValues(alpha: 0.35),
|
||||
child: Icon(fallbackIcon, size: size * 0.5, color: QuotidienTheme.ink),
|
||||
child: Icon(fallbackIcon, size: size * 0.55, color: QuotidienTheme.ink),
|
||||
);
|
||||
return ClipOval(
|
||||
child: SizedBox(
|
||||
@@ -311,11 +308,11 @@ class _CoupleBandeauSkeleton extends StatelessWidget {
|
||||
),
|
||||
child: Carte.bandeau(
|
||||
assetPath: QuotidienTheme.bandeauLime,
|
||||
height: 90,
|
||||
height: CoupleSelectorBandeau.height,
|
||||
child: const Center(
|
||||
child: SizedBox(
|
||||
width: 26,
|
||||
height: 26,
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
),
|
||||
@@ -331,17 +328,19 @@ class _CoupleBandeauEmpty extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Carte.bandeau(
|
||||
assetPath: QuotidienTheme.bandeauLime,
|
||||
height: 90,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
height: CoupleSelectorBandeau.height,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, color: QuotidienTheme.muted),
|
||||
const SizedBox(width: 12),
|
||||
const Icon(Icons.info_outline, size: 18, color: QuotidienTheme.muted),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Aucune garde active pour le moment.',
|
||||
'Aucune garde active',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 14,
|
||||
fontSize: 12,
|
||||
color: QuotidienTheme.muted,
|
||||
),
|
||||
),
|
||||
@@ -367,25 +366,30 @@ class _CoupleBandeauError extends StatelessWidget {
|
||||
),
|
||||
child: Carte.bandeau(
|
||||
assetPath: QuotidienTheme.bandeauLime,
|
||||
height: 90,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
height: CoupleSelectorBandeau.height,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.error_outline, color: QuotidienTheme.ink),
|
||||
const SizedBox(width: 12),
|
||||
const Icon(Icons.error_outline, size: 18, color: QuotidienTheme.ink),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merriweather(
|
||||
fontSize: 13,
|
||||
fontSize: 11,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (onRetry != null)
|
||||
TextButton(
|
||||
IconButton(
|
||||
onPressed: onRetry,
|
||||
child: const Text('Réessayer'),
|
||||
icon: const Icon(Icons.refresh, size: 18),
|
||||
tooltip: 'Réessayer',
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(minWidth: 28, minHeight: 28),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -5,25 +5,31 @@ import 'package:p_tits_pas/services/auth_service.dart';
|
||||
import 'package:p_tits_pas/widgets/image_button.dart';
|
||||
import 'package:p_tits_pas/widgets/quotidien/quotidien_theme.dart';
|
||||
|
||||
/// Bandeau quotidien pastel : logo · pastilles Cahier de liaison / Agenda /
|
||||
/// Contrat · menu user.
|
||||
/// Réutilisable parent (#166) et AM (#169).
|
||||
/// Bandeau quotidien pastel : logo · [contexte couple] · pastilles · menu user.
|
||||
/// Réutilisable parent (#166) et AM (#169) ; couple compact (#211).
|
||||
class QuotidienBandeau extends StatelessWidget {
|
||||
final QuotidienNavSection selectedSection;
|
||||
final ValueChanged<QuotidienNavSection> onSectionSelected;
|
||||
final String userDisplayName;
|
||||
final String? userEmail;
|
||||
|
||||
/// Sélecteur de couple compact, juste après le logo (~280 px).
|
||||
final Widget? contextSelector;
|
||||
|
||||
final VoidCallback? onProfileTap;
|
||||
final VoidCallback? onSearchAmTap;
|
||||
final VoidCallback? onSettingsTap;
|
||||
final VoidCallback? onLogout;
|
||||
|
||||
static const double contextSelectorMaxWidth = 280;
|
||||
|
||||
const QuotidienBandeau({
|
||||
super.key,
|
||||
required this.selectedSection,
|
||||
required this.onSectionSelected,
|
||||
required this.userDisplayName,
|
||||
this.userEmail,
|
||||
this.contextSelector,
|
||||
this.onProfileTap,
|
||||
this.onSearchAmTap,
|
||||
this.onSettingsTap,
|
||||
@@ -32,28 +38,61 @@ class QuotidienBandeau extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 3 zones : gauche (logo + couple vers le centre) · pastilles · menu.
|
||||
// Les Expanded gauche/droite équilibrent le centrage des pastilles.
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
QuotidienTheme.logoAsset,
|
||||
height: 44,
|
||||
fit: BoxFit.contain,
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
QuotidienTheme.logoAsset,
|
||||
height: 44,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
if (contextSelector != null) ...[
|
||||
const SizedBox(width: 16),
|
||||
Flexible(
|
||||
child: Align(
|
||||
// Pousse le couple vers le centre du bandeau.
|
||||
alignment: Alignment.centerRight,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: contextSelectorMaxWidth,
|
||||
),
|
||||
child: contextSelector!,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_NavPills(
|
||||
selected: selectedSection,
|
||||
onSelected: onSectionSelected,
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: Center(
|
||||
child: _NavPills(
|
||||
selected: selectedSection,
|
||||
onSelected: onSectionSelected,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_UserMenu(
|
||||
displayName: userDisplayName,
|
||||
email: userEmail,
|
||||
onProfileTap: onProfileTap,
|
||||
onSearchAmTap: onSearchAmTap,
|
||||
onSettingsTap: onSettingsTap,
|
||||
onLogout: onLogout,
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: _UserMenu(
|
||||
displayName: userDisplayName,
|
||||
email: userEmail,
|
||||
onProfileTap: onProfileTap,
|
||||
onSearchAmTap: onSearchAmTap,
|
||||
onSettingsTap: onSettingsTap,
|
||||
onLogout: onLogout,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -70,51 +109,78 @@ class _NavPills extends StatelessWidget {
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
static const double _pillHeight = 46;
|
||||
static const double _gap = 10;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_pill(
|
||||
label: 'Cahier de liaison',
|
||||
section: QuotidienNavSection.liaison,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_pill(
|
||||
label: 'Agenda',
|
||||
section: QuotidienNavSection.agenda,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_pill(
|
||||
label: 'Contrat',
|
||||
section: QuotidienNavSection.contrat,
|
||||
),
|
||||
],
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final naturalW = _pillHeight * QuotidienTheme.pillAspectRatio;
|
||||
final naturalTotal = 3 * naturalW + 2 * _gap;
|
||||
final maxW = constraints.maxWidth;
|
||||
// Réduit proportionnellement si la fenêtre est trop étroite
|
||||
// (évite l’overflow jaune/noir sur les pastilles).
|
||||
final scale = maxW.isFinite && maxW > 0 && maxW < naturalTotal
|
||||
? (maxW / naturalTotal).clamp(0.55, 1.0)
|
||||
: 1.0;
|
||||
final h = _pillHeight * scale;
|
||||
final w = naturalW * scale;
|
||||
final g = _gap * scale;
|
||||
final fontSize = (14 * scale).clamp(10.0, 14.0);
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_pill(
|
||||
label: 'Cahier de liaison',
|
||||
section: QuotidienNavSection.liaison,
|
||||
width: w,
|
||||
height: h,
|
||||
fontSize: fontSize,
|
||||
),
|
||||
SizedBox(width: g),
|
||||
_pill(
|
||||
label: 'Agenda',
|
||||
section: QuotidienNavSection.agenda,
|
||||
width: w,
|
||||
height: h,
|
||||
fontSize: fontSize,
|
||||
),
|
||||
SizedBox(width: g),
|
||||
_pill(
|
||||
label: 'Contrat',
|
||||
section: QuotidienNavSection.contrat,
|
||||
width: w,
|
||||
height: h,
|
||||
fontSize: fontSize,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _pill({
|
||||
required String label,
|
||||
required QuotidienNavSection section,
|
||||
required double width,
|
||||
required double height,
|
||||
required double fontSize,
|
||||
}) {
|
||||
final active = selected == section;
|
||||
// Même famille que l’inscription : fonds « dessinés » (pas Material).
|
||||
// Les deux pastilles ont la même silhouette (ratio ~4:1) : la largeur
|
||||
// est dérivée de la hauteur pour ne jamais déformer le PNG.
|
||||
// Chaque section garde sa couleur ; l'inactive est juste plus claire.
|
||||
return ImageButton(
|
||||
bg: QuotidienTheme.pillAssetFor(section),
|
||||
bgOpacity: active ? 1.0 : QuotidienTheme.pillInactiveOpacity,
|
||||
width: _pillHeight * QuotidienTheme.pillAspectRatio,
|
||||
height: _pillHeight,
|
||||
width: width,
|
||||
height: height,
|
||||
text: label,
|
||||
textColor: QuotidienTheme.ink,
|
||||
fontSize: 14,
|
||||
fontSize: fontSize,
|
||||
onPressed: () => onSelected(section),
|
||||
);
|
||||
}
|
||||
|
||||
static const double _pillHeight = 46;
|
||||
}
|
||||
|
||||
class _UserMenu extends StatelessWidget {
|
||||
|
||||
@@ -16,7 +16,7 @@ class QuotidienShell extends StatelessWidget {
|
||||
final VoidCallback? onSettingsTap;
|
||||
final VoidCallback? onLogout;
|
||||
|
||||
/// Colonne gauche (couple + cartes + actions).
|
||||
/// Colonne gauche (cartes + actions).
|
||||
final Widget leftColumn;
|
||||
|
||||
/// Colonne milieu (blog).
|
||||
@@ -25,6 +25,9 @@ class QuotidienShell extends StatelessWidget {
|
||||
/// Colonne droite (messagerie).
|
||||
final Widget rightColumn;
|
||||
|
||||
/// Sélecteur de couple compact dans le bandeau haut (#211).
|
||||
final Widget? contextSelector;
|
||||
|
||||
/// Corps affiché hors Cahier de liaison (Agenda / Contrat stubs).
|
||||
final Widget? agendaBody;
|
||||
final Widget? contratBody;
|
||||
@@ -37,6 +40,7 @@ class QuotidienShell extends StatelessWidget {
|
||||
required this.leftColumn,
|
||||
required this.centerColumn,
|
||||
required this.rightColumn,
|
||||
this.contextSelector,
|
||||
this.userEmail,
|
||||
this.onProfileTap,
|
||||
this.onSearchAmTap,
|
||||
@@ -59,6 +63,7 @@ class QuotidienShell extends StatelessWidget {
|
||||
onSectionSelected: onSectionSelected,
|
||||
userDisplayName: userDisplayName,
|
||||
userEmail: userEmail,
|
||||
contextSelector: contextSelector,
|
||||
onProfileTap: onProfileTap,
|
||||
onSearchAmTap: onSearchAmTap,
|
||||
onSettingsTap: onSettingsTap,
|
||||
|
||||
Reference in New Issue
Block a user