Browse Source

Update action href links

pull/1584/head
Kat 3 years ago
parent
commit
8d5f7a035b
  1. 2
      app/components/check_answers_summary_list_card_component.html.erb
  2. 4
      app/components/check_answers_summary_list_card_component.rb
  3. 5
      app/helpers/form_page_helper.rb
  4. 4
      app/helpers/interruption_screen_helper.rb
  5. 8
      app/models/form/question.rb
  6. 2
      app/views/form/_check_answers_summary_list.html.erb
  7. 2
      app/views/form/_interruption_screen_question.html.erb
  8. 2
      spec/models/form/question_spec.rb

2
app/components/check_answers_summary_list_card_component.html.erb

@ -36,7 +36,7 @@
<% if @log.collection_period_open? %>
<% row.action(
text: question.action_text(log),
href: question.action_href(log, question.page.id),
href: action_href(log, question.page.id),
visually_hidden_text: question.check_answer_label.to_s.downcase,
) %>
<% end %>

4
app/components/check_answers_summary_list_card_component.rb

@ -28,6 +28,10 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
"Person #{question.check_answers_card_number}"
end
def action_href(log, page_id)
send("#{log.model_name.param_key}_#{page_id}_path", log, referrer: "check_answers")
end
private
def unanswered_value

5
app/helpers/form_page_helper.rb

@ -0,0 +1,5 @@
module FormPageHelper
def action_href(log, page_id)
send("#{log.model_name.param_key}_#{page_id}_path", log, referrer: "check_answers")
end
end

4
app/helpers/interruption_screen_helper.rb

@ -33,6 +33,10 @@ module InterruptionScreenHelper
question.page.affected_question_ids.map { |question_id| log.form.get_question(question_id, log) }
end
def interruption_action_href(log, page_id, current_page_id)
send("#{log.model_name.param_key}_#{page_id}_path", log, referrer: current_page_id)
end
private
def get_value_from_argument(log, argument)

8
app/models/form/question.rb

@ -120,14 +120,6 @@ class Form::Question
end
end
def action_href(log, page_id)
"/#{log.model_name.param_key.dasherize}s/#{log.id}/#{page_id.to_s.dasherize}?referrer=check_answers"
end
def interruption_action_href(log, page_id, current_page_id)
"/#{log.model_name.param_key.dasherize}s/#{log.id}/#{page_id.to_s.dasherize}?referrer=#{current_page_id}"
end
def unanswered?(log)
return answer_options.keys.none? { |key| value_is_yes?(log[key]) } if type == "checkbox"

2
app/views/form/_check_answers_summary_list.html.erb

@ -23,7 +23,7 @@
<% if @log.collection_period_open? %>
<% row.action(
text: question.action_text(@log),
href: question.action_href(@log, question.page.id),
href: action_href(@log, question.page.id),
visually_hidden_text: question.check_answer_label.to_s.downcase,
) %>
<% end %>

2
app/views/form/_interruption_screen_question.html.erb

@ -38,7 +38,7 @@
<% if @log.collection_period_open? %>
<% row.action(
text: affected_question.action_text(@log),
href: affected_question.interruption_action_href(@log, affected_question.page.id, question.page.id),
href: interruption_action_href(@log, affected_question.page.id, question.page.id),
visually_hidden_text: affected_question.check_answer_label.to_s.downcase,
) %>
<% end %>

2
spec/models/form/question_spec.rb

@ -259,7 +259,7 @@ RSpec.describe Form::Question, type: :model do
it "has an update answer link href helper" do
lettings_log.id = 1
expect(question.action_href(lettings_log, page.id)).to eq("/lettings-logs/1/net-income?referrer=check_answers")
expect(action_href(lettings_log, page.id)).to eq("/lettings-logs/1/net-income?referrer=check_answers")
end
context "when the question has an inferred answer" do

Loading…
Cancel
Save