10 changed files with 36 additions and 220 deletions
@ -1,55 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
class Confirm |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_resume/confirm" |
||||
end |
||||
|
||||
def back_path |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, page: "fix-choice") |
||||
end |
||||
|
||||
def next_path |
||||
resume_bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
|
||||
def error_report_path |
||||
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? |
||||
summary_bulk_upload_lettings_result_path(bulk_upload) |
||||
else |
||||
bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
end |
||||
|
||||
def save! |
||||
ApplicationRecord.transaction do |
||||
processor = BulkUpload::Processor.new(bulk_upload:) |
||||
processor.approve |
||||
|
||||
bulk_upload.update!(choice: "create-fix-inline") |
||||
end |
||||
|
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "create-fix-inline" && bulk_upload.choice != "bulk-confirm-soft-validations" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, :chosen) |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,74 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
class FixChoice |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
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"), |
||||
OpenStruct.new(id: "upload-again", name: "Fix errors in the CSV and upload the file again"), |
||||
] |
||||
end |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_resume/fix_choice" |
||||
end |
||||
|
||||
def next_path |
||||
case choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, page: "confirm") |
||||
when "upload-again" |
||||
error_report_path |
||||
else |
||||
raise "invalid choice" |
||||
end |
||||
end |
||||
|
||||
def error_report_path |
||||
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? |
||||
summary_bulk_upload_lettings_result_path(bulk_upload) |
||||
else |
||||
bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
end |
||||
|
||||
def recommendation |
||||
if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? |
||||
"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." |
||||
else |
||||
"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." |
||||
end |
||||
end |
||||
|
||||
def save! |
||||
bulk_upload.update!(choice:) if choice == "upload-again" |
||||
|
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice.blank? |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, :chosen) |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, :chosen) |
||||
else |
||||
bulk_upload_lettings_result_path(bulk_upload) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,22 +1,23 @@
|
||||
module Forms |
||||
module BulkUploadLettingsResume |
||||
module BulkUploadResume |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :log_type |
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
bulk_upload.completed? ? "bulk_upload_lettings_resume/completed" : "bulk_upload_lettings_resume/chosen" |
||||
bulk_upload.completed? ? "bulk_upload_#{log_type}_resume/completed" : "bulk_upload_#{log_type}_resume/chosen" |
||||
end |
||||
|
||||
def back_path |
||||
lettings_logs_path |
||||
send("#{log_type}_logs_path") |
||||
end |
||||
|
||||
def next_path |
||||
lettings_logs_path |
||||
send("#{log_type}_logs_path") |
||||
end |
||||
|
||||
def save! |
@ -1,31 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesResume |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
bulk_upload.completed? ? "bulk_upload_sales_resume/completed" : "bulk_upload_sales_resume/chosen" |
||||
end |
||||
|
||||
def back_path |
||||
sales_logs_path |
||||
end |
||||
|
||||
def next_path |
||||
sales_logs_path |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
true |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,28 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesResume |
||||
class DeletionReport |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_resume/deletion_report" |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "create-fix-inline" && bulk_upload.choice != "bulk-confirm-soft-validations" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "create-fix-inline" |
||||
page_bulk_upload_sales_resume_path(bulk_upload, :chosen) |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue