Browse Source

Revert "CLDC-1402: Ensure that start date is valid"

This reverts commit 000fe4b369.
CLDC-1402-update-tenancy-start-date-hint-text
Samuel Young 6 days ago
parent
commit
506794ea7f
  1. 9
      app/helpers/collection_time_helper.rb
  2. 7
      app/models/form/lettings/questions/tenancy_start_date.rb
  3. 7
      app/models/form/question.rb
  4. 2
      app/views/form/_date_question.html.erb

9
app/helpers/collection_time_helper.rb

@ -16,13 +16,10 @@ module CollectionTimeHelper
Time.zone.local(collection_start_year_for_date(date), 4, 1)
end
def date_mid_collection_year(date)
relevant_year = date.nil? ? current_collection_start_year : collection_start_year_for_date(date)
Date.new(relevant_year, 9, 13)
end
def date_mid_collection_year_formatted(date)
date_mid_collection_year(date).to_formatted_s(:govuk_date_number_month)
relevant_year = date.nil? ? current_collection_start_year : collection_start_year_for_date(date)
example_date = Date.new(relevant_year, 9, 13)
example_date.to_formatted_s(:govuk_date_number_month)
end
def current_collection_start_date

7
app/models/form/lettings/questions/tenancy_start_date.rb

@ -1,6 +1,4 @@
class Form::Lettings::Questions::TenancyStartDate < ::Form::Question
include CollectionTimeHelper
def initialize(id, hsh, page)
super
@id = "startdate"
@ -9,10 +7,5 @@ class Form::Lettings::Questions::TenancyStartDate < ::Form::Question
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?
end
def example_date_formatted(log)
example_date = [date_mid_collection_year(log.startdate), Time.zone.today + 7].min
example_date.to_formatted_s(:govuk_date_number_month)
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 5, 2024 => 7 }.freeze
end

7
app/models/form/question.rb

@ -1,6 +1,5 @@
class Form::Question
include FormattingHelper
include CollectionTimeHelper
attr_accessor :id, :description, :questions, :disable_clearing_if_not_routed_or_dynamic_answer_options,
:type, :min, :max, :step, :width, :fields_to_add, :result_field,
@ -300,12 +299,6 @@ class Form::Question
answer_options.keys.reject { |x| x.match(/divider/) }
end
def example_date_formatted(log)
if type == "date"
date_mid_collection_year_formatted(log.startdate)
end
end
private
def selected_answer_option_is_derived?(log)

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

@ -6,7 +6,7 @@
question_id: question.id,
legend: { text: legend[:text], size: legend[:size], caption: caption(caption_text, page_header, conditional) },
resource_type: @log.log_type,
hint: (question.hint_text.blank? ? "" : (question.hint_text.html_safe + "</br></br>".html_safe)) + "For example, #{question.example_date_formatted(@log).tr(' ', '/')}",
hint: (question.hint_text.blank? ? "" : (question.hint_text.html_safe + "</br></br>".html_safe)) + "For example, #{date_mid_collection_year_formatted(@log.startdate).tr(' ', '/')}",
f:,
} %>

Loading…
Cancel
Save