Skip to content

Nest organizations under a parent org - #2473

Merged
maebeale merged 9 commits into
mainfrom
maebeale/nested-orgs-fm-import
Sep 1, 2026
Merged

Nest organizations under a parent org#2473
maebeale merged 9 commits into
mainfrom
maebeale/nested-orgs-fm-import

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 new self-referential nesting on Organization — a migration + a few model/view additions, no wide blast radius

Organizations can now sit under a parent "roof" org, so the FileMaker import can pull the historically-split Adult/Children program records back under one organization — staff wanted them grouped, not duplicated.

Closes #508

What's here

  • Model — one nullable parent_id self-FK (belongs_to :parent / has_many :children), mirroring FileMaker's Organization ParentID. Arbitrary depth, with #ancestors / #descendants / #root helpers.
  • Structural only — a parent does not aggregate its children's affiliations/sectors/workshops/etc. yet. Deliberate first cut; roll-ups are a later change (ADR-0004 D2).
  • Safe by construction — cycle guard (can't parent yourself or a descendant), and deleting a parent un-nests its children (dependent: :nullify) rather than deleting real programs.
  • UI — admin sets the parent from a "Parent organization" picker on the org edit form (reuses the remote-select pattern, excludes self + descendants). The profile shows the relationship both ways: a "Part of …" link up and a "Nested organizations" list down.

Notes for the reviewer

  • Decision record: docs/adr/0004-nested-organizations.md.
  • Added a Features & tips entry (admin-facing) and an AGENTS.md line for the new model capability.

@maebeale
maebeale force-pushed the maebeale/nested-orgs-fm-import branch from a9d8e43 to 2af9ea3 Compare August 31, 2026 22:23
@maebeale
maebeale marked this pull request as ready for review September 1, 2026 03:18
@maebeale maebeale changed the title Nest organizations under a parent org WAIT UNTIL DEPLOY: Nest organizations under a parent org Sep 1, 2026
Comment thread app/views/organizations/_form.html.erb Outdated
controller: "remote-select",
remote_select_model_value: "organization",
remote_select_exclude_value: ([ f.object.id ] + f.object.descendants.map(&:id)).compact.join(","),
remote_select_truncate_chars_value: 22

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you added this. My personal suggestion would be to just place the search box under the Org name input so they would be the same width. This search box is tiny in this position (so not a great experience typing) and drives the need for this extra remote-select code added in the PR.

I don't love added extra things to the remote-select controller if we can help it because it is used in so many places. Keeping it simple will help keep it maintainable.

This is an example of my concern about design driving the code instead of taking a design compromise with simpler code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmilljr24 was thinking same to back out of remote-select change anyway just to not touch it. still, having it be an expandable box that wraps text isn't a great ui everywhere it is, so was considering this signal enough to make the needed change, not this was driven by a short width placement.

@maebeale

maebeale commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

@jmilljr24 since you've already reviewed, i'll take out the remote-select change and would love to merge and not wait.

maebeale and others added 9 commits September 1, 2026 12:07
Mirrors FileMaker's Organization ParentID so the FM organizations import
can group the split Adult/Children program records under one org roof.
Structural only (no roll-up), arbitrary-depth tree with cycle protection.

Refs #508

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Applies to every remote-select record picker: a long value (e.g. a parent
org name) now ellipsizes on one line rather than doubling the control height.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Only the parent-org picker truncates its long selected label; every other
remote-select keeps its existing wrapping behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- remote-select truncation is now a fixed ch-width cap (truncate-chars value)
  driving a CSS var, never exceeding the control width
- selected item carries a title tooltip so the full label shows on hover
- when a parent is saved, the picker label becomes a jump link (new tab) to
  the parent org's profile

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the truncation/tooltip changes to the shared remote-select controller;
the parent-org picker no longer opts into a width cap. The clickable
jump-link label to the parent's profile stays.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maebeale
maebeale force-pushed the maebeale/nested-orgs-fm-import branch from 2a09bd5 to c163faf Compare September 1, 2026 16:08

@jmilljr24 jmilljr24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I thought the title had something to do with changes in staging.

This looks good matching the FM pattern. Would love to know your thoughts some other time about the structure and if it's something we would eventually want to move away with or if its a good db pattern.

@maebeale maebeale changed the title WAIT UNTIL DEPLOY: Nest organizations under a parent org Nest organizations under a parent org Sep 1, 2026
@maebeale
maebeale merged commit 504b1b7 into main Sep 1, 2026
3 checks passed
@maebeale
maebeale deleted the maebeale/nested-orgs-fm-import branch September 1, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build a way to nest Organizations

2 participants