9 changed files with 26 additions and 158 deletions
@ -1,47 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadLettingsSoftValidationsCheck |
||||
class Confirm |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_lettings_soft_validations_check/confirm" |
||||
end |
||||
|
||||
def back_path |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, page: "confirm-soft-errors") |
||||
end |
||||
|
||||
def next_path |
||||
lettings_logs_path |
||||
end |
||||
|
||||
def save! |
||||
ApplicationRecord.transaction do |
||||
processor = BulkUpload::Processor.new(bulk_upload:) |
||||
processor.approve_and_confirm_soft_validations |
||||
|
||||
bulk_upload.update!(choice: "bulk-confirm-soft-validations") |
||||
end |
||||
|
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "bulk-confirm-soft-validations" && bulk_upload.choice != "create-fix-inline" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_lettings_soft_validations_check_path(bulk_upload, :chosen) |
||||
when "create-fix-inline" |
||||
page_bulk_upload_lettings_resume_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,31 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesSoftValidationsCheck |
||||
class Chosen |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_soft_validations_check/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,53 +0,0 @@
|
||||
module Forms |
||||
module BulkUploadSalesSoftValidationsCheck |
||||
class ConfirmSoftErrors |
||||
include ActiveModel::Model |
||||
include ActiveModel::Attributes |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attribute :bulk_upload |
||||
attribute :confirm_soft_errors, :string |
||||
|
||||
validates :confirm_soft_errors, presence: true |
||||
|
||||
def options |
||||
[ |
||||
OpenStruct.new(id: "yes", name: "Yes, these fields are correct"), |
||||
OpenStruct.new(id: "no", name: "No, there are errors"), |
||||
] |
||||
end |
||||
|
||||
def view_path |
||||
"bulk_upload_sales_soft_validations_check/confirm_soft_errors" |
||||
end |
||||
|
||||
def next_path |
||||
case confirm_soft_errors |
||||
when "no" |
||||
page_bulk_upload_sales_resume_path(bulk_upload, page: "fix-choice", soft_errors_only: true) |
||||
when "yes" |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, page: "confirm") |
||||
else |
||||
raise "invalid choice" |
||||
end |
||||
end |
||||
|
||||
def save! |
||||
true |
||||
end |
||||
|
||||
def preflight_valid? |
||||
bulk_upload.choice != "bulk-confirm-soft-validations" && bulk_upload.choice != "create-fix-inline" |
||||
end |
||||
|
||||
def preflight_redirect |
||||
case bulk_upload.choice |
||||
when "bulk-confirm-soft-validations" |
||||
page_bulk_upload_sales_soft_validations_check_path(bulk_upload, :chosen) |
||||
when "create-fix-inline" |
||||
page_bulk_upload_sales_resume_path(bulk_upload, :chosen) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,22 +1,23 @@
|
||||
module Forms |
||||
module BulkUploadLettingsSoftValidationsCheck |
||||
module BulkUploadSoftValidationsCheck |
||||
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_lettings_soft_validations_check/chosen" |
||||
"bulk_upload_#{log_type}_soft_validations_check/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! |
Loading…
Reference in new issue