Introspection
v0.0.1
Gervaz compiles each resource's mishka_gervaz block into one persisted config map at compile time, and the runtime reads that map. The Info modules read it for you. Use them in a LiveView, a template, a test or an iex session instead of re-deriving what the DSL already says. This page lists the functions of each module.
Modules
| Module | Reads |
|---|---|
MishkaGervaz.Resource.Info.Table | The merged table config of a resource. |
MishkaGervaz.Resource.Info.Form | The form config of a resource. |
MishkaGervaz.Domain.Info.Table | The table defaults of a domain. Its config/1 returns the whole domain config, both sides. |
MishkaGervaz.Domain.Info.Form | The form defaults of a domain. Its config/1 returns the whole domain config, both sides. |
MishkaGervaz.Domain.Info | The navigation of a domain, and delegates to the two above. |
MishkaGervaz.ResourceInfo | Flat delegates to the two resource modules. |
MishkaGervaz.DomainInfo | Flat delegates to the domain modules. |
In MishkaGervaz.ResourceInfo and MishkaGervaz.DomainInfo, every function is the original name with a table_ or form_ prefix and the same arity. ResourceInfo.table_columns/1 calls Resource.Info.Table.columns/1, and DomainInfo.form_submit/1 calls Domain.Info.Form.submit/1. DomainInfo.navigation/1 and DomainInfo.menu_groups/1 have no prefix. get_hook, builtins and preload_aliases of the table module, and preload_aliases of the form module, have no delegate in ResourceInfo.
table_config = MishkaGervaz.Resource.Info.Table.config(MishkaBlog.Tag)
columns = MishkaGervaz.Resource.Info.Table.columns(MishkaBlog.Tag)
form_id = MishkaGervaz.Resource.Info.Form.component_id(MishkaBlog.Tag)
defaults = MishkaGervaz.Domain.Info.Table.defaults(MishkaBlog)Resource.Info.Table
| Function | Returns |
|---|---|
config/1 | The full compiled table config, merged with the domain defaults. |
columns/1, column/2, column_order/1 | All columns, one column by name, and the column order. |
filters/1, filter/2, filter_mode/1 | All filters, one filter by name, and the filter mode. |
filter_groups/1, filter_group/2 | All filter groups and one by name. |
row_actions/1, row_action/2, bulk_actions/1 | The row actions, one row action by name, and the bulk actions. |
action_for/3 | The Ash action for :read, :get or :destroy, given master_user?. |
archive_action_for/3, archive_enabled?/1 | The archive action for :read, :get, :restore or :destroy, and whether archive is on. |
detected_preloads/1, all_preloads/2, preload_aliases/2 | Preloads detected from column sources, every preload for a role, and the alias map for a role. |
pagination/1, pagination_enabled?/1, pagination_type/1 | The pagination config, whether it is on, and its type. |
page_size/1, page_size_options/1, max_page_size/1, pagination_ui/1 | The page size values and the pagination UI labels. |
layout/1, header/1, footer/1 | The chrome. Each returns nil when not declared. |
notices/1, notice/2, notices_at/2 | All notices, one by name, and the notices at a position. |
hooks/1, get_hook/2, builtins/1 | The hooks map, one hook by key, and the built-in transition flags. |
refresh/1, url_sync/1 | The refresh and URL sync config. |
features/1, feature_enabled?/2 | The enabled features and a check for one. |
route/1, stream_name/1 | The identity values. |
state/1, data_loader/1, events/1 | The override modules. |
Resource.Info.Form
| Function | Returns |
|---|---|
config/1 | The full compiled form config. |
fields/1, field/2, field_order/1 | All fields, one field by name, and the field order. |
groups/1, uploads/1, submit/1 | The groups, the uploads and the submit config. |
layout/1, navigation/1, persistence/1 | The layout, and its navigation and persistence values. |
steps/1, step/2, step_groups/2 | All steps, one by name, and the group maps of a step. |
header/1, footer/1, notices/1, notice/2, notices_at/2 | The chrome. |
action_for/3 | The Ash action for :create, :update or :read, given master_user?. |
hooks/1, js_hook/2 | The hooks map, and one JS hook function by name. |
detected_preloads/1, all_preloads/2, preload_aliases/2 | The preloads of the form. |
component_id/1 | The identity name as a string, the id to mount the form component with. nil without a form identity. |
route/1, stream_name/1 | The identity values. |
state/1, data_loader/1, events/1 | The override modules. |
Domain.Info
| Module | Functions |
|---|---|
Domain.Info.Table | config/1, defaults/1, ui_adapter/1, ui_adapter_opts/1, actor_key/1, master_check/1, pagination/1, page_size/1, page_size_options/1, max_page_size/1, realtime/1, theme/1, actions/1, refresh/1, url_sync/1 |
Domain.Info.Form | config/1, defaults/1, ui_adapter/1, ui_adapter_opts/1, actor_key/1, master_check/1, actions/1, theme/1, layout/1, template/1, features/1, submit/1 |
Domain.Info | navigation/1 returns the navigation config, or nil when the domain declares none. menu_groups/1 returns the menu groups. |
Helpers
MishkaGervaz.Helpers holds the small functions that templates and handlers share. The ones you are likely to call from a custom template or an override are:
| Function | Does |
|---|---|
humanize/1 | Turns an atom into a title-cased string, so :first_name becomes "First Name". |
resolve_label/1 | Resolves a label that is a string or a zero-arity function, translating a string. |
resolve_options/1 | Calls an options value that is a zero-arity function, and returns a list as it is. |
normalize_options/1 | Turns every label and value of an options list into strings. |
translate_options/1 | Translates the labels and the group labels of an options list. |
accessible?/2 | Applies restricted and visible to an element for a state. restricted: true passes only for a master user. A function restricted is ignored, and visible is a boolean or a function of the state. |
format_filesize/1 | Formats a byte count. |
dynamic_component/1 | Renders the function named in the :function assign on the module in the :module assign. Templates use it to reach the UI adapter. |
strip_tags/1 | Removes HTML tags from a string. |
Errors
Failures are Splode errors under MishkaGervaz.Errors. MishkaGervaz.Errors.format_flash_message/2 turns any of them, and Ash errors, into a flash string. MishkaGervaz.Errors.extract_error_message/2 pulls the message out of an error for a resource.