diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index c257498..e20f591 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -123,6 +123,6 @@ def ensure_group_manager
end
def group_params
- params.require(:group).permit(:name, :description, :privacy, :focus, :reading_list)
+ params.require(:group).permit(:name, :description, :privacy, :plan, :focus, :reading_list)
end
end
diff --git a/app/models/group.rb b/app/models/group.rb
index f4e12c6..add064a 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -91,6 +91,21 @@ def starting_location
{ translation: "kjv", book: first_red.book.downcase, chapter: first_red.number }
end
+ # What the study reads, as the one choice the form offers: "bible",
+ # "red" (Highlighted in Red, chapter by chapter), or a reading list.
+ def plan
+ reading_list.presence || focus
+ end
+
+ def plan=(value)
+ if FOCUSES.key?(value.to_s.to_sym)
+ self.focus = value
+ self.reading_list = nil
+ else
+ self.reading_list = value
+ end
+ end
+
# The passages on the study's list, in the order the list presents
# them. Empty for a study with no list.
def passages
diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb
index 1ec6884..4d96325 100644
--- a/app/views/groups/_form.html.erb
+++ b/app/views/groups/_form.html.erb
@@ -37,28 +37,21 @@
<% end %>
-
- <%= t("groups.focus.label") %>
- <% Group::FOCUSES.each_key do |key| %>
-
- <%= f.radio_button :focus, key, class: radio_classes %>
- <%= t("groups.focus.#{key}") %>
-
- <% end %>
- <%= t("groups.focus.hint") %>
-
-
+ <%# One choice for what the study reads: the whole Bible, Highlighted
+ in Red chapter by chapter, or one of the lists or themes read a
+ passage at a time. %>
- <%= f.label :reading_list, t("groups.reading_list.label"), class: label_classes %>
- <%= f.select :reading_list,
+ <%= f.label :plan, t("groups.focus.label"), class: label_classes %>
+ <%= f.select :plan,
+ options_for_select([ [ t("groups.plan.bible"), "bible" ], [ t("groups.plan.red"), "red" ] ], group.plan) +
grouped_options_for_select(
{ t("groups.reading_list.lists_group") => Bible::Passages::COLLECTIONS.keys.map { |list| [ t("red.#{list}.title"), list ] },
t("groups.reading_list.themes_group") => Bible::Themes.all.map { |theme| [ theme.name, "#{Group::THEME_PREFIX}#{theme.slug}" ] } },
- group.reading_list
+ group.plan
),
- { include_blank: t("groups.reading_list.none") },
+ {},
class: "#{input_classes} [&_option]:bg-surface-50 [&_option]:text-surface-900" %>
-
<%= t("groups.reading_list.hint") %>
+
<%= t("groups.plan.hint") %>
diff --git a/app/views/groups/bible/show.html.erb b/app/views/groups/bible/show.html.erb
index 8d0e92a..86be44a 100644
--- a/app/views/groups/bible/show.html.erb
+++ b/app/views/groups/bible/show.html.erb
@@ -22,9 +22,13 @@
-
- <%= @translation.name %>
-
+ <%# On a passage page the translation is named beside the
+ reference, under the title. %>
+ <% unless @passage %>
+
+ <%= @translation.name %>
+
+ <% end %>
<% if @passage %>
<% if @appearances.size > 1 %>
" class="passage-tellings flex flex-wrap items-center gap-1 font-ui text-sm">
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 34131cf..5e6736a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -379,15 +379,14 @@ en:
open_group: Open
focus:
label: What this study reads
- bible: The whole Bible
red: Highlighted in Red
- hint: A study of Highlighted in Red reads Jesus's words, chapter by chapter, with the story around them dimmed.
+ plan:
+ bible: The whole Bible
+ red: Highlighted in Red, chapter by chapter
+ hint: Highlighted in Red reads Jesus's words with the story around them dimmed. Pick a list or a theme to read one passage at a time, with a marker for where the study is.
reading_list:
- label: Work through a list
- none: No list. Read chapter by chapter
- lists_group: Lists
- themes_group: Themes
- hint: Optional. The study reads one passage at a time, and a manager marks where you are. Choosing a list makes this a Highlighted in Red study.
+ lists_group: One passage at a time
+ themes_group: A theme, one passage at a time
working_through: "Working through: %{list}"
intro: Read one passage at a time. A manager marks where the study is.
open_current: "Open: %{title}"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 5e04e69..1f6495b 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -372,15 +372,14 @@ es:
open_group: Abierto
focus:
label: Qué lee este estudio
- bible: Toda la Biblia
red: En Rojo
- hint: Un estudio de En Rojo lee las palabras de Jesús, capítulo por capítulo, con el relato que las rodea atenuado.
+ plan:
+ bible: Toda la Biblia
+ red: En Rojo, capítulo por capítulo
+ hint: En Rojo lee las palabras de Jesús con el relato que las rodea atenuado. Elige una lista o un tema para leer un pasaje a la vez, con una marca de por dónde va el estudio.
reading_list:
- label: Recorrer una lista
- none: Sin lista. Leer capítulo por capítulo
- lists_group: Listas
- themes_group: Temas
- hint: Opcional. El estudio lee un pasaje a la vez, y un administrador marca por dónde van. Al elegir una lista, este será un estudio de En Rojo.
+ lists_group: Un pasaje a la vez
+ themes_group: Un tema, un pasaje a la vez
working_through: "Recorriendo: %{list}"
intro: Lean un pasaje a la vez. Un administrador marca por dónde va el estudio.
open_current: "Abrir: %{title}"
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index cb52242..37fb8f0 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -102,6 +102,25 @@
expect(group).to be_focus_red
end
+ it "is chosen through one plan: the whole Bible, red chapters, a list or a theme" do
+ expect(build(:group).plan).to eq("bible")
+ expect(build(:group, focus: :red).plan).to eq("red")
+ expect(build(:group, reading_list: "parables").plan).to eq("parables")
+
+ group = create(:group, plan: "theme:forgiveness")
+ expect([ group.focus, group.reading_list ]).to eq([ "red", "theme:forgiveness" ])
+
+ group.update!(plan: "red")
+ expect([ group.focus, group.reading_list ]).to eq([ "red", nil ])
+
+ group.update!(plan: "bible")
+ expect([ group.focus, group.reading_list ]).to eq([ "bible", nil ])
+ end
+
+ it "rejects a plan that does not exist" do
+ expect(build(:group, plan: "miracles")).not_to be_valid
+ end
+
it "treats a blank list as none" do
expect(create(:group, reading_list: "").reading_list).to be_nil
end
diff --git a/spec/requests/study_focus_spec.rb b/spec/requests/study_focus_spec.rb
index f37fd69..d21bd1f 100644
--- a/spec/requests/study_focus_spec.rb
+++ b/spec/requests/study_focus_spec.rb
@@ -92,7 +92,8 @@ def verse!(book, chapter_number, number, text, red: nil)
it "is offered when starting a study and saved" do
get "/studies/new"
- expect(response.body).to include(I18n.t("groups.focus.red"))
+ options = Nokogiri::HTML(response.body).css("select[name='group[plan]'] option").map { |o| o[:value] }
+ expect(options.first(2)).to eq(%w[bible red])
post "/studies", params: { group: { name: "Red letters", privacy: "invite_only", focus: "red" } }
expect(Group.find_by!(name: "Red letters")).to be_focus_red
diff --git a/spec/requests/study_reading_lists_spec.rb b/spec/requests/study_reading_lists_spec.rb
index 048524e..163c145 100644
--- a/spec/requests/study_reading_lists_spec.rb
+++ b/spec/requests/study_reading_lists_spec.rb
@@ -30,11 +30,32 @@ def verse!(book, chapter_number, number, text, red: true)
end
describe "starting one" do
- it "offers the lists and themes on the new-study form" do
+ it "offers everything a study can read in one control on the new-study form" do
get "/studies/new"
- options = Nokogiri::HTML(response.body).css("select[name='group[reading_list]'] option").map { |o| o[:value] }
- expect(options).to include("", "parables", "encounters", "sayings", "theme:forgiveness")
+ page = Nokogiri::HTML(response.body)
+ options = page.css("select[name='group[plan]'] option").map { |o| o[:value] }
+ expect(options).to include("bible", "red", "parables", "encounters", "sayings", "theme:forgiveness")
+ expect(page.at_css("select[name='group[reading_list]']")).to be_nil
+ expect(page.at_css("input[name='group[focus]']")).to be_nil
+ end
+
+ it "starts a list study from that one control" do
+ post "/studies", params: { group: { name: "Sayings", privacy: "invite_only", plan: "sayings" } }
+
+ group = Group.find_by!(name: "Sayings")
+ expect([ group.focus, group.reading_list ]).to eq(%w[red sayings])
+ end
+
+ it "shows the study's current choice when editing, and can change it" do
+ group = create(:group, owner: owner, reading_list: "parables")
+
+ get "/studies/#{group.id}/edit"
+ selected = Nokogiri::HTML(response.body).at_css("select[name='group[plan]'] option[selected]")
+ expect(selected[:value]).to eq("parables")
+
+ patch "/studies/#{group.id}", params: { group: { plan: "red" } }
+ expect([ group.reload.focus, group.reading_list ]).to eq([ "red", nil ])
end
it "saves the list and makes it a red study" do
@@ -94,6 +115,7 @@ def verse!(book, chapter_number, number, text, red: true)
expect(response).to have_http_status(:ok)
page = Nokogiri::HTML(response.body)
+ expect(page.at_css("article header").text.scan(kjv.name).size).to eq(1)
expect(page.at_css("h1").text).to include("The Sower")
expect(page.css(".chapter-body .verse").map { |v| v["data-osis-ref"] })
.to eq((3..9).map { |n| "Bible.KJV.Matt.13.#{n}" })
diff --git a/spec/system/study_focus_spec.rb b/spec/system/study_focus_spec.rb
index 8d83f78..7649bc0 100644
--- a/spec/system/study_focus_spec.rb
+++ b/spec/system/study_focus_spec.rb
@@ -41,7 +41,7 @@ def verse!(book, chapter_number, number, text, red: nil)
visit "/studies/new"
fill_in "Name", with: "Red letters"
find("input[value='invite_only']").click
- choose I18n.t("groups.focus.red")
+ select I18n.t("groups.plan.red"), from: I18n.t("groups.focus.label")
find('input[type="submit"]').click
expect(page).to have_content(/red letters/i)
diff --git a/spec/system/study_reading_lists_spec.rb b/spec/system/study_reading_lists_spec.rb
index d0a8764..27bb0d6 100644
--- a/spec/system/study_reading_lists_spec.rb
+++ b/spec/system/study_reading_lists_spec.rb
@@ -23,7 +23,7 @@ def verse!(book, chapter_number, number, text, red: true)
visit "/studies/new"
fill_in "Name", with: "Parables together"
find("input[value='invite_only']").click
- select I18n.t("red.parables.title"), from: I18n.t("groups.reading_list.label")
+ select I18n.t("red.parables.title"), from: I18n.t("groups.focus.label")
find('input[type="submit"]').click
expect(page).to have_content(/parables together/i)