Concetti
Pipeline Fasi
Architettura dello schema fasi — tabelle, viste e flusso dati.
Panoramica
Lo schema PostgreSQL fasi è il layer dati per @pzeta/vue-kanban. Contiene le tabelle core, le viste denormalizzate per il Kanban e le funzioni RPC per le operazioni transazionali.
Schema tabelle
fasi.board — Board disponibili
fasi.fase — Fasi (colonne) di una board
fasi.scheda — Schede (card) nelle fasi
fasi.priorita — Priorità per schede
fasi.tag — Tag etichetta
fasi.statoscheda — Stati scheda (sistema)
fasi.faseteam — Associazione fase ↔ team
fasi.boardcampo — Campi dinamici per board
fasi.templateemail — Template email notifiche
fasi.templatesms — Template SMS notifiche
Viste
| Vista | Dati | Usata da |
|---|---|---|
v_fasi_pipeline | Fasi + metriche aggregate + team | useFasiService.loadFasi() |
v_schede_kanban | Schede + dati denormalizzati | useFasiService.loadSchede() |
v_fasi_avanzamento | Distribuzione stati per fase | useFasiMetrics.loadAvanzamento() |
v_stalli_pipeline | Schede oltre giorni stallo | useFasiMetrics.loadStalli() |
Flusso di un nuovo elemento
Utente clicca "Nuova" nella colonna
→ KanbanFasiBoard apre SchedaFormDialog
→ Utente compila form
→ fasiService.creaScheda(payload)
→ POST /scheda?Content-Profile=fasi
→ fasiService.loadSchede() (refresh)
→ KanbanBoard re-renderizza la colonna
Flusso di spostamento
Utente trascina card in un'altra colonna
→ KanbanColumn emette 'moveItem'
→ KanbanFasiBoard.handleMoveItem()
→ aggiornamento ottimistico di schede.value
→ fasiService.spostaScheda(id, idFaseDestinazione, idUtente)
→ POST /rpc/sposta_scheda_fase?Content-Profile=fasi
→ successo: emit 'schedaspostata'
→ errore: rollback schede.value + emit 'errorespostamento'
Header Content-Profile
Tutte le chiamate allo schema fasi richiedono l'header PostgREST:
Content-Profile: fasi
useFasiService e useFasiMetrics lo impostano automaticamente tramite il repository interno. Se usi @pzeta/postgrest direttamente:
import { usePostgRESTClient } from '@pzeta/vue-kanban'
// Riusa il client singleton inizializzato con initializePostgRESTClient()
const client = usePostgRESTClient()
// Oppure crea un client dedicato con configurazione esplicita
import { createPostgrestClient } from '@pzeta/postgrest'
const client = createPostgrestClient({
baseUrl: import.meta.env.VITE_APP_API_URL,
defaultHeaders: { 'Content-Profile': 'fasi' },
})
Relazione board → fase → scheda
board (1) ──< fase (N) ──< scheda (N)
board (1) ──< priorita (N)
board (1) ──< tag (N)
board (1) ──< boardcampo (N)
fase (1) ──< faseteam (N)
scheda (1) ──< scheda×tag (N) — join table
Una scheda appartiene sempre a esattamente una fase. Lo spostamento aggiorna idfase nella riga scheda tramite la RPC sposta_scheda_fase.