# Episode Management in Project Settings

## Overview

Episode management has been moved to the Project Settings page to provide a centralized location for coordinators to create and manage episodes before creating shots.

## Requirements Added

### New Requirement 3: Episode Management in Project Settings

**User Story:** As a coordinator, I want to create and manage episodes within the project settings, so that I can organize shots into logical production units before creating shots.

#### Acceptance Criteria

1. THE VFX_System SHALL provide episode management functionality within the project settings page
2. WHEN a coordinator accesses project settings, THE VFX_System SHALL display an episodes management section
3. THE VFX_System SHALL allow coordinators to create new episodes with name, episode number, and status
4. THE VFX_System SHALL allow coordinators to edit existing episode details including name, episode number, description, and status
5. THE VFX_System SHALL allow coordinators to delete episodes that have no associated shots
6. THE VFX_System SHALL prevent deletion of episodes that contain shots and display an appropriate error message
7. THE VFX_System SHALL display a list of all episodes for the project with their current status and shot count
8. THE VFX_System SHALL support the following episode statuses: planning, in_progress, on_hold, completed, cancelled
9. THE VFX_System SHALL sort episodes by episode number in ascending order by default

## Task Updates

### Task 12.5: Implement project settings interface with episode management

Updated to include:
- Episode management section within project settings
- Episode list display with episode number, name, status, and shot count
- Episode creation form with all required fields
- Episode edit functionality with validation
- Episode deletion with protection for episodes containing shots
- Tabbed interface for different settings sections

## Design Rationale

### Why Move Episode Management to Settings?

1. **Logical Organization**: Episodes are project-level configuration that should be set up before creating shots
2. **Coordinator Workflow**: Coordinators typically set up project structure (including episodes) before production begins
3. **Centralized Management**: All project configuration in one place makes it easier to manage
4. **Prevents Errors**: Creating episodes first ensures shots are always associated with valid episodes
5. **Better UX**: Separates setup/configuration from day-to-day production work

### User Flow

1. **Project Setup Phase**:
   - Coordinator creates project
   - Coordinator goes to Project Settings
   - Coordinator creates episodes (Episode 1, Episode 2, etc.)
   - Episodes are now available for shot creation

2. **Production Phase**:
   - Coordinator goes to Shots tab
   - Selects episode from dropdown
   - Creates shots for that episode
   - Episode dropdown shows all episodes created in settings

## Implementation Plan

### Backend (Already Exists)
- ✅ Episode model with all required fields
- ✅ Episode CRUD API endpoints
- ✅ Episode-shot relationship
- ✅ Shot count calculation

### Frontend (To Be Implemented)

1. **Project Settings Page Enhancement**
   - Add tabbed interface for different settings sections
   - Create "Episodes" tab

2. **Episode Management Components**
   - `EpisodeManagementPanel.vue` - Main episode management interface
   - `EpisodeTable.vue` - List of episodes with actions
   - `EpisodeFormDialog.vue` - Create/edit episode form
   - `EpisodeDeleteConfirmDialog.vue` - Deletion confirmation with shot count check

3. **Episode Management Features**
   - Display episodes in sortable table
   - Show episode number, name, status, shot count
   - Create new episode button
   - Edit episode inline or in dialog
   - Delete episode with validation
   - Status badge with color coding

4. **Integration**
   - Update `ProjectSettingsView.vue` to include episode management
   - Connect to existing episode service and store
   - Add toast notifications for success/error feedback

## UI Mockup

```
┌─────────────────────────────────────────────────────────┐
│ Project Settings                                         │
├─────────────────────────────────────────────────────────┤
│ [General] [Members] [Episodes] [Technical Specs]        │
├─────────────────────────────────────────────────────────┤
│                                                          │
│ Episodes                                [+ New Episode]  │
│                                                          │
│ ┌────────────────────────────────────────────────────┐ │
│ │ # │ Name      │ Status      │ Shots │ Actions     │ │
│ ├───┼───────────┼─────────────┼───────┼─────────────┤ │
│ │ 1 │ Episode 1 │ In Progress │ 12    │ [Edit][Del] │ │
│ │ 2 │ Episode 2 │ Planning    │ 0     │ [Edit][Del] │ │
│ │ 3 │ Episode 3 │ Planning    │ 0     │ [Edit][Del] │ │
│ └────────────────────────────────────────────────────┘ │
│                                                          │
└─────────────────────────────────────────────────────────┘
```

## Benefits

1. **Better Organization**: Episodes are managed in a dedicated settings area
2. **Clearer Workflow**: Setup phase (settings) vs production phase (shots tab)
3. **Prevents Errors**: Can't create shots without episodes
4. **Easier Management**: All episodes visible and editable in one place
5. **Consistent UX**: Follows pattern of other project settings (members, technical specs)

## Migration Notes

- Existing episode functionality remains unchanged
- Episode dropdown in Shots tab continues to work
- No database changes required
- Only frontend UI organization changes

## Next Steps

1. Implement episode management panel in project settings
2. Add episode table with CRUD operations
3. Create episode form dialog
4. Add validation and error handling
5. Test episode creation and deletion workflows
6. Update user documentation
