TenantAtlas/specs/124-inventory-coverage-table/data-model.md
ahmido 3971c315d8 feat: add inventory coverage interactive table (#151)
## Summary
- replace the static Inventory Coverage HTML tables with a Filament native searchable, sortable, filterable table on the existing tenant page
- normalize supported policy types and foundations into one runtime dataset while preserving centralized badge semantics and the documented read-only action-surface exemption
- add the full spec kit artifact set for feature 124 and focused Pest coverage for rendering, search, sort, filters, empty state, and regression-sensitive page copy

## Testing
- `vendor/bin/sail bin pint --dirty --format agent`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/InventoryCoverageTableTest.php tests/Feature/Filament/InventoryPagesTest.php tests/Feature/Filament/InventoryHubDbOnlyTest.php`

## Filament Notes
- Livewire v4.0+ compliance: yes, this uses Filament v5 table APIs on the existing page and does not introduce any Livewire v3 patterns
- Provider registration: unchanged; Laravel 11+ provider registration remains in `bootstrap/providers.php`
- Globally searchable resources: none changed in this feature; no Resource global-search behavior was added or modified
- Destructive actions: none; the page remains read-only and only exposes a non-destructive clear-filters empty-state action
- Asset strategy: no new panel or shared assets were added, so no `filament:assets` deployment change is required for this feature
- Testing plan delivered: focused Filament/Pest coverage for the page table surface plus existing page-load regressions

## Follow-up
- Manual dark-mode and badge-regression QA from task `T018` is still pending and should be completed before merge if that check remains mandatory in your review flow.

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #151
2026-03-08 18:33:00 +00:00

79 lines
3.6 KiB
Markdown

# Data Model: Inventory Coverage Interactive Table
## Overview
This feature does not introduce persistent storage. It defines runtime view-model objects that shape existing coverage metadata into a Filament table.
## Entities
### CoverageTableRow
- Purpose: Represents one row in the interactive coverage table.
- Source: Derived from `InventoryPolicyTypeMeta::supported()` and `InventoryPolicyTypeMeta::foundations()` plus `CoverageCapabilitiesResolver`.
#### Fields
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `key` | string | yes | Stable runtime identifier composed from segment and type for table keys and deterministic ordering |
| `segment` | enum(`policy`,`foundation`) | yes | Distinguishes supported policy types from foundation types |
| `type` | string | yes | Stable policy type identifier |
| `label` | string | yes | Human-readable label derived from shared badge metadata |
| `category` | string | yes | Coverage category from the metadata catalog |
| `dependencies` | bool | yes | Whether dependency support is available for the type |
| `restore` | string nullable | no | Restore mode value when present in the current data shape |
| `risk` | string | yes | Risk state from the existing metadata source |
| `source_order` | int | yes | Preserves deterministic fallback ordering from the source lists |
#### Validation Rules
- `key` must be non-empty and unique within the dataset.
- `segment` must be one of `policy` or `foundation`.
- `type` must be non-empty.
- `category` and `risk` must match values already emitted by the metadata source.
- `restore` may be null; if present, it must match a restore-mode value supported by the shared badge catalog.
### CoverageTableDataset
- Purpose: Aggregates the derived rows and the filter metadata required by the table.
#### Fields
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `rows` | list<CoverageTableRow> | yes | Full runtime dataset rendered by the table |
| `categories` | list<string> | yes | Distinct category options available for filtering |
| `restore_modes` | list<string> | no | Distinct restore values available for filtering; empty when restore metadata is absent |
#### Relationships
- One `CoverageTableDataset` contains many `CoverageTableRow` objects.
- Badge rendering for each `CoverageTableRow` is derived from shared badge catalogs, not embedded or persisted.
### CoverageTableState
- Purpose: Represents the transient UI state managed by Filament table interactions.
#### Fields
| Field | Type | Description |
|-------|------|-------------|
| `search` | string nullable | Current free-text search term |
| `category_filter` | string nullable | Selected category filter |
| `restore_filter` | string nullable | Selected restore filter when available |
| `sort_column` | string nullable | Current sort column |
| `sort_direction` | enum(`asc`,`desc`) nullable | Current sort direction |
| `page` | int | Current pagination page |
## State Transitions
- Initial load: Build `CoverageTableDataset` from existing metadata sources and render default sort order.
- Search update: Narrow `rows` by matching `type` and `label`.
- Category filter update: Narrow `rows` to selected category.
- Restore filter update: Narrow `rows` to selected restore mode when that filter exists.
- Reset action: Clear search and filters and return to the default dataset view.
## Notes
- No database migrations, model classes, or storage contracts change in this feature.
- The runtime row model exists only to shape existing metadata for a native Filament table experience.