Skip to content

Issue #1472: feat: edit an association's Name and Array in the MDR UI - #1509

Merged
bjagg merged 3 commits into
mainfrom
issue-1472-edit-association-ui
Nov 12, 2026
Merged

bjagg merged 3 commits into
mainfrom
issue-1472-edit-association-ui

Conversation

@dereck-symmetry

@dereck-symmetry dereck-symmetry commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Description of Change

Problem. PR #1508 (the API half of #1472) lets the MDR API read and set an association's Name and Array, but the MDR UI can't edit them yet.

Solution. This is the UI half of #1472. It's stacked on #1508, so the diff shrinks to this PR's commit once that merges.

  • Edit Association (entity and attribute associations) shows Name and List under this parent.
    • Only changed fields are sent, as before.
    • Clearing Name sends null, which the API resets to the default key.
    • A whitespace-only Name is sent as typed, so the API's 400 explains why it was refused in the dialog's error line. Cross-model and ExtendedByDataModelId refusals show the same way.
  • The dialog title shows the association's Name, the key the child appears under. Before this PR, handleEditAssoc overwrote itemToEdit.Name with the tree label "for display". With Name now a field, that override would make every save send a Name.
  • + Existing Entity / Attribute (create), in a model's own dialog: picking the child starts the switch at the child's own Array, or off for a Reference (MDR portability: decide whether a Reference association can be a list #1471), so the user sees the list setting and can change it. This follows the decision on MDR portability: generate an element's cardinality from its association's Array #1429/MDR portability: edit an association's Name and Array through the API and UI #1472: after Issue #1429: feat: generate an element's cardinality from its association's Array (backend) #1498, an imported list element is stored as single, so the old default (the rule) is wrong for imported models.
    • SelectDialog gets an optional onSelected hook for this. Value sets don't pass it, so they're unchanged.
    • The create template only copies truthy values it already has, so the switch's value is carried over explicitly (withCreateArray). Otherwise an unticked switch would be dropped.
  • Overlay models' create dialogs don't show the switch. Their associations are cross-model or ExtendedByDataModelId, which the API refuses to give an Array, so sending one would break every plain create there.

Limitations.

Overlap with #1507 (cbeach47, the frontend half of #1429): #1507 makes the UI's own schema and sample records read the association's Array, and this PR is where a user sets it. The two share no files (#1507 changes modelService.ts and types.ts), so either can merge first. Once both are in, a switch flipped here should show up in #1507's schema and samples after the dialog's refetch.

Related Issues

Closes #1472 (with #1508)
Refs #1429, #1471, #1478, #1500, #913

Type of Change
  • New feature (non-breaking change which adds functionality)
Project Area(s) Affected
  • frontends/
  • test/ or e2e/

Checklist
Testing
  • vitest: 62 passed (8 new, in associationKeyFields.test.ts). npm run build (tsc -b + vite) passes; eslint reports 0 errors.
  • Browser, against the real MDR API (this branch's code, seeded Postgres), on model 26 (R1 Demo Source Data Model). I checked each step's request body, and read the stored rows once, after the last step:
    • edit person → employment: Name jobs, list on → PUT {"Name":"jobs","Array":true} (200; reopening shows jobs, on);
    • clear Name → PUT {"Name":null}, final row (employment, t);
    • Name " " → 400, and the dialog stays open with "Name can't be blank: …";
    • attribute association preferences.preferred_org_types, list off → PUT {"Array":false}, final row f;
      • Existing Attribute preferred_org_types (a list) on person: the switch starts on → POST … "Array":true, final row t;
      • Existing Attribute id (single) on employment: starts off, ticked → POST … "Array":true, final row t;
      • Existing Entity preferences (single) under person, untouched → POST … "Array":false, final row f;
    • model 17 (overlay): the + Existing Attribute dialog has no list switch.

🤖 Generated with Claude Code

dereck and others added 2 commits November 11, 2026 18:16
…gh the MDR API

The entity and attribute association DTOs carry Name and Array. Create stores a
sent value, or the rule's when it's not sent or null. Update keeps a sent value
through Relationship/Placement/child edits in the same request, and a sent null
resets it to the rule's. A blank Name is refused, and so is setting either one
across data models or on an association with ExtendedByDataModelId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Edit Association shows the association's Name and a "List under this
parent" switch. Clearing Name sends null, which resets it to the default
key. The dialog title shows the association's Name instead of the tree
label. In a model's own create dialog, picking the child starts the switch
at the child's Array (single for a Reference); an overlay's create dialog
leaves Array to the API, since its cross-model and ExtendedBy associations
can't set it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dereck-symmetry

Copy link
Copy Markdown
Contributor Author

@cbeach47, a heads-up on how this fits with your #1507.

This PR lets a user set an association's Array (and Name) in Edit Association, and sets Array on create from + Existing Entity / Attribute, starting from the picked child's own setting. #1507 makes the UI's schema and sample records read that same Array (IsArray, from ChildEntityDTO.AssociationArray). So this is where the value gets set, and #1507 is where the UI starts using it.

The two PRs share no files. This one changes Dialog.tsx, CreateOptFields.tsx, ModelExplorer.tsx, entityService.ts and attributesService.ts; #1507 changes modelService.ts and types.ts. Either can merge first without a conflict. Once both are in, flipping the switch here should change #1507's schema and samples after the dialog refetches. If you see a case where it doesn't, I'd like to hear about it.

This PR is stacked on #1508 (the API half), so it's based on that branch until #1508 merges.

@bjagg bjagg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, Dereck. I checked it at 8d331d2. It's stacked on #1508, so CI hasn't run on it; I ran its checks locally.

  • Frontend checks:
    • npx vitest run passes (62);
    • tsc -b is clean;
    • eslint gives no errors on the changed files;
    • npm run build succeeds.
  • Red against #1508: all 8 new tests in associationKeyFields.test.ts fail with #1508's CreateOptFields.tsx.
  • The edit dialog sends only changed fields (Dialog.tsx, newValue !== originalValue). So an unchanged Name/Array isn't sent, and it keeps following the rule after a Relationship or Placement edit. The association it edits comes from the association list, which carries Name and Array since #1508.
  • Edge case, not blocking: the dialog starts a boolean field at !!value. So a row whose Array is still NULL shows "off", and any edit to that row sends Array: false. That's rows from older images, until V1.9 fills them. Dev has none: 0 of 2,260 entity associations and 0 of 24,749 attribute associations have a NULL Name or Array.

Approving. Once #1508 merges, retarget this to main so CI runs before it merges.

Base automatically changed from issue-1472-edit-association-name-array to main November 12, 2026 07:53
…anch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bjagg
bjagg merged commit 296827d into main Nov 12, 2026
4 checks passed
@bjagg
bjagg deleted the issue-1472-edit-association-ui branch November 12, 2026 08:22
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Current Community Efforts Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

MDR portability: edit an association's Name and Array through the API and UI

2 participants