Aurora. Uix. Integration. Default. FieldsParser
(Aurora UIX v0.1.4-rc.0)
Copy Markdown
Field metadata parser for Context-based (Ecto) schemas.
Provides utilities for extracting and formatting field metadata from Ecto schemas, including type mapping, HTML input type generation, and field attribute determination. Handles associations, embeds, and standard Ecto field types.
Key Features
- Human-readable label generation from field names
- Ecto type to HTML input type mapping
- Field metadata extraction (length, precision, scale)
- Association and embed handling
- Default placeholder text generation
- Field visibility and editability rules
Key Constraints
- Designed for Ecto schemas only
- Assumes standard Ecto field types
- Association metadata requires Ecto.Association structs
- Embed metadata requires Ecto.Embedded structs
Summary
Functions
Processes embedded resources from an Ecto schema.
Parses all associations from an Ecto schema.
Parses all fields from an Ecto schema into Field structs.
Functions
@spec embedded_resource({atom(), module(), atom()}, [Aurora.Uix.Resource.t()]) :: [ Aurora.Uix.Resource.t() ]
Processes embedded resources from an Ecto schema.
Recursively discovers and configures embedded resources from the parent schema, creating new resource configurations for each embedded field found.
Parameters
parent_resource({atom(), module(), atom()}) - Tuple containing parent resource name, schema module, and type.result(list(Resource.t())) - Accumulator list of resource configurations.
Returns
list(Resource.t()) - Updated list with embedded resource configurations added.
Examples
iex> embedded_resource({:users, MyApp.User, :ctx}, [])
[%Resource{name: :users__profile, ...}]
@spec parse_associations(module(), atom(), [Aurora.Uix.Resource.t()], [ Aurora.Uix.Field.t() ]) :: [ Aurora.Uix.Field.t() ]
Parses all associations from an Ecto schema.
Iterates through schema associations and converts each into a Field struct with proper relationship metadata and type information.
Parameters
resource_schema(module()) - The schema module containing associations.resource_name(atom()) - The name of the resource.resources(list(Resource.t())) - List of available resources for reference lookup.fields(list(Field.t())) - Existing fields list to prepend associations to.
Returns
list(Field.t()) - Updated list with association fields added.
@spec parse_fields(module() | nil, atom()) :: [Aurora.Uix.Field.t()]
Parses all fields from an Ecto schema into Field structs.
Extracts field metadata from the schema and converts each field into a structured Field configuration with type information and display attributes.
Parameters
schema(module() | nil) - The Ecto schema module to parse fields from.resource_name(atom()) - The identifier for the resource.
Returns
list(Field.t()) - List of configured field structs, or empty list if schema is nil.