reviewed epic 4

This commit is contained in:
Naser Mansour
2025-12-20 23:57:39 +02:00
parent 8b8d9735b9
commit ad2d9604b8
6 changed files with 1144 additions and 117 deletions
+63 -22
View File
@@ -11,19 +11,32 @@ So that **I can organize active and completed case timelines**.
## Story Context
### Existing System Integration
- **Integrates with:** timelines table
- **Integrates with:** timelines table (status field from Story 4.1)
- **Technology:** Livewire Volt
- **Follows pattern:** Soft state change pattern
- **Touch points:** Timeline list views
- **Touch points:** Timeline list views, timeline detail view
### Prerequisites (from Story 4.1)
The `timelines` table includes:
```php
$table->enum('status', ['active', 'archived'])->default('active');
```
### Files to Modify
- `app/Models/Timeline.php` - add archive/unarchive methods and scopes
- `resources/views/livewire/admin/timelines/show.blade.php` - add archive/unarchive button
- `resources/views/livewire/admin/timelines/index.blade.php` - add status filter dropdown
- `resources/views/livewire/client/timelines/index.blade.php` - separate archived timelines display
## Acceptance Criteria
### Archive Timeline
- [ ] Archive button on timeline detail
- [ ] Archive button on timeline detail view (admin only)
- [ ] Confirmation modal before archiving ("Are you sure?")
- [ ] Status changes to 'archived'
- [ ] Timeline remains visible to client
- [ ] No further updates can be added (until unarchived)
- [ ] Visual indicator shows archived status
- [ ] Timeline remains visible to client (read-only as always)
- [ ] No further updates can be added (show disabled state with tooltip)
- [ ] Visual indicator shows archived status (badge + muted styling)
### Unarchive Timeline
- [ ] Unarchive button on archived timelines
@@ -31,14 +44,41 @@ So that **I can organize active and completed case timelines**.
- [ ] Updates can be added again
### List Filtering
- [ ] Filter timelines by status (active/archived/all)
- [ ] Archived timelines sorted separately in client view
- [ ] Bulk archive option for multiple timelines
- [ ] Filter dropdown with options: Active (default), Archived, All
- [ ] Archived timelines shown in separate section in client view (below active)
- [ ] Bulk archive via checkbox selection + "Archive Selected" button
- [ ] Bulk archive shows count confirmation ("Archive 3 timelines?")
### Edge Cases
- [ ] Archiving already-archived timeline: No-op, no error shown
- [ ] Unarchiving already-active timeline: No-op, no error shown
- [ ] Adding update to archived timeline: Prevented with error message
- [ ] Bulk archive mixed selection: Skip already-archived, archive only active ones
- [ ] Empty bulk selection: "Archive Selected" button disabled
### Quality Requirements
- [ ] Audit log for status changes
- [ ] Bilingual labels
- [ ] Tests for archive/unarchive
- [ ] Audit log for status changes (action_type: 'archive' or 'unarchive')
- [ ] Bilingual labels (AR/EN for buttons, messages, filters)
- [ ] Feature tests covering all scenarios below
### Test Scenarios
```
tests/Feature/Timeline/TimelineArchivingTest.php
- test_admin_can_archive_active_timeline
- test_admin_can_unarchive_archived_timeline
- test_archiving_archived_timeline_is_noop
- test_unarchiving_active_timeline_is_noop
- test_cannot_add_update_to_archived_timeline
- test_client_can_view_archived_timeline
- test_admin_can_filter_by_active_status
- test_admin_can_filter_by_archived_status
- test_admin_can_filter_all_statuses
- test_bulk_archive_updates_multiple_timelines
- test_bulk_archive_skips_already_archived
- test_audit_log_created_on_archive
- test_audit_log_created_on_unarchive
- test_guest_cannot_archive_timeline
```
## Technical Notes
@@ -133,20 +173,21 @@ public function bulkArchive(array $ids): void
## Definition of Done
- [ ] Can archive active timeline
- [ ] Can unarchive archived timeline
- [ ] Cannot add updates to archived timeline
- [ ] Filter by status works
- [ ] Bulk archive works
- [ ] Visual indicators correct
- [ ] Audit log created
- [ ] Tests pass
- [ ] Archive button on timeline detail view works with confirmation modal
- [ ] Unarchive button on archived timelines works
- [ ] Update form disabled/hidden on archived timelines with clear messaging
- [ ] Status filter dropdown functional (Active/Archived/All)
- [ ] Bulk archive with checkbox selection works
- [ ] Visual indicators (badge + muted styling) display correctly
- [ ] Client can still view archived timelines in separate section
- [ ] Audit log entries created for all archive/unarchive actions
- [ ] All test scenarios in `tests/Feature/Timeline/TimelineArchivingTest.php` pass
- [ ] Code formatted with Pint
## Dependencies
- **Story 4.1:** Timeline creation
- **Story 4.2:** Timeline updates
- **Story 4.1:** Timeline creation (`docs/stories/story-4.1-timeline-creation.md`) - provides Timeline model and schema
- **Story 4.2:** Timeline updates (`docs/stories/story-4.2-timeline-updates-management.md`) - provides update blocking context
## Estimation