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

Add content item links rules subgroups #1032

Merged
merged 6 commits into from
Aug 14, 2018

Conversation

oscarwyatt
Copy link
Contributor

@oscarwyatt oscarwyatt commented Aug 7, 2018

Extend content item navigation links to show content filtered by subgroups. Supersedes PR #1028 (add-content-item-links-rules)

screenshot-localhost-3090-2018 08 07-16-16-49

Visual regression results:
https://government-frontend-pr-1032.surge.sh/gallery.html

Component guide for this PR:
https://government-frontend-pr-1032.herokuapp.com/component-guide

Trello card
https://trello.com/c/A55u68Xw/98-implement-ruleset-for-showing-navigation-in-government-frontend

@sihugh sihugh closed this Aug 9, 2018
@sihugh sihugh reopened this Aug 9, 2018
@benthorner benthorner temporarily deployed to government-frontend-pr-1032 August 9, 2018 09:25 Inactive
@benthorner benthorner temporarily deployed to government-frontend-pr-1032 August 9, 2018 10:10 Inactive
@oscarwyatt oscarwyatt force-pushed the add-content-item-links-rules-subgroups branch from 54329f6 to a0069b6 Compare August 9, 2018 11:20
@benthorner benthorner temporarily deployed to government-frontend-pr-1032 August 9, 2018 11:20 Inactive
@oscarwyatt oscarwyatt force-pushed the add-content-item-links-rules-subgroups branch from a0069b6 to b38a83d Compare August 9, 2018 12:14
@benthorner benthorner temporarily deployed to government-frontend-pr-1032 August 9, 2018 12:14 Inactive
@@ -0,0 +1,167 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

We could maybe represent this configuration in YAML instead of JSON?

Doing so would allow us to use Rails' built in mechanism to load configuration files.

module MyApp
  class Application < Rails::Application
    config.taxonomy_navigation_links_out = config_for(:taxonomy_navigation_links_out)
  end
end
---
default: &default
  content_purpose_supergroup:
    news_and_communications:
    - title: policy_and_engagement
      type: content_purpose_supergroup
      supergroup: policy_and_engagement
    - title: research_and_data
      type: content_purpose_subgroup
      supergroup: transparency
    - title: guidance
      type: content_purpose_subgroup
      supergroup: guidance_and_regulation
    - title: news
      type: content_purpose_subgroup
      supergroup: news_and_communications
    - title: incidents
      type: content_purpose_subgroup
      supergroup: transparency
    guidance_and_regulation:
    - title: services
      type: content_purpose_supergroup
      supergroup: services
    - title: guidance
      type: content_purpose_subgroup
      supergroup: guidance_and_regulation
    - title: news
      type: content_purpose_subgroup
      supergroup: news_and_communications
    - title: decisions
      type: content_purpose_subgroup
      supergroup: transparency
    - title: step_by_step
      type: document_type
      supergroup: services
    services:
    - title: services
      type: content_purpose_supergroup
      supergroup: services
    - title: guidance
      type: content_purpose_subgroup
      supergroup: guidance_and_regulation
  content_purpose_subgroup:
    policy:
    - title: policy_and_engagement
      type: content_purpose_supergroup
      supergroup: policy_and_engagement
    - title: policy
      type: content_purpose_subgroup
      supergroup: policy_and_engagement
    incidents:
    - title: incidents
      type: content_purpose_subgroup
      supergroup: transparency
    - title: news
      type: content_purpose_subgroup
      supergroup: news_and_communications
    - title: research_and_data
      type: content_purpose_supergroup
      supergroup: transparency
    - title: guidance
      type: content_purpose_subgroup
      supergroup: guidance_and_regulation
    research_and_data:
    - title: research_and_data
      type: content_purpose_supergroup
      supergroup: transparency
    decisions:
    - title: news
      type: content_purpose_subgroup
      supergroup: news_and_communications
    - title: guidance
      type: content_purpose_subgroup
      supergroup: guidance_and_regulation
  document_type:
    fatality_notice: []
    manual: []
    manual_section: []
    open_consultation:
    - title: policy_and_engagement
      type: content_purpose_supergroup
      supergroup: policy_and_engagement
    - title: decisions
      type: content_purpose_subgroup
      supergroup: transparency
    closed_consultation:
    - title: policy_and_engagement
      type: content_purpose_supergroup
      supergroup: policy_and_engagement
    - title: decisions
      type: content_purpose_subgroup
      supergroup: transparency
    consultation_outcome:
    - title: decisions
      type: content_purpose_subgroup
      supergroup: transparency

development:
  <<: *default

test:
  <<: *default

production:
  <<: *default

@@ -0,0 +1,107 @@
module ContentItem
module LinksOut
def links_out_supergroups
Copy link
Contributor

Choose a reason for hiding this comment

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

Should all these methods be added to the public interface of the class that includes this module?

end

def any?
[email protected]?
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 use the public links interface here since it implements a default?

We could maybe delegate the any? method to the links object and initialise the default like so:

class LinkRule
  extend Forwardable
  
  def initialize(content_item)
    @content_item = content_item
    @rules = load_rules
    @links = fetch_links || []
  end
  
  def_delegator :@links, :any?

  # ...
end

@benthorner benthorner temporarily deployed to government-frontend-pr-1032 August 9, 2018 16:54 Inactive
@oscarwyatt oscarwyatt force-pushed the add-content-item-links-rules-subgroups branch from 902839c to c20318d Compare August 14, 2018 09:30
@benthorner benthorner temporarily deployed to government-frontend-pr-1032 August 14, 2018 09:30 Inactive
oscarwyatt and others added 6 commits August 14, 2018 12:10
remove force b variant

fixed json file

fixed minor controller mistype

Add links out to configure taxonomy navigation

linting

Filter content page navigation links by subgroups

remove force b variant

fixed json file

started
@oscarwyatt oscarwyatt force-pushed the add-content-item-links-rules-subgroups branch from c20318d to b549356 Compare August 14, 2018 11:35
@andrewgarner andrewgarner merged commit 44f6c50 into master Aug 14, 2018
@andrewgarner andrewgarner deleted the add-content-item-links-rules-subgroups branch August 14, 2018 12:44
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.

4 participants