Allow cascading deletion of tree nodes and unused children #5324
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1653
Rather than protecting children, the delete will cascade if there are no references to those children.
If all child nodes are not referenced by any records within that discipline (taxon, geography, lithostrat, chronostrat, tectonicunit) or institution (storage), then the user should be able to delete the parent and all children:
https://github.com/user-attachments/assets/1b8054b2-db58-4945-a27f-f1eb15b69475
If any child is referenced by a record within that discipline or institution, it should block deletion:
https://github.com/user-attachments/assets/ebdb649a-b57d-4596-89be-c7b094e1bfa2
TO BE DONE
Before this is merged or tested, we should consider this:
Testing instructions
Tip: To find unused nodes, make the counts climb up the entire tree: https://discourse.specifysoftware.org/t/change-tree-node-count-behavior/2014/1