fix(member-export): split composite Name and Address into component columns on export
This commit is contained in:
parent
a64835fe6d
commit
0a23d03d9d
3 changed files with 96 additions and 1 deletions
|
|
@ -83,5 +83,59 @@ defmodule MvWeb.MemberLive.Index.ExportPayloadTest do
|
|||
assert payload.cycle_status_filter == nil
|
||||
assert payload.boolean_filters == %{}
|
||||
end
|
||||
|
||||
test "expands visible composite Name/Address cells into their constituent db columns" do
|
||||
# Compact mode: the composite :name / :address cells are visible and their
|
||||
# constituent columns are hidden from member_fields_visible_db. The export
|
||||
# must still carry name and address, split into their db components.
|
||||
assigns = %{
|
||||
selected_members: MapSet.new(),
|
||||
member_fields_visible_db: [:join_date],
|
||||
member_fields_visible_computed: [],
|
||||
member_fields_visible: [:name, :address, :join_date],
|
||||
member_include_email: true,
|
||||
visible_custom_field_ids: [],
|
||||
all_custom_fields: []
|
||||
}
|
||||
|
||||
payload = ExportPayload.build(assigns)
|
||||
|
||||
# Constituents are emitted in Mv.Constants.member_fields/0 order, interleaved
|
||||
# with the ordinary visible db field (join_date sits between the name and
|
||||
# address groups per constants order).
|
||||
assert payload.column_order == [
|
||||
"first_name",
|
||||
"last_name",
|
||||
"email",
|
||||
"join_date",
|
||||
"city",
|
||||
"street",
|
||||
"house_number",
|
||||
"postal_code"
|
||||
]
|
||||
|
||||
# The composite pseudo-columns themselves are never exported.
|
||||
refute "name" in payload.member_fields
|
||||
refute "address" in payload.member_fields
|
||||
end
|
||||
|
||||
test "omits email from the Name composite expansion when it is not folded into the cell" do
|
||||
# include_email off: email is its own column (exported only if separately
|
||||
# visible), so the Name composite expands to first/last name only.
|
||||
assigns = %{
|
||||
selected_members: MapSet.new(),
|
||||
member_fields_visible_db: [:join_date],
|
||||
member_fields_visible_computed: [],
|
||||
member_fields_visible: [:name, :join_date],
|
||||
member_include_email: false,
|
||||
visible_custom_field_ids: [],
|
||||
all_custom_fields: []
|
||||
}
|
||||
|
||||
payload = ExportPayload.build(assigns)
|
||||
|
||||
assert payload.column_order == ["first_name", "last_name", "join_date"]
|
||||
refute "email" in payload.column_order
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue