Show a book's group name as text where its field was
The way back above the form is small, so the name stays on the form,
shown as text rather than offered as a field.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VNdx5qiRSWADBoVfDRcrd
diff --git a/lib/pro_tacts/admin/groups_edit.rb b/lib/pro_tacts/admin/groups_edit.rb
index c9e6e3f..c786354 100644
--- a/lib/pro_tacts/admin/groups_edit.rb
+++ b/lib/pro_tacts/admin/groups_edit.rb
@@ -59,10 +59,15 @@ module ProTacts
# The id as the blank's placeholder, because a group
# with no name is shown as its id everywhere else. A
# book's group keeps its name (Store#rename_group), so
- # it gets no field at all: the way back above already
- # names it, and a save without one keeps the name
+ # the name is shown rather than offered: text where the
+ # field would be, and a save that carries none keeps it
# (Web#apply_group_edit).
- unless @group.sync?
+ if @group.sync?
+ div(class: "field") do
+ span { "Name" }
+ span { @group.name }
+ end
+ else
label(class: "field") do
span { "Name" }
input(type: "text", name: "name", value: @group.name, placeholder: @group.id, autofocus: true)
diff --git a/lib/pro_tacts/web/groups.rb b/lib/pro_tacts/web/groups.rb
index f9472fe..543d6c0 100644
--- a/lib/pro_tacts/web/groups.rb
+++ b/lib/pro_tacts/web/groups.rb
@@ -99,7 +99,7 @@ module ProTacts
end #: Array[String]
# No name at all keeps the one it has, the members' posture
- # above: a book's group renders no name field (Admin::GroupsEdit),
+ # above: a book's group shows its name as text (Admin::GroupsEdit),
# where a blank one is a request to go nameless.
name = r.params.key?("name") ? r.params["name"].to_s : group.name
@@ -111,7 +111,7 @@ module ProTacts
return group_edit_screen(group, notice: "Another group is already named #{r.params['name']}; nothing was saved.")
rescue Store::SyncGroupRename
# A book's group keeps its name (Store#rename_group); the
- # editor renders no field for it, so this is a doctored save.
+ # editor offers no field for it, so this is a doctored save.
return group_edit_screen(group, notice: "The #{group.name} group names a book and keeps its name; nothing was saved.")
end
r.redirect "/groups/#{id}", 303
diff --git a/test/pro_tacts/admin/test_groups_pages.rb b/test/pro_tacts/admin/test_groups_pages.rb
index 7b4924d..e7dea15 100644
--- a/test/pro_tacts/admin/test_groups_pages.rb
+++ b/test/pro_tacts/admin/test_groups_pages.rb
@@ -302,13 +302,14 @@ class AdminGroupsPagesTest < Minitest::Test
end
end
- def test_a_books_group_renders_no_name_field
+ def test_a_books_group_shows_its_name_as_text
with_contacts(BOOLES) do |store|
id = FixtureData.seed_group(store, name: ProTacts::Group::EVERYONE, members: %w[george])
get "/groups/#{id}/edit"
refute_includes last_response.body, %(name="name")
+ assert_includes last_response.body, "<span>Name</span><span>sync:*</span>"
end
end