You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
2 years ago
|
module Forms
|
||
1 week ago
|
module BulkUploadForm
|
||
2 years ago
|
class Year
|
||
|
include ActiveModel::Model
|
||
|
include ActiveModel::Attributes
|
||
|
include Rails.application.routes.url_helpers
|
||
|
|
||
1 week ago
|
attribute :log_type
|
||
2 years ago
|
attribute :year, :integer
|
||
3 months ago
|
attribute :organisation_id, :integer
|
||
2 years ago
|
|
||
|
validates :year, presence: true
|
||
|
|
||
|
def view_path
|
||
1 week ago
|
"bulk_upload_#{log_type}_logs/forms/year"
|
||
2 years ago
|
end
|
||
|
|
||
|
def options
|
||
|
possible_years.map do |year|
|
||
2 months ago
|
OpenStruct.new(id: year, name: "#{year} to #{year + 1}")
|
||
2 years ago
|
end
|
||
|
end
|
||
|
|
||
|
def back_path
|
||
3 months ago
|
if organisation_id.present?
|
||
1 week ago
|
send("#{log_type}_logs_organisation_path", organisation_id)
|
||
3 months ago
|
else
|
||
1 week ago
|
send("#{log_type}_logs_path")
|
||
3 months ago
|
end
|
||
2 years ago
|
end
|
||
|
|
||
|
def next_path
|
||
1 week ago
|
send("bulk_upload_#{log_type}_log_path", id: "prepare-your-file", form: { year:, organisation_id: }.compact)
|
||
2 years ago
|
end
|
||
|
|
||
2 years ago
|
def save!
|
||
|
true
|
||
|
end
|
||
|
|
||
2 years ago
|
private
|
||
|
|
||
|
def possible_years
|
||
2 years ago
|
[
|
||
1 week ago
|
FormHandler.instance.send("#{log_type}_forms")["current_#{log_type}"].start_date.year,
|
||
|
(FormHandler.instance.send("previous_#{log_type}_form").start_date.year if FormHandler.instance.send("#{log_type}_in_crossover_period?")),
|
||
|
(FormHandler.instance.send("next_#{log_type}_form").start_date.year if FeatureToggle.allow_future_form_use?),
|
||
10 months ago
|
].compact
|
||
2 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|