Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Contact presentation to Publishing API #4475

Merged
merged 2 commits into from
Nov 8, 2018

Conversation

kevindew
Copy link
Member

@kevindew kevindew commented Nov 6, 2018

Trello: https://trello.com/c/gEAMmD0g/386-ability-to-embed-a-contact-via-markdown

This is marked as DNM as it requires this alphagov/govuk-content-schemas#830 to be deployed.

This resolves a lot of empty data problems with Contacts data in the Publishing API by removing null and empty string values. It also adds in the iso2_country_code field to help with rendering contacts in govspeak correctly: alphagov/govspeak#130

Many of contacts in Publishing API have big chunks of empty data in them
which causes poor rendering.

Example:

```
{:description=>"Email monitored Monday - Friday, 9.00am - 5.00pm",
 :contact_type=>"Media contact",
 :title=>"Press Office (media enquiries)",
 :contact_form_links=>
  [{:title=>"Press Office (media enquiries)", :link=>"", :description=>""}],
 :post_addresses=>
  [{:title=>"",
    :street_address=>"",
    :locality=>"",
    :region=>"",
    :postal_code=>"",
    :world_location=>""}],
 :email_addresses=>[{:title=>"", :email=>"[email protected]  "}],
 :phone_numbers=>
  [{:title=>"Belfast", :number=>"028 9052 7856 "},
   {:title=>"Out of hours duty press officer",
    :number=>"M:  ‭‭+44 ‭+44 7464 981449‬"}]}
```

To resolve this this uses the presence methods on strings or nils to
make them nil and then uses compact to remove them from hashes.

This also removes the title from the contact form as it did not make
sense to duplicate the contact title here (and is not required by the
schema)
This adds the iso2_country_code field for the post_addresses section of
Contacts' details. Field was introduced in: alphagov/govuk-content-schemas#830
@kevindew kevindew requested a review from benthorner November 7, 2018 09:44
Copy link
Contributor

@benthorner benthorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hurray :-).

details[:post_addresses] = [post_address] if postal_code
details[:email_addresses] = [email_address] if email
details = {
title: title,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you changed the schema so these aren't required anymore - just wondering if you meant to remove these now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure what the consequences are of removing them, but am confident they shouldn't be used.

@kevindew kevindew changed the title [DO NOT MERGE] Improve Contact presentation to Publishing API Improve Contact presentation to Publishing API Nov 8, 2018
@kevindew kevindew merged commit ac4be7c into master Nov 8, 2018
@kevindew kevindew deleted the update-contact-rendering branch November 8, 2018 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants