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

Taxonomy email alert signup pages #33

Merged
merged 15 commits into from
Mar 28, 2017
Merged

Conversation

malcolmbaig
Copy link
Contributor

@malcolmbaig malcolmbaig commented Mar 23, 2017

Add the taxonomy email alert signup pages, served from /email-alert.

This PR includes some initial cleaning up of the test suite and dependencies - recommend using this diff to review the actual feature.

https://trello.com/c/lPlSbZnX/166-3-build-3-types-of-sign-up-pages-backend

New sign up (when child taxons present)

screen shot 2017-03-28 at 11 58 28

New sign up (when looking at leaf taxon)

screen shot 2017-03-28 at 12 03 11

Confirm page

screen shot 2017-03-28 at 11 58 44

@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch from 397211a to df7e112 Compare March 24, 2017 17:00
Mo Baig and others added 12 commits March 25, 2017 10:47
- Remove unused @mock-email-alert-api tag.
- Remove manually added lines from support/env.rb - this is a generated
  file and shouldn't be modified.
- Rename the helper that adds GovukContentSchemaExamples to World, more
  accurately reflecting what it does.
- Extract a slimmer helper from env.
Ensure that we can only stub methods that exist on instances of the
GdsApi:EmailAlertApi object.
- Use the verifying instance double of email-alert-api in the existing
  email alert feature.
- Setup a route specific to the test environment to test redirecting to
  govdelivery subscription url.
2.3.1 is the minimum version required by govuk_taxonomy_helpers.
Update frontend toolkit and add elements to bring in necessary sass for checkboxes.
Add show/hide content javascript and show and hide form submits.
Includes addition of 'Get email alerts' to breadcrumb and refactoring of
the TaxonomySignupsController.
Stops sporadic failures caused by network requests to static.
@carolinegreen carolinegreen force-pushed the mb-taxonomy-email-signup branch from efa23f8 to 3259a2d Compare March 26, 2017 20:38
@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch from 3259a2d to 272524f Compare March 26, 2017 21:16
@carolinegreen carolinegreen force-pushed the mb-taxonomy-email-signup branch from 17f6d14 to 496395a Compare March 27, 2017 06:59
@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch 2 times, most recently from 745c1c1 to d9c455c Compare March 27, 2017 12:49
@malcolmbaig malcolmbaig changed the title [DO NOT MERGE] [WIP] taxonomy email signup Taxonomy email alert signup Mar 27, 2017
@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch 3 times, most recently from 09319a5 to b15d158 Compare March 27, 2017 13:05
@malcolmbaig malcolmbaig changed the title Taxonomy email alert signup Taxonomy email alert signup pages Mar 27, 2017
Copy link
Contributor

@dwhenry dwhenry left a comment

Choose a reason for hiding this comment

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

Some of the pages don't have a blank line at the bottom of them which would be good to add from a consistency point of view if your keen. :)

@@ -15,3 +17,5 @@
margin: 20px 0;
}
}

@import "taxonomy-signup"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is duplicated from line 5 above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed.

def confirm
redirect_to '/' and return unless params[:'taxon-list'].present?

taxon_path = params[:'taxon-list']
Copy link
Contributor

Choose a reason for hiding this comment

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

we look to have called the same thing 3 different names in the params: paths, taxon-list and taxon_path are we able to use something consistent or are these three different things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, naming consistency needs looking at - was going to do this in a followup PR but i'll commit something here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated - I've opted to call the query param 'topic' across the controller and view. This is how we describe taxons to users so probably sensible to use that in the URL.

redirect_to '/' and return unless params[:paths].present?

