You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 397de92
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(workflow-form): render Projection's drag-reorder list in the form, with the drag (apache#8843)
### What changes were proposed in this PR?
Closesapache#8761. Part of the Form View feature (apache#8011); from the apache#8439
refinements (item 2).
An exposed drag-reorder property -- Projection's columns, formly type
`repeat-section-dnd` -- fell back to a plain repeated list in the Form
View (`CANVAS_ONLY_FORMLY_TYPES`): a reader could edit the rows but not
reorder them, which is what the widget is for. The fallback assumed the
drag had nowhere to attach on a form; the widget carries its own CDK
drop list, and the row template it needs comes from the operator's own
schema (the per-instance one, with the upstream columns), which the form
already builds.
- `repeat-section-dnd` leaves `CANVAS_ONLY_FORMLY_TYPES`; the set now
holds the code editor only. On the form the widget renders exactly as on
the operator property panel, drag handle and all, and a drop reaches the
operator through the card's `valueChanges` write-back; the panel's
`reorder` callback stays optional (the widget calls it only when the
host provides one), so the same widget serves both hosts without a
form-specific branch. Nothing is added to the widget's UI.
- Two defects in the widget itself, found while reviewing this and in
reach of the form for the first time: every button now has
`type="button"` -- `nz-button` sets no type, so inside a form (the
card's, the panel's) a typeless button is the submit button and Enter in
a row's input clicked it, removing the first row (the fallback the form
used before had typed buttons; the panel has had this since the widget
exists); and the rows are re-keyed to their positions after a drop, as
formly's own `remove()` does -- formly keys rows by position and writes
a cell's value into the model by that key path, so a value typed into a
moved row landed on the row that used to be there (the same after a drag
on the panel, until the operator was re-selected).
### Any related issues, documentation, discussions?
Closesapache#8761. Raised by @mengw15 on apache#8436; filed from apache#8439. Builds on
the sub-field walk from apache#8438. apache#8760 (proper) also shrinks
`CANVAS_ONLY_FORMLY_TYPES`; whichever lands second deletes the
then-empty set. Known limitation, not this PR's code: the Form View
rebuilds every card on every compilation, including the one a card's own
write triggers, so on the form a drop's write redraws the rows about a
second later, and a second drop made in the last 150 ms before that
redraw is undone. The canvas panel has no such rebuild. Filed as apache#8844
and fixed in apache#8845 (the form rebuilds only when the schema, the set of
inputs or a value it does not hold changed); this PR is independent of
it. Other follow-ups: a card's model is seeded once and never re-seeded
from a co-editor's edit of the same property, so a reorder writes the
whole array back over such an edit (pre-existing for every array/object
property; a reorder is one more trigger); the HuggingFace and codearea
widgets also carry typeless buttons.
### How was this PR tested?
Unit tests (vitest). The widget's spec: a drop reorders the model, the
field configs and the form controls and then tells the parent; a section
without a reorder callback still reorders; a keyless row's children are
re-keyed to the row's new position, as formly's own remove() does; every
button carries `type="button"`; the existing rendering tests (one row
per entry, draggable rows, remove, add, disabled section) still hold. A
second spec stands the widget up under real formly
(`FormlyModule.forRoot`, a form, a model): a drop changes the model and
the cells and keeps the rows' keys in step with their positions, and a
value typed into a moved row lands on that row's entry. The form's spec:
Projection's `attributes` renders through `repeat-section-dnd`.
`custom-formly-type`'s spec pins the set. Each guard was
deletion-checked (the re-keying dropped; the callback called unguarded;
the remove button typeless; the type back in the canvas-only set) and
turned a named test red. eslint, prettier and the production (AOT) build
pass; the full frontend suite passes; every statement, function and
branch this PR adds is covered.
Checked on a flag-on instance (main-demo; a Python source with four
columns feeding a Projection whose `attributes` is exposed), with the
canvas and the form open side by side: on main the card is a plain list
(no handle); with this PR the card shows the drag handles, as the panel
does. Dragging the last row to the top: the operator's order follows in
the canvas tab's panel within a second and in the saved workflow. An
alias typed into the moved row lands on that column, not its neighbour;
Enter in an alias input removes no row; a reload shows the same order. A
drop made on the canvas panel reaches the form within a second.
#### Video
**Before**
https://github.com/user-attachments/assets/5a78f6f5-3b27-4b93-955e-bb15b40fd854
**After**
https://github.com/user-attachments/assets/b84c79fa-a0a4-4bbc-b734-e75147bdf0d6
### Was this PR authored or co-authored using generative AI tooling?
Yes. Generated-by: Claude Code (Claude Fable 5.1, Anthropic).
Co-authored with Claude, reviewed line by line by the author before
submission.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Meng Wang <[email protected]>
0 commit comments