Update cycle button styling and text

Make cycle button match PaymentFilterComponent and Columns button style.
Show 'Current Cycle Payment Status' or 'Last Cycle Payment Status'
based on active state. Button shows active state when current cycle
is selected.
This commit is contained in:
Moritz 2025-12-18 13:47:23 +01:00
parent effb710741
commit f25e198b0e
Signed by: moritz
GPG key ID: 1020A035E5DD0824
3 changed files with 71 additions and 19 deletions

View file

@ -42,23 +42,34 @@
cycle_status_filter={@cycle_status_filter} cycle_status_filter={@cycle_status_filter}
member_count={length(@members)} member_count={length(@members)}
/> />
<div class="flex gap-2 items-center">
<button <button
type="button" type="button"
phx-click="toggle_cycle_view" phx-click="toggle_cycle_view"
class={[ class={[
"btn btn-sm btn-outline gap-2", "btn gap-2",
@cycle_status_filter && "btn-active" @show_current_cycle && "btn-active"
]} ]}
aria-label={gettext("Show Last/Current Cycle Payment Status")} aria-label={
title={gettext("Show Last/Current Cycle Payment Status")} if(@show_current_cycle,
do: gettext("Current Cycle Payment Status"),
else: gettext("Last Cycle Payment Status")
)
}
title={
if(@show_current_cycle,
do: gettext("Current Cycle Payment Status"),
else: gettext("Last Cycle Payment Status")
)
}
> >
<.icon name="hero-arrow-path" class="size-4" /> <.icon name="hero-arrow-path" class="h-5 w-5" />
<span class="hidden sm:inline"> <span class="hidden sm:inline">
{gettext("Show Last/Current Cycle Payment Status")} {if(@show_current_cycle,
do: gettext("Current Cycle Payment Status"),
else: gettext("Last Cycle Payment Status")
)}
</span> </span>
</button> </button>
</div>
<.live_component <.live_component
module={MvWeb.Components.FieldVisibilityDropdownComponent} module={MvWeb.Components.FieldVisibilityDropdownComponent}
id="field-visibility-dropdown" id="field-visibility-dropdown"

View file

@ -186,7 +186,10 @@ Enum.with_index(member_attrs_list)
member_attrs_with_fee_type = Map.put(member_attrs, :membership_fee_type_id, fee_type.id) member_attrs_with_fee_type = Map.put(member_attrs, :membership_fee_type_id, fee_type.id)
# Use upsert to prevent duplicates based on email # Use upsert to prevent duplicates based on email
Membership.create_member!(member_attrs_with_fee_type, upsert?: true, upsert_identity: :unique_email) Membership.create_member!(member_attrs_with_fee_type,
upsert?: true,
upsert_identity: :unique_email
)
end) end)
# Create additional users for user-member linking examples # Create additional users for user-member linking examples
@ -249,7 +252,9 @@ Enum.with_index(linked_members)
# Start from where previous members ended # Start from where previous members ended
fee_type_index = rem(length(member_attrs_list) + index, length(all_fee_types)) fee_type_index = rem(length(member_attrs_list) + index, length(all_fee_types))
fee_type = Enum.at(all_fee_types, fee_type_index) fee_type = Enum.at(all_fee_types, fee_type_index)
member_attrs_with_fee_type = Map.put(member_attrs_without_user, :membership_fee_type_id, fee_type.id)
member_attrs_with_fee_type =
Map.put(member_attrs_without_user, :membership_fee_type_id, fee_type.id)
# Check if user already has a member # Check if user already has a member
if user.member_id == nil do if user.member_id == nil do

View file

@ -42,5 +42,41 @@ defmodule Mv.SeedsTest do
assert length(custom_fields_count_1) == length(custom_fields_count_2), assert length(custom_fields_count_1) == length(custom_fields_count_2),
"CustomFields count should remain same after re-running seeds" "CustomFields count should remain same after re-running seeds"
end end
test "all members have membership fee type assigned" do
# Run the seeds script
assert Code.eval_file("priv/repo/seeds.exs")
# Get all members
{:ok, members} = Ash.read(Mv.Membership.Member)
# All members should have a membership_fee_type_id
Enum.each(members, fn member ->
assert member.membership_fee_type_id != nil,
"Member #{member.first_name} #{member.last_name} should have a membership fee type assigned"
end)
end
test "each membership fee type has at least one member" do
# Run the seeds script
assert Code.eval_file("priv/repo/seeds.exs")
# Get all fee types and members
{:ok, fee_types} = Ash.read(Mv.MembershipFees.MembershipFeeType)
{:ok, members} = Ash.read(Mv.Membership.Member)
# Group members by fee type
members_by_fee_type =
members
|> Enum.group_by(& &1.membership_fee_type_id)
# Each fee type should have at least one member
Enum.each(fee_types, fn fee_type ->
members_for_type = Map.get(members_by_fee_type, fee_type.id, [])
assert length(members_for_type) > 0,
"Membership fee type #{fee_type.name} should have at least one member assigned"
end)
end
end end
end end