admin: list contacts as "Name (Nickname)"
Assisted-by: GLM-5.3 via pi
diff --git a/lib/pro_tacts/admin/dashboard.rb b/lib/pro_tacts/admin/dashboard.rb
index aa8f625..8d0701f 100644
--- a/lib/pro_tacts/admin/dashboard.rb
+++ b/lib/pro_tacts/admin/dashboard.rb
@@ -77,8 +77,8 @@ module ProTacts
private
# Match generously (docs/DESIGN.md): a contact is findable by
- # name — the nickname too, being the name it lists under — any
- # of its values, or the groups it belongs to.
+ # name or nickname, any of its values, or the groups it
+ # belongs to.
#: (Store::RecentContact row, String query) -> bool
def matches?(row, query)
q = query.downcase
diff --git a/lib/pro_tacts/admin/format.rb b/lib/pro_tacts/admin/format.rb
index 56ffc1f..18e2758 100644
--- a/lib/pro_tacts/admin/format.rb
+++ b/lib/pro_tacts/admin/format.rb
@@ -7,9 +7,9 @@ module ProTacts
# Small display helpers shared by the admin views. Presentation, not
# structure: these read a Contact but decide only how it looks.
module Format
- # The name a listing row shows: "Nickname (Name)" when the card
- # carries a NICKNAME — the name someone is known by, the formal
- # one kept beside it — and the plain name otherwise. The
+ # The name a listing row shows: "Name (Nickname)" when the card
+ # carries a NICKNAME — the formal name, the one someone is
+ # known by kept beside it — and the plain name otherwise. The
# composition is the listing screens', not Contact's: the card
# holds the two facts independently, and other screens (the
# detail card, the birthdays column) show the plain name.
@@ -17,7 +17,7 @@ module ProTacts
def self.name_label(contact)
nickname = contact.nickname
name = contact.name
- return "#{nickname} (#{name})" if nickname && name
+ return "#{name} (#{nickname})" if nickname && name
nickname || name || contact.id
end
diff --git a/test/pro_tacts/admin/test_contacts_pages.rb b/test/pro_tacts/admin/test_contacts_pages.rb
index 3ecf297..68c5282 100644
--- a/test/pro_tacts/admin/test_contacts_pages.rb
+++ b/test/pro_tacts/admin/test_contacts_pages.rb
@@ -69,16 +69,16 @@ class AdminContactsPagesTest < Minitest::Test
end
end
- # A card with a NICKNAME lists as "Nickname (Name)" — the name
- # someone is known by, the formal one kept beside it. The plain-name
+ # A card with a NICKNAME lists as "Name (Nickname)" — the formal
+ # name with the one someone is known by beside it. The plain-name
# row is what every other index test already shows.
- def test_index_lists_a_nicknamed_contact_as_nickname_and_name
+ def test_index_lists_a_nicknamed_contact_as_name_and_nickname
red = ADA.sub("FN:Ada Lovelace", "FN:Sarah\r\nNICKNAME:Red").sub("UID:ada", "UID:red")
with_contacts({"red" => red}) do
get "/"
- assert_includes last_response.body, "Red (Sarah)"
+ assert_includes last_response.body, "Sarah (Red)"
end
end
@@ -113,13 +113,13 @@ class AdminContactsPagesTest < Minitest::Test
# The row shows the same composition the dashboard's rows do
# (Format.name_label).
- def test_contacts_lists_a_nicknamed_contact_as_nickname_and_name
+ def test_contacts_lists_a_nicknamed_contact_as_name_and_nickname
red = ADA.sub("FN:Ada Lovelace", "FN:Sarah\r\nNICKNAME:Red").sub("UID:ada", "UID:red")
with_contacts({"red" => red}) do
get "/contacts"
- assert_includes last_response.body, "Red (Sarah)"
+ assert_includes last_response.body, "Sarah (Red)"
end
end
@@ -327,7 +327,7 @@ class AdminContactsPagesTest < Minitest::Test
with_contacts({"red" => red}) do
get "/", q: "red"
- assert_includes last_response.body, "Red (Sarah)"
+ assert_includes last_response.body, "Sarah (Red)"
end
end