Aurora.Uix.Layout.ResourceMetadata (Aurora UIX v0.1.0)
Provides a comprehensive, declarative UI configuration system for structured data in Phoenix LiveView.
Enables rich, metadata-driven UI configuration for data structures with flexible field-level UI metadata management and seamless integration with Phoenix LiveView.
Configuration Strategies
- Field-level customization
- Bulk field configuration
- Automatic default generation based on field types
- Inheritance and extension of configurations
Supported Field Attributes
- Labels and placeholders
- Input types and lengths
- Validation rules (e.g. required)
- Rendering options (readonly, hidden, disabled)
- Precision and scale for numeric fields
- Custom rendering via component or function
- Omission flag to exclude fields entirely (
:omitted)
Example
defmodule MyApp.Product do
use Ecto.Schema
import Ecto.Changeset
schema "products" do
field :name, :string
field :price, :float
field :quantity, :integer
belongs_to :category, MyApp.Category
timestamps()
end
end
defmodule MyApp.Category do
use Ecto.Schema
import Ecto.Changeset
schema "categories" do
field :name, :string
has_many :products, MyApp.Product
timestamps()
end
end
defmodule MyAppWeb.Inventory.Views do
auix_resource_metadata :product, schema: MyApp.Product, context: MyApp.Inventory do
field :id, hidden: true
field :name, placeholder: "Product name", max_length: 40, required: true
field :price, placeholder: "Price", precision: 12, scale: 2
end
auix_resource_metadata :category, schema: MyApp.Category do
field :id, readonly: true
field :name, max_length: 20, required: true
field :products, resource: :product
end
end
Summary
Functions
Defines UI configuration for a schema.
Configures a single field within a resource configuration.
Applies configuration to multiple fields simultaneously.
Functions
Defines UI configuration for a schema.
Parameters
name(atom()) - Resource identifier.opts(keyword()) - Configuration options.do_block(Macro.t() | nil) - Field configurations block.
Options
:schema(module()) - Required. Ecto schema/data structure module.:context(module()) - Optional. Context module with data functions.:order_by(atom() | list() | keyword()) - Optional. Order used for displaying the index.- atom() - Accepts an atom referencing a field.
- list() - Accepts a list of fields (atoms).
- keyword() - Accepts keywords indicating the direction of the sort (:asc, :desc) See Ecto.Query.order_by/3 for details about the supported directions.
Examples
# Single field
auix_resource_metadata(:product,
context: Inventory,
schema: Product,
order_by: :reference
) # Changed direction field
auix_resource_metadata(:product,
context: Inventory,
schema: Product,
order_by: [desc: :reference]
)Returns
Macro.t() - Configured metadata block for the resource.
Configures a single field within a resource configuration.
Provides fine-grained control over field presentation, validation, and interaction rules. Supports comprehensive customization of individual fields.
Parameters
field(atom() | tuple()): The name of the field to configureopts(keyword()): Field-specific configuration options
Options
The following options can be provided to configure the field:
:key(atom()| tuple()) - The referred field in the schema. This should be rarely changed.:type(atom()) - The html type that best represent the current field elixir type.:label(binary()) - A custom label for the field. (auto-generated from field name if omitted).:placeholder(binary()) - Placeholder text for the field.:length(non_neg_integer()) - Display length of the field.:precision(integer()) - The numeric precision for decimal or float fields.:scale(integer()) - The numeric scale for decimal or float fields.:readonly(boolean()) - Marks the field as read-only.:hidden(boolean()) - Hides the field.:filterable?(boolean()) - If true, allows the field to participate in UI filtering.:renderer(function()) - Custom rendering function/component.:required(boolean()) - Marks the field as required.:disabled(boolean()) - If true, the field should not participate in form interaction.:omitted(boolean()) - If true, the field will be entirely excluded from the UI and configuration.
Example
field :name, label: "Product Name", placeholder: "Enter product name", required: true
field :price, precision: 12, scale: 2, label: "Price ($)"
Applies configuration to multiple fields simultaneously.
Enables bulk configuration of fields, reducing repetitive code and promoting consistent field settings across multiple attributes.
Parameters
fields(list() of atoms or tuples): Fields to be configuredopts(keyword()): Configuration options applied to all specified fields
Example
fields [:msrp, :rrp, :list_price], precision: 10, scale: 2