Aurora. Uix. Integration. FieldsParser
(Aurora UIX v0.1.4-rc.1)
Copy Markdown
Common field parsing utilities for integration modules.
Provides shared functions for converting Elixir types to HTML input types, generating field labels, placeholders, and determining field metadata such as length, precision, and visibility rules. Used by both Ash and Ctx integration field parsers.
Key Features
- HTML5 input type mapping from Elixir types
- Field label generation with capitalization
- Default placeholder text generation
- Field length and precision calculation
- Field visibility and editability rules
- Microsecond timestamp handling
Key Constraints
- Designed for standard Ecto and Ash types
- Returns
:unimplementedfor unknown association types - Fixed precision/scale values for numeric types
- Filterable check always returns true (to be specialized by implementations)
Summary
Functions
Extracts metadata for field types.
Checks if a field should be disabled by default.
Determines if a field should be filterable in queries.
Determines if a field should be hidden from display.
Maps an Elixir type to an HTML input type.
Formats a display label from a field name.
Determines the display length for a field.
Checks if a field should be omitted from forms.
Determines the default placeholder text for a field.
Gets the numeric precision for number fields.
Gets the numeric scale for decimal/float fields.
Functions
Extracts metadata for field types.
Returns additional metadata for fields that require special handling, such as step values for microsecond timestamps.
Parameters
resource_schema(module()) - The schema module.field_key(atom()) - The field identifier.association_or_embed(map() | nil) - Optional association metadata.resource_name(atom()) - The resource name.type(term()) - The field type.
Returns
map() - Field metadata map, or empty map if no special handling needed.
Checks if a field should be disabled by default.
Determines whether a field should be read-only in forms based on its key.
Parameters
key(atom()) - The field key (e.g.,:id,:deleted).
Returns
boolean() - True if the field should be disabled, false otherwise.
Determines if a field should be filterable in queries.
Checks whether a field can be used in filter/search operations.
Parameters
type(atom()) - The field type.
Returns
boolean() - True if the field is filterable, false otherwise.
Maps an Elixir type to an HTML input type.
Converts Elixir/Ecto types to appropriate HTML5 input types for form generation.
Parameters
type(atom() | tuple()) - The Elixir type (e.g.,:string,:integer,:datetime).association(map() | nil) - Optional association metadata.
Returns
atom() - The HTML input type (e.g., :text, :number, :checkbox, :unimplemented).
Formats a display label from a field name.
Capitalizes field names and replaces underscores with spaces for human-readable labels.
Parameters
name(atom() | nil) - The field name to format.resource_name(atom() | nil) - The resource name (currently unused).association_or_embed(map() | nil) - Optional association metadata (currently unused).
Returns
binary() - The formatted label string, or empty string if name is nil.
Determines the display length for a field.
Calculates appropriate display width based on field type for form rendering.
Parameters
type(atom()) - The field type (e.g.,:string,:integer,:datetime).
Returns
integer() - The field display length in characters.
Checks if a field should be omitted from forms.
Determines whether a field should be excluded from form rendering.
Parameters
key(atom()) - The field key (e.g.,:inserted_at,:updated_at).
Returns
boolean() - True if the field should be omitted, false otherwise.
Determines the default placeholder text for a field.
Generates placeholder text based on field type, providing sensible defaults for form inputs.
Parameters
name(atom()) - The field name.type(atom()) - The field type (e.g.,:string,:integer,:binary_id).
Returns
binary() - The placeholder text for the field.
Gets the numeric precision for number fields.
Returns the total number of digits for numeric types.
Parameters
type(atom()) - The field type (e.g.,:integer,:decimal).
Returns
integer() - The precision value, or 0 for non-numeric types.
Gets the numeric scale for decimal/float fields.
Returns the number of digits after the decimal point for fractional numeric types.
Parameters
type(atom()) - The field type (e.g.,:float,:decimal).
Returns
integer() - The scale value, or 0 for non-fractional types.