refactor(overview): use English identifier as_of_date for point-in-time filter
This commit is contained in:
parent
ce877463d6
commit
0acd12360f
11 changed files with 113 additions and 112 deletions
|
|
@ -35,7 +35,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
* `{:payment_filter_changed, nil | :fully_paid | {:has_unpaid, 1..3} | {:unpaid_range, pos_integer(), pos_integer() | nil}}`
|
||||
* `{:payment_period_changed, %{from: Date.t() | nil, to: Date.t() | nil}}`
|
||||
* `{:suspended_changed, boolean()}`
|
||||
* `{:stichtag_changed, Date.t() | nil}`
|
||||
* `{:as_of_date_changed, Date.t() | nil}`
|
||||
|
||||
and `{:clear_all_filters}` for Clear all.
|
||||
"""
|
||||
|
|
@ -91,7 +91,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
|> assign(:payment_filter, assigns[:payment_filter])
|
||||
|> assign(:payment_period, assigns[:payment_period] || PaymentAging.default_period())
|
||||
|> assign(:suspended, assigns[:suspended] || false)
|
||||
|> assign(:stichtag, assigns[:stichtag])
|
||||
|> assign(:as_of_date, assigns[:as_of_date])
|
||||
end
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
|
@ -461,23 +461,23 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
</fieldset>
|
||||
|
||||
<%!-- Separate paragraph (not part of the Active/Former button-join): the
|
||||
point-in-time "active on X" Stichtag filter (§1.24). --%>
|
||||
<div class="flex flex-col gap-1" data-testid="stichtag-paragraph">
|
||||
point-in-time "active on X" as-of-date filter (§1.24). --%>
|
||||
<div class="flex flex-col gap-1" data-testid="as-of-date-paragraph">
|
||||
<.input
|
||||
type="date"
|
||||
name="stichtag"
|
||||
name="as_of_date"
|
||||
label={gettext("Active on reference date")}
|
||||
class="input input-sm input-bordered"
|
||||
value={date_iso(@stichtag)}
|
||||
data-testid="stichtag-input"
|
||||
value={date_iso(@as_of_date)}
|
||||
data-testid="as-of-date-input"
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<%!-- Third paragraph "Eigener Zeitraum": the same native From/To range the
|
||||
<%!-- Third paragraph, a custom range: the same native From/To range the
|
||||
join-date builder uses, wired to the exit_date custom mode — members whose
|
||||
exit date falls within [from, to] (§1.24). A sibling form (not the
|
||||
quick/Stichtag one) so committing a bound only touches the exit_date
|
||||
quick/as-of-date one) so committing a bound only touches the exit_date
|
||||
slice and never re-reads the quick radios. --%>
|
||||
<form
|
||||
phx-change="commit"
|
||||
|
|
@ -614,7 +614,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
{local_range(@from_val, @to_val)}
|
||||
</p>
|
||||
|
||||
<%!-- Separate "Eigener Zeitraum" paragraph: two native <input type="date">
|
||||
<%!-- Separate custom-range paragraph: two native <input type="date">
|
||||
controls side by side (§3.12 native-first — no cally). Committing a bound
|
||||
through the shared date dispatch applies the custom range; the browser's
|
||||
own date popup gives year-jump, manual entry and WCAG a11y for free. --%>
|
||||
|
|
@ -722,7 +722,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
def handle_event("commit", params, socket) do
|
||||
dispatch_payment(socket, params)
|
||||
dispatch_quick(socket, params)
|
||||
dispatch_stichtag(socket, params)
|
||||
dispatch_as_of_date(socket, params)
|
||||
dispatch_exit_range(socket, params)
|
||||
|
||||
dispatch_prefix(
|
||||
|
|
@ -824,14 +824,14 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
end
|
||||
end
|
||||
|
||||
defp dispatch_stichtag(socket, params) do
|
||||
if Map.has_key?(params, "stichtag") do
|
||||
date = parse_date(Map.get(params, "stichtag"))
|
||||
maybe_send(date != socket.assigns.stichtag, {:stichtag_changed, date})
|
||||
defp dispatch_as_of_date(socket, params) do
|
||||
if Map.has_key?(params, "as_of_date") do
|
||||
date = parse_date(Map.get(params, "as_of_date"))
|
||||
maybe_send(date != socket.assigns.as_of_date, {:as_of_date_changed, date})
|
||||
end
|
||||
end
|
||||
|
||||
# The exit-date "Eigener Zeitraum" range writes only the exit_date slice
|
||||
# The exit-date custom range writes only the exit_date slice
|
||||
# (mode :custom + bounds), preserving join_date and custom-date entries — so
|
||||
# editing the exit range never wipes another active date filter. Committing an
|
||||
# empty range simply parks exit_date in :custom with nil bounds (no chip, no
|
||||
|
|
@ -917,7 +917,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
end
|
||||
|
||||
defp remove_chip("suspended", _id, _socket), do: send(self(), {:suspended_changed, false})
|
||||
defp remove_chip("stichtag", _id, _socket), do: send(self(), {:stichtag_changed, nil})
|
||||
defp remove_chip("as_of_date", _id, _socket), do: send(self(), {:as_of_date_changed, nil})
|
||||
|
||||
defp remove_chip("group", id, _socket), do: send(self(), {:group_filter_changed, id, nil})
|
||||
defp remove_chip("fee_type", id, _socket), do: send(self(), {:fee_type_filter_changed, id, nil})
|
||||
|
|
@ -947,7 +947,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
fee_type_chips(assigns) ++
|
||||
boolean_chips(assigns) ++
|
||||
date_chips(assigns) ++
|
||||
stichtag_chip(assigns) ++
|
||||
as_of_date_chip(assigns) ++
|
||||
payment_chips(assigns) ++
|
||||
suspended_chip(assigns)
|
||||
end
|
||||
|
|
@ -1117,18 +1117,18 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
|
||||
defp suspended_chip(_), do: []
|
||||
|
||||
defp stichtag_chip(%{stichtag: %Date{} = date}) do
|
||||
defp as_of_date_chip(%{as_of_date: %Date{} = date}) do
|
||||
[
|
||||
%{
|
||||
kind: "stichtag",
|
||||
id: "stichtag",
|
||||
kind: "as_of_date",
|
||||
id: "as_of_date",
|
||||
edit_key: "active_former",
|
||||
label: gettext("Active on %{date}", date: DateFormatter.format_date(date))
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
defp stichtag_chip(_), do: []
|
||||
defp as_of_date_chip(_), do: []
|
||||
|
||||
defp unpaid_range_label(min, nil) when min <= 1, do: gettext("Open contributions")
|
||||
defp unpaid_range_label(min, nil), do: gettext("≥ %{n} unpaid", n: min)
|
||||
|
|
@ -1235,7 +1235,7 @@ defmodule MvWeb.Components.AddFilterBuilderComponent do
|
|||
defp date_iso(_), do: nil
|
||||
|
||||
# ISO string for a bound of the exit_date custom range, pre-filling the
|
||||
# "Eigener Zeitraum" inputs only when the exit filter is actually in :custom
|
||||
# custom-range inputs only when the exit filter is actually in :custom
|
||||
# mode (the quick active/former/all states carry no user range).
|
||||
defp exit_bound_iso(filters, bound) do
|
||||
case Map.get(filters, :exit_date, %{}) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue