Form API clause (phase 2): explicit object/parameter mapping

Open
#1,651 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java, javascript

Research direction

Start by reading phase 1 (#1650) and tracing the existing form API handling for controller.exec, eval, and change. Define how positional object mappings and caller-supplied parameters work, including fully qualified entries and explicit object selection. Done means named calls can inject the specified form objects while preserving the allow-list and object context.

Written by the indexing model from the issue text.

Description

Description

Extends the form API clause (phase 1, #1650) with an optional per-item parameter mapping, so an entry can bind a
specific form object (not only the current/active one) and mix form-bound and caller-supplied parameters.

After the action/property usage, an optional parenthesized list maps each parameter positionally: a form object
name
binds that parameter to the object's current value; ? marks a parameter supplied by the JS caller (its
type comes from the action/property interface).

FORM order 'Order'
    OBJECTS o = Order, w = Warehouse
    PROPERTIES(o) number
    API
        recalc(o),                 // bind param to form object o (phase 1: the id would come from JS)
        transfer(o, w, ?),         // o, w from the form; the amount from JS
        setPrice = price(o, ?),    // property key o from form, sku from JS; change('setPrice', sku, value)
        ACTION post(o)
;
await controller.exec("recalc");            // o injected
await controller.exec("transfer", 10.5);    // o, w injected; amount from JS
await controller.change("setPrice", sku, 9.99); // price(o, sku) <- 9.99 (value is the trailing arg)

The usage is fully qualifiable and signable, same as elsewhere — useful with mapping to pin an overload:

API
    Sales.transfer[Order, Warehouse, NUMERIC](o, w, ?),   // fully-qualified + signed, with object mapping
    setPrice = Sales.price[Order, Sku](o, ?)
;
await controller.exec("Sales.transfer[Order, Warehouse, NUMERIC]", 10.5); // o, w injected; amount from JS
await controller.change("setPrice", sku, 9.99);

This lets a named exec/change be bound to a specific form object (and pins the key to the form's row), and
lets a non-current / second group object be used.

Additionally — to consider here — like the form-only controller.changeProperty(name, value) (which changes a
property in the current row/object context), exec / eval / change may need a way to set the relevant form
object values explicitly for the call
, instead of only using the current (active) object: i.e. let the caller pass
the object value from JS and have it position/seek the corresponding form object for that invocation (e.g. an
object-typed ? parameter that seeks the form object, or an explicit object-set option in the call). This keeps a
call from being limited to the active row while still going through the form's allow-list and object context.

Reason

Phase 1 only allow-lists and aliases entries; parameters still come from the JS caller, so a listed keyed entry can
be called for any key. Phase 2 lets an entry bind some parameters to the form's objects (and take the rest from JS),
so a named exec/change is forced to the form's own object — the caller can't target an arbitrary row — and
needs fewer JS params. Inside an eval script the existing ACTIVE formObjectID operator already reaches a form
object, but it can't be injected into a named exec/change call; phase 2 is that mechanism for the named path.

Dominant language
Java
Stars
214
Forks
46
PR merge metrics
No merged PRs in 30d

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lsfusion/platform

All issues in lsfusion/platform

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.