diff --git a/README.md b/README.md index ab098aa84..c1afaf7f5 100644 --- a/README.md +++ b/README.md @@ -163,7 +163,10 @@ Assumptions made by the format: ## JSON Form Validation against Schema To validate the form JSON against the schema you can run: -`rake form_definition:validate["config/forms/2021_22.json"]` +`rake form_definition:validate["config/forms/2021_2022.json"]` + +n.b. You may have to escape square brackets in zsh +`rake form_definition:validate\["config/forms/2021_2022.json"\]` This will validate the given form definition against the schema in `config/forms/schema/generic.json`. diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index 8eb60af6a..1f6936520 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -107,6 +107,8 @@ private day = params["case_log"]["#{question_key}(3i)"] month = params["case_log"]["#{question_key}(2i)"] year = params["case_log"]["#{question_key}(1i)"] + next unless day.present? && month.present? && year.present? + result[question_key] = Date.new(year.to_i, month.to_i, day.to_i) end next unless question_params diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 1cc1bc65e..6282f9d06 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -60,6 +60,8 @@ module CheckAnswersHelper case_log[question_key].blank? || !condition.include?(case_log[question_key]) when "radio" case_log[question_key].blank? || !condition.include?(case_log[question_key]) + when "select" + case_log[question_key].blank? || !condition.include?(case_log[question_key]) else raise "Not implemented yet" end diff --git a/app/javascript/controllers/soft_validations_controller.js b/app/javascript/controllers/soft_validations_controller.js index a408e4460..2c223ce1c 100644 --- a/app/javascript/controllers/soft_validations_controller.js +++ b/app/javascript/controllers/soft_validations_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { initialize() { let url = window.location.href + "/soft_validations" - this.fetch_retry(url, { headers: { accept: "application/json" } }, 2) + this.fetch_retry(url, { headers: { accept: "application/json" } }, 5) } fetch_retry(url, options, n) { diff --git a/app/javascript/styles/_task-list.scss b/app/javascript/styles/_task-list.scss index 755836e3f..603a6d55c 100644 --- a/app/javascript/styles/_task-list.scss +++ b/app/javascript/styles/_task-list.scss @@ -81,11 +81,6 @@ } } -// turbo-frame { -// display: block; -// border: 1px solid blue -// } - .app-task-list__item:target, .tasklist_item_highlight{ background-color: $govuk-focus-colour; diff --git a/app/javascript/styles/application.scss b/app/javascript/styles/application.scss index 4caf03bda..7e1158bd7 100644 --- a/app/javascript/styles/application.scss +++ b/app/javascript/styles/application.scss @@ -11,4 +11,11 @@ $govuk-image-url-function: frontend-image-url; @import "~govuk-frontend/govuk/all"; -@import '_task-list' +@import '_task-list'; + +$govuk-global-styles: true; + +// turbo-frame { +// display: block; +// border: 1px solid blue +// } diff --git a/app/models/case_log.rb b/app/models/case_log.rb index f373745fd..718e3fda2 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -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 diff --git a/app/views/case_logs/_log_list.html.erb b/app/views/case_logs/_log_list.html.erb index 3edfabe06..c0f856f09 100644 --- a/app/views/case_logs/_log_list.html.erb +++ b/app/views/case_logs/_log_list.html.erb @@ -12,7 +12,7 @@ <% case_logs.map do |log| %>
You've completed <%= get_subsections_count(@form, @case_log, :completed) %> of <%= get_subsections_count(@form, @case_log, :all) %> sections.