Aurora.Uix.Integration.FieldsParser (Aurora UIX v0.1.4-rc.4)

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 :unimplemented for unknown association types
  • Fixed precision/scale values for numeric types
  • Filterable check always returns true (to be specialized by implementations)

Summary

Functions

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

field_data(resource_schema, field_key, arg3, resource_name, type)

@spec field_data(module(), atom(), nil | map(), nil | atom(), nil | term()) :: map()

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.

field_disabled(key)

@spec field_disabled(atom()) :: boolean()

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.

field_filterable(type)

@spec field_filterable(atom()) :: boolean()

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.

field_hidden(field)

@spec field_hidden(atom()) :: boolean()

Determines if a field should be hidden from display.

Checks whether a field should be visible in UI views.

Parameters

  • key (atom()) - The field key.

Returns

boolean() - True if the field should be hidden, false otherwise.

field_html_type(type, arg2)

@spec field_html_type(atom() | tuple(), map() | nil) :: atom()

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).

field_label(name, resource_name, association_or_embed)

@spec field_label(atom() | nil, atom() | nil, map() | nil) :: binary()

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.

field_length(type)

@spec field_length(atom()) :: integer()

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.

field_omitted(key)

@spec field_omitted(atom()) :: boolean()

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.

field_placeholder(name, type)

@spec field_placeholder(atom(), atom()) :: binary()

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.

field_precision(type)

@spec field_precision(atom()) :: integer()

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.

field_scale(type)

@spec field_scale(atom()) :: integer()

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.