MishkaGervaz.Form.SubmitMerger (MishkaGervaz v0.0.1-alpha.3)

Copy Markdown View Source

Resolves the final form submit configuration by merging the resource-level submit (built from the DSL entity) with the domain-level submit defaults.

Priority rules

  • Resource is the first priority; domain is the second.
  • For each button kind (:create, :update, :cancel):
    • If the resource defines the button, the resource wins. The label falls back through resource → domain → hard default for the kind.
    • If the resource does not define the button, the domain button is used.
    • If the resource defines the button with active: false, the button is suppressed regardless of what the domain provides.
  • position follows resource → domain → :bottom.
  • ui follows resource → domain → nil.
  • If neither side defines submit, the result is nil.
  • If only the domain defines submit, its buttons are normalized so that missing labels fall back to the hard defaults.

Both BuildRuntimeConfig (compile time) and Resource.Info.Form (runtime) use this module so the merge logic stays in one place.

Summary

Functions

Merges the resource entity (or pre-built map) with the domain submit map.

Functions

merge(resource, domain)

@spec merge(MishkaGervaz.Form.Entities.Submit.t() | map() | nil, map() | nil) ::
  map() | nil

Merges the resource entity (or pre-built map) with the domain submit map.

Returns the merged map with this shape:

%{
  create: %{label, active, disabled, restricted, visible} | nil,
  update: %{...} | nil,
  cancel: %{...} | nil,
  position: :top | :bottom | :both,
  ui: map() | nil
}

Returns nil if neither side defines a submit block.