Implement role-based booking list views for ROLE_USER and ROLE_INCARICATO

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simone Bierti
2026-04-07 12:34:03 +02:00
committed by Simone Bierti
parent b4d0ca4898
commit 78d3e17d02
4 changed files with 491 additions and 172 deletions

View File

@@ -731,3 +731,62 @@ A profile completion check is shown on the home page to prompt users to complete
- Bootstrap responsive design
- Complete Italian translations
- Security: users can only edit their own profile
---
# Frontend Changes: Gestione e Visualizzazione Prenotazioni per Ruolo
## Date
2026-04-07
## Overview
Implemented role-based booking management views as specified in `features/visualizzazione-prenotazioni.md`. The `prenotazione` list page now renders different UIs depending on the user's role:
- **ROLE_USER**: sees their own bookings in a single table. Edit and Delete actions are hidden when a `Conferma` exists for that booking. A "Vedi conferma" button appears instead.
- **ROLE_INCARICATO**: sees two separate tables — *Prenotazioni in attesa* (no `Conferma`) and *Prenotazioni gestite* (with `Conferma`). A "Prendi in carico" button opens a modal to create the `Conferma` record; after saving, the row moves reactively from the first table to the second without a page reload.
## Files Modified
### 1. Component Logic
**File:** `src/main/webapp/app/entities/prenotazione/prenotazione.component.ts`
- Imported `useAccountStore`, `Authority`, `TipoConferma`, `ConfermaService`
- Added `isIncaricato` computed property (checks `account.authorities`)
- Added `prenotazioniPendenti` and `prenotazioniCompletate` computed arrays (derived from `prenotaziones`)
- Added modal state: `showPrendiInCaricoModal`, `selectedPrenotazione`, `confermaForm`, `isSubmittingConferma`
- Added methods: `prendiInCarico()`, `closePrendiInCaricoModal()`, `submitConferma()`
- `submitConferma()` calls `ConfermaService.create()` with `id` set to the prenotazione id (shared PK), then refreshes the list reactively
### 2. Vue Template
**File:** `src/main/webapp/app/entities/prenotazione/prenotazione.vue`
- Split into two `<template v-if>` blocks: one for `!isIncaricato`, one for `isIncaricato`
- **ROLE_USER block**: simplified column set; Edit/Delete wrapped in `v-if="!prenotazione.conferma"`, "Vedi conferma" router-link shown when `conferma` exists
- **ROLE_INCARICATO block**:
- Table 1 (pendenti): full user/struttura columns + "Prendi in carico" button
- Table 2 (completate): shows `TipoConferma` badge + "Vedi conferma" link
- `b-modal` for "Prendi in carico" with `tipoConferma` select (required) and `motivoConferma` textarea; submit button disabled until tipo selected; spinner during save
### 3. Internationalization
**File:** `src/main/webapp/i18n/it/prenotazione.json`
New keys added:
- `home.titleIncaricato` — page title for incaricato view
- `viewConferma` — "Vedi conferma" button label
- `pendenti.title` / `pendenti.notFound`
- `completate.title` / `completate.notFound`
- `prendiInCarico.button`, `.title`, `.subtitle`, `.selectTipo`, `.motivoPlaceholder`, `.submit`, `.success`
Also improved existing Italian strings (`home.title`, `home.refreshListLabel`, `home.createLabel`, `home.notFound`).
## Acceptance Criteria Status
- [x] ROLE_USER cannot delete/edit a booking that has a conferma (buttons hidden in UI)
- [x] ROLE_INCARICATO sees two tables with correct content split
- [x] Saving a conferma moves the row reactively from Table 1 to Table 2 (via list refresh after create)
- [x] Conferma is created with `id` matching the prenotazione id (shared PK per spec)