From b807010800ad08d7e2388cded932a04d4f2b99f3 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Tue, 20 Aug 2024 16:33:33 +0100 Subject: [PATCH 1/5] pc area type error message --- app/helpers/report_design_helper.rb | 2 +- app/views/report_design/select_pc_area.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/report_design_helper.rb b/app/helpers/report_design_helper.rb index c9a9130..509c100 100644 --- a/app/helpers/report_design_helper.rb +++ b/app/helpers/report_design_helper.rb @@ -2,7 +2,7 @@ # :nodoc: module ReportDesignHelper # rubocop:disable Metrics/ModuleLength - def workflow_step_form(workflow) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize + def workflow_step_form(workflow, pc_type) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize step = workflow.current_step form_tag(workflow.form_action, method: 'get') do diff --git a/app/views/report_design/select_pc_area.html.haml b/app/views/report_design/select_pc_area.html.haml index 2c976e9..cd54ebe 100644 --- a/app/views/report_design/select_pc_area.html.haml +++ b/app/views/report_design/select_pc_area.html.haml @@ -12,4 +12,4 @@ the first one or two letters of a UK postcode, for example "B" or "TA" - = workflow_step_form( @workflow ) + = workflow_step_form( @workflow, "pc_area" ) From 2abb14a53b38fdd16f0f654e9089ba1d0f7ddf70 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Wed, 21 Aug 2024 09:33:05 +0100 Subject: [PATCH 2/5] updates postcode error messages --- app/helpers/report_design_helper.rb | 2 +- app/models/step_select_postcode.rb | 13 ------------- app/models/step_select_postcode_area.rb | 14 ++++++++++++++ app/models/step_select_postcode_district.rb | 14 ++++++++++++++ app/models/step_select_postcode_sector.rb | 14 ++++++++++++++ app/views/report_design/select_pc_area.html.haml | 2 +- .../report_design/select_pc_district.html.haml | 2 +- 7 files changed, 45 insertions(+), 16 deletions(-) diff --git a/app/helpers/report_design_helper.rb b/app/helpers/report_design_helper.rb index 509c100..c9a9130 100644 --- a/app/helpers/report_design_helper.rb +++ b/app/helpers/report_design_helper.rb @@ -2,7 +2,7 @@ # :nodoc: module ReportDesignHelper # rubocop:disable Metrics/ModuleLength - def workflow_step_form(workflow, pc_type) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize + def workflow_step_form(workflow) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize step = workflow.current_step form_tag(workflow.form_action, method: 'get') do diff --git a/app/models/step_select_postcode.rb b/app/models/step_select_postcode.rb index 630c646..f6f2861 100644 --- a/app/models/step_select_postcode.rb +++ b/app/models/step_select_postcode.rb @@ -15,19 +15,6 @@ def traverse(workflow) end end - def validate_with(workflow, value) - validated_value = validate(value) - - if validated_value - workflow.set_state(param_name, validated_value) - workflow_update_hook(workflow) - workflow.traverse_to(successor_step) - else - set_flash("Sorry, '#{value}' does not appear to be a valid value for a #{subtype_label}. - Perhaps there's a typo or too many characters or maybe an extra space somewhere?") - end - end - def validate(value) normalized_value = value.upcase normalized_value =~ validation_pattern && normalized_value diff --git a/app/models/step_select_postcode_area.rb b/app/models/step_select_postcode_area.rb index a001158..7f66ba7 100644 --- a/app/models/step_select_postcode_area.rb +++ b/app/models/step_select_postcode_area.rb @@ -23,4 +23,18 @@ def validation_pattern def input_label 'Enter postcode area:' end + + def validate_with(workflow, value) + validated_value = validate(value) + + if validated_value + workflow.set_state(param_name, validated_value) + workflow_update_hook(workflow) + workflow.traverse_to(successor_step) + else + set_flash("Sorry, '#{value}' does not appear to be a valid value for a #{subtype_label}. + A #{subtype_label} is the first one or two letters of a UK postcode, for example "B" + or "TA"".html_safe) + end + end end diff --git a/app/models/step_select_postcode_district.rb b/app/models/step_select_postcode_district.rb index 066d331..d6b1548 100644 --- a/app/models/step_select_postcode_district.rb +++ b/app/models/step_select_postcode_district.rb @@ -23,4 +23,18 @@ def validation_pattern def input_label 'Enter postcode district:' end + + def validate_with(workflow, value) + validated_value = validate(value) + + if validated_value + workflow.set_state(param_name, validated_value) + workflow_update_hook(workflow) + workflow.traverse_to(successor_step) + else + set_flash("Sorry, '#{value}' does not appear to be a valid value for a #{subtype_label}. + A #{subtype_label} is the first part of a UK postcode, up to the space. For example + "B17" or "TA9"".html_safe) + end + end end diff --git a/app/models/step_select_postcode_sector.rb b/app/models/step_select_postcode_sector.rb index 461d537..d62c9b2 100644 --- a/app/models/step_select_postcode_sector.rb +++ b/app/models/step_select_postcode_sector.rb @@ -27,4 +27,18 @@ def input_label def successor_step :select_aggregation_type end + + def validate_with(workflow, value) + validated_value = validate(value) + + if validated_value + workflow.set_state(param_name, validated_value) + workflow_update_hook(workflow) + workflow.traverse_to(successor_step) + else + set_flash("Sorry, '#{value}' does not appear to be a valid value for a #{subtype_label}. + A #{subtype_label} is the first part of a UK postcode, up to and including the first + digit after the space. For example "B17 0" or "TA9 3"".html_safe) + end + end end diff --git a/app/views/report_design/select_pc_area.html.haml b/app/views/report_design/select_pc_area.html.haml index cd54ebe..41f0d43 100644 --- a/app/views/report_design/select_pc_area.html.haml +++ b/app/views/report_design/select_pc_area.html.haml @@ -12,4 +12,4 @@ the first one or two letters of a UK postcode, for example "B" or "TA" - = workflow_step_form( @workflow, "pc_area" ) + = workflow_step_form( @workflow) diff --git a/app/views/report_design/select_pc_district.html.haml b/app/views/report_design/select_pc_district.html.haml index bdb0a73..9fdadce 100644 --- a/app/views/report_design/select_pc_district.html.haml +++ b/app/views/report_design/select_pc_district.html.haml @@ -8,7 +8,7 @@ Select a postcode district %p - Choose which postcode district the report should cover. A postcode area is + Choose which postcode district the report should cover. A postcode district is the first part of a UK postcode, up to the space. For example "B17" or "TA9" From 3f396c523f97b1f2e6e55bee447b809df9146b35 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Wed, 21 Aug 2024 09:34:19 +0100 Subject: [PATCH 3/5] updates changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84eb542..1feb089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.5.3 - 2024-08 +- (Dan) Update the error messages for the postcode selectors step 3/7 os each error message is unique [120](https://github.com/epimorphics/standard-reports-ui/issues/120) - (Dan) Updates alt text for screenshots of example reports [115](https://github.com/epimorphics/standard-reports-ui/issues/115) - (Dan) Updates report page styles so links are underlined and gives download report page a seperate page title - (Dan) Updates gemfile to use v1.9.5 lr_common_styles From 667e1e90536a648c110c8e50d108f1b1f5a2bd11 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Wed, 21 Aug 2024 09:44:47 +0100 Subject: [PATCH 4/5] updates changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1feb089..88d6992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.5.3 - 2024-08 -- (Dan) Update the error messages for the postcode selectors step 3/7 os each error message is unique [120](https://github.com/epimorphics/standard-reports-ui/issues/120) +- (Dan) Update the error messages for the postcode selectors step 3/7 so each error message is unique to the postcode selector [120](https://github.com/epimorphics/standard-reports-ui/issues/120) - (Dan) Updates alt text for screenshots of example reports [115](https://github.com/epimorphics/standard-reports-ui/issues/115) - (Dan) Updates report page styles so links are underlined and gives download report page a seperate page title - (Dan) Updates gemfile to use v1.9.5 lr_common_styles From c63de7ff8b6089cabcc2f8462fc8bee77c5a4885 Mon Sep 17 00:00:00 2001 From: Daniel Couzens Date: Wed, 21 Aug 2024 09:47:47 +0100 Subject: [PATCH 5/5] reverts change --- app/views/report_design/select_pc_area.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/report_design/select_pc_area.html.haml b/app/views/report_design/select_pc_area.html.haml index 41f0d43..2c976e9 100644 --- a/app/views/report_design/select_pc_area.html.haml +++ b/app/views/report_design/select_pc_area.html.haml @@ -12,4 +12,4 @@ the first one or two letters of a UK postcode, for example "B" or "TA" - = workflow_step_form( @workflow) + = workflow_step_form( @workflow )