mix selecto.gen.filter_sets (selecto_mix v0.4.2)

Generates a filter sets implementation for SelectoComponents.

This task creates:

  • A migration for the filter_sets table
  • An Ecto schema module for filter sets
  • A context module implementing the FilterSetsBehaviour
  • Optional test files

Usage

mix selecto.gen.filter_sets MyApp [options]

The first argument is your application's base module name.

Options

  • --context-module - The context module name (default: MyApp.FilterSets)
  • --schema-module - The schema module name (default: MyApp.FilterSets.FilterSet)
  • --table - The table name (default: filter_sets)
  • --repo - The repo module (default: MyApp.Repo)
  • --no-migration - Skip migration generation
  • --no-tests - Skip test file generation

Examples

mix selecto.gen.filter_sets MyApp

mix selecto.gen.filter_sets MyApp \
  --context-module MyApp.Filters \
  --schema-module MyApp.Filters.SavedFilter

Integration

After running this generator, you'll need to:

  1. Run the migration:

    mix ecto.migrate

  2. Configure the filter sets adapter in your components:

    assigns = assign(socket, :filter_sets_adapter, MyApp.FilterSets)

  3. If you use SelectoComponents.Form, the filter sets UI is rendered automatically once filter_sets_adapter is assigned.

    If you are wiring the component manually, pass the same assigns the form integration uses:

    <.live_component module={SelectoComponents.Filter.FilterSets} id="filter-sets" filter_sets_adapter={@filter_sets_adapter} user_id={@user_id} domain={@path || @domain} current_filters={@view_config.filters} />

Summary

Functions

Callback implementation for Mix.Task.run/1.

Functions

run(args)

Callback implementation for Mix.Task.run/1.