MishkaCmsCore.Runtime.PageBuilder.Helpers (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Saves a builder section through its resource's own actions.

Summary

Functions

Persists a builder section (page / layout / error page) by delegating to the resource's own create/update actions, so the resource's guardedstruct validation and field policies stay the single source of truth (no second schema on the builder side). Create vs update is chosen by an "id" in fields; master vs tenant by the actor's site_id (a master has site_id: nil and uses the bypass :master_* actions). fetch reads the record for an update. Returns the resource's own {:ok, record} / {:error, changeset}.

Functions

save_section(resource_module, fetch, fields, actor, opts \\ [])

Persists a builder section (page / layout / error page) by delegating to the resource's own create/update actions, so the resource's guardedstruct validation and field policies stay the single source of truth (no second schema on the builder side). Create vs update is chosen by an "id" in fields; master vs tenant by the actor's site_id (a master has site_id: nil and uses the bypass :master_* actions). fetch reads the record for an update. Returns the resource's own {:ok, record} / {:error, changeset}.

A field whose value is a one-argument function is one that has to be WORKED OUT FROM THE ROW BEING WRITTEN — an error page's error_pages is the whole list with one entry replaced — and it is resolved here, against the record this function has just read and is about to update, rather than by the caller against whatever copy it happens to hold. See MishkaCmsCore.Runtime.PageBuilder.Section.save_fields/3, which is what builds them.

Pass typed: true when the markup was typed by hand rather than generated from the tree — the recovery screen's box. The write is then code, as from any form, which a deployment that turned code off refuses.