Delete an Organizational Unit with Cascade Validation
From the Org Level Detail Screen, an authorized administrator can initiate deletion of an organizational unit. Before proceeding, the Org Structure Service performs cascade validation: it checks whether the unit has any child nodes in the hierarchy, active coordinators assigned to it, or unresolved activity attributions. If any blocking conditions exist, the delete is rejected with a descriptive error listing the blocking dependencies. If validation passes, the user is presented with a confirmation dialog before the deletion is committed. The repository executes the deletion transactionally to prevent partial state.
User Story
Acceptance Criteria
- Given I am an authorized administrator, when I tap the Delete action on a unit detail screen, then a confirmation dialog appears before any data is modified
- Given a unit has child associations, when I attempt to confirm deletion, then the system rejects it with an error message listing the child units that must be removed first
- Given a unit has active coordinators assigned, when I attempt to delete it, then the system rejects the deletion and prompts me to reassign or remove those coordinators first
- Given all cascade validation checks pass and I confirm deletion, when the operation completes, then the unit is removed and the parent unit's child count decrements correctly
- Given the deletion succeeds, when I return to the organization tree, then the deleted unit no longer appears at any level of the hierarchy
Business Value
Cascade validation on deletion prevents the most common class of data integrity errors in hierarchical systems — orphaned child records and broken role assignments. For a system where organizational structure directly drives access control and Bufdir reporting, unguarded deletions could silently corrupt financial grant data.
Components
- Org Level Detail Screen ui
- Org Structure Service service
- Org Structure Repository data
- Org Structure RLS Policy infrastructure