Skip to content

Commit

Permalink
Assessment Only spreadsheet upload (#4269)
Browse files Browse the repository at this point in the history
* work in progress

* linting

* add spec test

* add extension, ensure Non-UK sorted correctly

* spec fixes

* wip

* more wip

* handle international numbers and improve handling of missing regions

* Reorder regions so national comes before non-uk

* tweak formatting of extension

* Tweak order of National; regenerate list
  • Loading branch information
martyn-w authored Nov 21, 2024
1 parent ae63a28 commit 26d0330
Show file tree
Hide file tree
Showing 10 changed files with 1,049 additions and 438 deletions.
2 changes: 1 addition & 1 deletion app/components/grouped_cards/card_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<% for field, value in fields %>
<div class="group__card__fields">
<span><%= field.humanize %>:</span>
<span><%= linked_value(value) %></span>
<%= linked_value(field, value) %>
</div>
<% end %>
</div>
Expand Down
23 changes: 20 additions & 3 deletions app/components/grouped_cards/card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,28 @@ def linked_header
end

def fields
@data.without("header", "link", "status")
@data.without("header", "link", "status", "extension", "international_phone")
end

def linked_value(value)
Rinku.auto_link(h(value)).html_safe
def linked_value(field, value)
tags = []

if field == "telephone" && value.present?
tags << if @data["international_phone"].present?
# Although we present the national telephone number, we need to use the
# international_phone value in the URL to support overseas visitors
tag.span { link_to(value, "tel:#{@data['international_phone']}") }
else
tag.span { link_to(value, "tel:#{value}") }
end
# add extension here
if @data["extension"].present?
tags << tag.span(class: "extension") { @data["extension"] }
end
else
tags << tag.span { Rinku.auto_link(h(value)).html_safe }
end
safe_join tags
end

def link
Expand Down
Loading

0 comments on commit 26d0330

Please sign in to comment.