taxon_path = params[:paths].first
load_taxon(taxon_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens here if this fails to find the taxon? does the breadcrumb stuff breaks should it redirect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Breaks noisily if it can't find a taxon with the given base path, which is reasonable i think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dwhenry added a controller test for this.

{
'title' => taxon['title'],
'links' => {
'taxons' => [taxon['content_id']]
Copy link
Contributor

Choose a reason for hiding this comment

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

we have called this taxon_tree when it is passed through with the content_item so I think that is the field we should be subscribing to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

quite right, updated.


<p class='email-option form-block'>or only one of the following</p>

<% @taxon.dig('links', 'child_taxons').each_with_index do |taxon, taxon_index| %>
Copy link
Contributor

Choose a reason for hiding this comment

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

might be nicer to use:

<%= render partial: "taxon", collection: @taxon.dig('links', 'child_taxons') %>

this would give youn the index variable in then view rather than having to pass it in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not worth it in this case, less clear whats going on - particularly as you then need to handle a default value for when you're rendering the parent taxon with this partial.

@@ -0,0 +1,43 @@
class TaxonomySignupsController < ApplicationController
def new
redirect_to '/' and return unless params[:paths].present?
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be redirecting back rather than to root?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would break in the absence of a referer - redirecting to root is the simplest thing to do in this case, especially as you'd never have a link on the site without the paths specified.

@@ -3,6 +3,7 @@
<head>
<title><%= yield :title %> - GOV.UK</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag 'application' %>
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this only be loaded in the footer? or at least lazy-loaded

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 that doesn't work in our layouts, this is the way it's done in the frontends I've seen.

Copy link
Contributor Author

@malcolmbaig malcolmbaig Mar 27, 2017

Choose a reason for hiding this comment

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

moved, although as discussed this is handled by slimmer (checked with @NickColley )

@tijmenb
Copy link
Contributor

tijmenb commented Mar 27, 2017

Can you add some screenshots?

@malcolmbaig
Copy link
Contributor Author

@tijmenb added

@@ -3,7 +3,8 @@ source 'https://rubygems.org'
gem 'rails', '4.2.5.2'
gem 'slimmer', '10.0.0'

gem 'govuk_frontend_toolkit', '~> 3.1.0'
gem 'govuk_elements_rails', '~> 3.0.1'
Copy link
Contributor

Choose a reason for hiding this comment

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

We're currently not using GOV.UK Elements on any GOV.UK Publishing frontend applications.

Seems as though the kind of UI you're implementing it makes sense to make use of Elements, just Elements is technically built in a different way to the rest of GOV.UK Publishing frontend.

Maybe let's have a chat through it offline

Choose a reason for hiding this comment

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

As far as I know you don't have or hardly have anything like this on GOV.UK. Looks like you had a chat about it though, so that's good.

@@ -0,0 +1,172 @@
;(function (global) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NickColley nothing, from the looks of it. The frontend work in this PR is almost entirely @carolinegreen . I would assume that with the removal of govuk_frontend_toolkit from this project, the show-hide-content javascript was simply copied across out of pragmatism.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mobaig @carolinegreen did govuk_frontend_toolkit conflict with govuk_elements?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@NickColley Unfortunately @carolinegreen is on holiday this week : (.

Choose a reason for hiding this comment

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

No, I wasn't familiar with rails asset pipeline, and was making sure it worked before I put that in. Managed to miss this, I've put in a pull request for this now.

#34

@NickColley
Copy link
Contributor

In your screenshots looks like there are indentation issues, the breadcrumbs should line up with the body of the page.

<%= render 'govuk_component/breadcrumbs', breadcrumbs: @breadcrumbs %>

<div class='email-signup column-two-thirds'>
<div class="govuk-title length-long">
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use the component instead.

@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch from 781ab90 to 09cf32e Compare March 28, 2017 10:36
Mo Baig added 3 commits March 28, 2017 12:05
Specifically, these failures scenarios:

- the absence of the expected query param
- not finding an item in the content store
- Add missing div and class for grid system, thus correcting alignment
  of page with breadcrumbs.
- Use a govuk_component for the title on both signup pages.
@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch from 619e75b to b0cf74e Compare March 28, 2017 11:05
@dwhenry
Copy link
Contributor

dwhenry commented Mar 28, 2017

As discussed would prefer not to use topic in the url, but understand the reasoning - nice external urls - so feel it is fine to do in this case.

@malcolmbaig malcolmbaig force-pushed the mb-taxonomy-email-signup branch from 011aa7e to ce64de0 Compare March 28, 2017 11:32
@malcolmbaig malcolmbaig merged commit 50f9ccb into master Mar 28, 2017
@malcolmbaig malcolmbaig deleted the mb-taxonomy-email-signup branch March 28, 2017 11:35
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.

5 participants