Add filter prefix constants and shared FilterParams module
- Mv.Constants: group_filter_prefix/0, fee_type_filter_prefix/0 - MvWeb.MemberLive.Index.FilterParams: parse_in_not_in_value/1 for URL param parsing
This commit is contained in:
parent
5ab73aada6
commit
2a07ddef80
2 changed files with 36 additions and 0 deletions
22
lib/mv_web/live/member_live/index/filter_params.ex
Normal file
22
lib/mv_web/live/member_live/index/filter_params.ex
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
defmodule MvWeb.MemberLive.Index.FilterParams do
|
||||
@moduledoc """
|
||||
Shared parsing helpers for member list filter URL/params (in/not_in style).
|
||||
Used by MemberLive.Index and MemberFilterComponent to avoid duplication and recursion bugs.
|
||||
"""
|
||||
@doc """
|
||||
Parses a value for group or fee-type filter params.
|
||||
Returns `:in`, `:not_in`, or `nil`. Handles trimmed strings; no recursion.
|
||||
"""
|
||||
def parse_in_not_in_value("in"), do: :in
|
||||
def parse_in_not_in_value("not_in"), do: :not_in
|
||||
|
||||
def parse_in_not_in_value(val) when is_binary(val) do
|
||||
case String.trim(val) do
|
||||
"in" -> :in
|
||||
"not_in" -> :not_in
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
def parse_in_not_in_value(_), do: nil
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue