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.
76 lines
2.4 KiB
76 lines
2.4 KiB
2 years ago
|
module Forms
|
||
4 weeks ago
|
module BulkUploadResume
|
||
2 years ago
|
class FixChoice
|
||
|
include ActiveModel::Model
|
||
|
include ActiveModel::Attributes
|
||
|
include Rails.application.routes.url_helpers
|
||
|
|
||
4 weeks ago
|
attribute :log_type
|
||
2 years ago
|
attribute :bulk_upload
|
||
|
attribute :choice, :string
|
||
|
|
||
|
validates :choice, presence: true,
|
||
|
inclusion: { in: %w[create-fix-inline upload-again] }
|
||
|
|
||
|
def options
|
||
|
[
|
||
|
OpenStruct.new(id: "create-fix-inline", name: "Upload these logs and fix errors on CORE site"),
|
||
1 month ago
|
OpenStruct.new(id: "upload-again", name: "Fix errors in the CSV and upload the file again"),
|
||
2 years ago
|
]
|
||
|
end
|
||
|
|
||
|
def view_path
|
||
4 weeks ago
|
"bulk_upload_#{log_type}_resume/fix_choice"
|
||
2 years ago
|
end
|
||
|
|
||
|
def next_path
|
||
|
case choice
|
||
|
when "create-fix-inline"
|
||
4 weeks ago
|
send("page_bulk_upload_#{log_type}_resume_path", bulk_upload, page: "confirm")
|
||
2 years ago
|
when "upload-again"
|
||
12 months ago
|
error_report_path
|
||
2 years ago
|
else
|
||
|
raise "invalid choice"
|
||
|
end
|
||
|
end
|
||
|
|
||
12 months ago
|
def error_report_path
|
||
|
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors?
|
||
4 weeks ago
|
send("summary_bulk_upload_#{log_type}_result_path", bulk_upload)
|
||
12 months ago
|
else
|
||
4 weeks ago
|
send("bulk_upload_#{log_type}_result_path", bulk_upload)
|
||
12 months ago
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
def recommendation
|
||
|
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors?
|
||
2 years ago
|
"We recommend fixing these errors in the CSV, as you may be able to edit multiple fields at once. However, you can also upload these logs and fix the errors on the CORE site."
|
||
2 years ago
|
else
|
||
2 years ago
|
"We recommend uploading logs and fixing errors on site as you can easily see the questions and select the appropriate answer. However, you can also fix these errors in the CSV."
|
||
2 years ago
|
end
|
||
|
end
|
||
|
|
||
|
def save!
|
||
2 years ago
|
bulk_upload.update!(choice:) if choice == "upload-again"
|
||
|
|
||
2 years ago
|
true
|
||
|
end
|
||
2 years ago
|
|
||
|
def preflight_valid?
|
||
4 months ago
|
bulk_upload.choice.blank?
|
||
2 years ago
|
end
|
||
|
|
||
|
def preflight_redirect
|
||
|
case bulk_upload.choice
|
||
|
when "create-fix-inline"
|
||
4 weeks ago
|
send("page_bulk_upload_#{log_type}_resume_path", bulk_upload, :chosen)
|
||
2 years ago
|
when "bulk-confirm-soft-validations"
|
||
4 weeks ago
|
send("page_bulk_upload_#{log_type}_soft_validations_check_path", bulk_upload, :chosen)
|
||
4 months ago
|
else
|
||
4 weeks ago
|
send("bulk_upload_#{log_type}_result_path", bulk_upload)
|
||
2 years ago
|
end
|
||
|
end
|
||
2 years ago
|
end
|
||
|
end
|
||
|
end
|