Skip to content

Commit

Permalink
Merge pull request #132 from epimorphics/issue/120-improve-error-sugg…
Browse files Browse the repository at this point in the history
…estion

Issue/120 improve error suggestion
  • Loading branch information
DanielCouzens authored Aug 21, 2024
2 parents 0d0db54 + c63de7f commit e757a2e
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.5.3 - 2024-08

- (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
Expand Down
13 changes: 0 additions & 13 deletions app/models/step_select_postcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions app/models/step_select_postcode_area.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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&quot".html_safe)
end
end
end
14 changes: 14 additions & 0 deletions app/models/step_select_postcode_district.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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&quot".html_safe)
end
end
end
14 changes: 14 additions & 0 deletions app/models/step_select_postcode_sector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/views/report_design/select_pc_district.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit e757a2e

Please sign in to comment.