|
|
|
@ -10,7 +10,7 @@ class CaseLogValidator < ActiveModel::Validator
|
|
|
|
|
# If we've come from the form UI we only want to validate the specific fields |
|
|
|
|
# that have just been submitted. If we're submitting a log via API or Bulk Upload |
|
|
|
|
# we want to validate all data fields. |
|
|
|
|
page_to_validate = options[:page] |
|
|
|
|
page_to_validate = record.page |
|
|
|
|
if page_to_validate |
|
|
|
|
public_send("validate_#{page_to_validate}", record) if respond_to?("validate_#{page_to_validate}") |
|
|
|
|
else |
|
|
|
@ -41,7 +41,7 @@ class CaseLog < ApplicationRecord
|
|
|
|
|
default_scope -> { kept } |
|
|
|
|
scope :not_completed, -> { where.not(status: "completed") } |
|
|
|
|
|
|
|
|
|
validates_with CaseLogValidator, ({ page: @page } || {}) |
|
|
|
|
validates_with CaseLogValidator |
|
|
|
|
before_save :update_status! |
|
|
|
|
|
|
|
|
|
attr_accessor :page |
|
|
|
|