fix: normalize checkbox value and improve UI layout
- Normalize checkbox 'on' value to boolean true in settings - Change Payment Data layout to flex-nowrap for horizontal display - Replace membership fee type dropdown with display-only view - Fix tests to use correct button selectors and switch to membership fees tab
This commit is contained in:
parent
3f723a3c3a
commit
803d9a0a94
10 changed files with 262 additions and 91 deletions
|
|
@ -30,11 +30,39 @@ defmodule MvWeb.MembershipFeeSettingsLive do
|
|||
|
||||
@impl true
|
||||
def handle_event("validate", %{"settings" => params}, socket) do
|
||||
{:noreply, assign(socket, form: AshPhoenix.Form.validate(socket.assigns.form, params))}
|
||||
# Normalize checkbox value: "on" -> true, missing -> false
|
||||
normalized_params =
|
||||
if Map.has_key?(params, "include_joining_cycle") do
|
||||
params
|
||||
|> Map.update("include_joining_cycle", false, fn
|
||||
"on" -> true
|
||||
"true" -> true
|
||||
true -> true
|
||||
_ -> false
|
||||
end)
|
||||
else
|
||||
Map.put(params, "include_joining_cycle", false)
|
||||
end
|
||||
|
||||
{:noreply, assign(socket, form: AshPhoenix.Form.validate(socket.assigns.form, normalized_params))}
|
||||
end
|
||||
|
||||
def handle_event("save", %{"settings" => params}, socket) do
|
||||
case AshPhoenix.Form.submit(socket.assigns.form, params: params) do
|
||||
# Normalize checkbox value: "on" -> true, missing -> false
|
||||
normalized_params =
|
||||
if Map.has_key?(params, "include_joining_cycle") do
|
||||
params
|
||||
|> Map.update("include_joining_cycle", false, fn
|
||||
"on" -> true
|
||||
"true" -> true
|
||||
true -> true
|
||||
_ -> false
|
||||
end)
|
||||
else
|
||||
Map.put(params, "include_joining_cycle", false)
|
||||
end
|
||||
|
||||
case AshPhoenix.Form.submit(socket.assigns.form, params: normalized_params) do
|
||||
{:ok, updated_settings} ->
|
||||
{:noreply,
|
||||
socket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue