## Overview

The Edit Organizational Structure widget serves as the primary interface for managing organizational structures within cplace. It displays a hierarchical tree representation showing relationships between departments, teams, users (persons), and their associated schedules. The widget enables visualization, navigation, and manipulation of organizational hierarchies through an interactive tree interface.

The tree structure includes:
- **Departments** - Root level and nested (subdepartments), containing users and teams
- **Teams** - Belong to departments and contain user members
- **Persons** - Can belong to multiple departments and/or teams, expandable to show schedules
- **Virtual Schedule Nodes** - Group "Own schedules" and "Substitute schedules" under users
- **Schedules** - Leaf nodes linked to project planning functionality

## Use Cases

### Organizational Structure Management
Building and maintaining company or project organizational structures. Suitable for creating initial structures, updating during reorganizations, adding new departments, and restructuring via drag-and-drop.

### Team Management
HR managers and department heads organizing teams within departments. Create new teams, view all teams and members at a glance, move teams between departments.

### User Assignment and Overview
Managers viewing which users belong to which departments and teams. Users can appear in multiple locations when they belong to multiple organizational units.

### Schedule Management Access
Navigating to user schedules through the organizational tree. Access own schedules, substitute schedules (where user is deputy), and project schedules.

### Homepage and Navigation Hub
Serves as the primary landing page for workspaces with the Organizational Structure app, providing central navigation for all organizational data.

## Design Considerations

### Drag-and-Drop Reorganization
- Only departments can be moved via drag-and-drop (not teams or users)
- Server-side validation prevents invalid hierarchy structures
- Position options: "before", "after", or "inside" the target node

### Context Menu Actions
Actions are context-sensitive based on node type:
- **Departments**: New Department, New Team, Open, Edit access rights, Delete
- **Teams**: New Team, Open, Edit access rights, Delete
- **Schedules**: Copy, Open, Delete
- **Persons/Virtual Nodes**: Open in new tab

### Permission Model
The widget respects cplace permissions - actions are hidden (not disabled) when users lack required permissions. Create, edit/move, delete, and read operations all require appropriate rights.

### Data Loading
Uses lazy loading - root departments load initially, child nodes load on expansion. Real-time updates via platform events for create/delete operations.

## Common Pitfalls

- Assuming teams and users can be reorganized via drag-and-drop (only departments support this)
- Expecting selection functionality - the edit widget focuses on navigation and manipulation, not selection
- Real-time sync only covers create/delete events, not edits to existing items

## Related Widgets

- **Project Tree Widget** (`cf.cplace.projectTree`) - Similar hierarchical tree for project management, shares base infrastructure
- **Personal Tree Content Provider** - Provides schedule management functionality integrated into this widget

## Alternatives

For pure viewing without editing capabilities, consider a read-only tree display. For schedule-focused workflows, the project tree widget may be more appropriate.
