-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from Christine-horrocks/katylouise/WEBDEV-682_…
…proposed-neg-statutory-instruments [WEBDEV-682] Proposed Negative SIs
- Loading branch information
Showing
36 changed files
with
2,490 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,4 +286,4 @@ RUBY VERSION | |
ruby 2.5.1p57 | ||
|
||
BUNDLED WITH | ||
1.16.1 | ||
1.16.2 |
25 changes: 25 additions & 0 deletions
25
app/controllers/proposed_negative_statutory_instruments_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class ProposedNegativeStatutoryInstrumentsController < ApplicationController | ||
# Controller rendering proposed negative statutory instruments index and show pages | ||
before_action :build_request | ||
|
||
ROUTE_MAP = { | ||
index: proc { ParliamentHelper.parliament_request.proposed_negative_statutory_instrument_index }, | ||
show: proc { |params| ParliamentHelper.parliament_request.proposed_negative_statutory_instrument_by_id.set_url_params({ proposed_negative_statutory_instrument_id: params[:proposed_negative_statutory_instrument_id] }) } | ||
}.freeze | ||
|
||
def index | ||
@proposed_negative_statutory_instruments = FilterHelper.filter(@request, 'ProposedNegativeStatutoryInstrumentPaper') | ||
serializer = PageSerializer::ProposedNegativeStatutoryInstrumentsIndexPageSerializer.new(proposed_negative_statutory_instruments: @proposed_negative_statutory_instruments, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) | ||
|
||
render_page(serializer) | ||
end | ||
|
||
def show | ||
@proposed_negative_statutory_instrument = FilterHelper.filter(@request, 'ProposedNegativeStatutoryInstrumentPaper') | ||
@proposed_negative_statutory_instrument = @proposed_negative_statutory_instrument.first | ||
|
||
serializer = PageSerializer::ProposedNegativeStatutoryInstrumentsShowPageSerializer.new(proposed_negative_statutory_instrument: @proposed_negative_statutory_instrument, request_id: app_insights_request_id, data_alternates: @alternates, request_original_url: request.original_url) | ||
|
||
render_page(serializer) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/serializers/page_serializer/laid_thing_show_page_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module PageSerializer | ||
class LaidThingShowPageSerializer < PageSerializer::BasePageSerializer | ||
# Initialise a Laid Thing show page serializer. | ||
# | ||
# @param [<Grom::Node>] laid_thing a Grom::Node object of type LaidThing. | ||
# @param [String] request_id AppInsights request id | ||
# @param [Array<Hash>] data_alternates array containing the href and type of the alternative data urls | ||
# @param [String] request_original_url original url of the request | ||
def initialize(laid_thing:, request_id: nil, data_alternates: nil, request_original_url: nil) | ||
@laid_thing = laid_thing | ||
@work_package = @laid_thing.work_package | ||
@laying_body = @laid_thing&.laying&.body | ||
@laying_person = @laid_thing&.laying&.person | ||
@procedure = @work_package&.procedure | ||
|
||
super(request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) | ||
end | ||
|
||
private | ||
|
||
def content; end | ||
|
||
def parent_child_objects | ||
[].tap do |components| | ||
components << object_heading_paragraph(3, 'laid-thing.work-package', "<a href='/work-packages/#{@work_package&.graph_id}'>#{@work_package&.graph_id}</a>") | ||
components << object_heading_paragraph(4, 'laid-thing.procedure', "<a href='/procedures/#{@procedure&.graph_id}'>#{@procedure&.name}</a>") | ||
components << object_heading_paragraph(3, 'laid-thing.laying', @laid_thing&.laying&.graph_id) | ||
components << object_heading_paragraph(4, 'laid-thing.laid-date', l(@laid_thing&.laying&.date)) | ||
components << object_heading_paragraph(4, 'laid-thing.laying-body', @laying_body&.name) | ||
components << object_heading_paragraph(4, 'laid-thing.laying-person', @laying_person&.display_name) | ||
components << object_heading_paragraph(3, 'laid-thing.web-link', "<a href='#{@laid_thing.web_link}'>#{@laid_thing.web_link}</a>") | ||
end.flatten | ||
end | ||
|
||
def object_heading_paragraph(heading_size, heading_content, paragraph_content) | ||
[].tap do |components| | ||
components << ComponentSerializer::HeadingComponentSerializer.new(content: heading_content, size: heading_size).to_h | ||
components << ComponentSerializer::ParagraphComponentSerializer.new(content: [{ content: paragraph_content }]).to_h | ||
end | ||
end | ||
|
||
def section_objects | ||
[].tap do |components| | ||
components << ComponentSerializer::HeadingComponentSerializer.new(content: 'laid-thing.objects', size: 2).to_h | ||
components << parent_child_objects | ||
components << ComponentSerializer::HeadingComponentSerializer.new(content: connected_statutory_instruments_title, size: 3).to_h | ||
components << ComponentSerializer::ListComponentSerializer.new(display: 'generic', display_data: [display_data(component: 'list')], components: connected_statutory_instruments).to_h | ||
end.flatten | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module PageSerializer | ||
class ListPageSerializer < PageSerializer::BasePageSerializer | ||
# Initialise a list page serializer. | ||
# | ||
# @param [String] page_title title of the page | ||
# @param [String] request_id AppInsights request id | ||
# @param [Array<Hash>] data_alternates array containing the href and type of the alternative data urls | ||
# @param [String] request_original_url original url of the request | ||
def initialize(page_title: nil, request_id: nil, data_alternates: nil, request_original_url: nil) | ||
@page_title = page_title | ||
@data_alternates = data_alternates | ||
|
||
super(request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) | ||
end | ||
|
||
private | ||
|
||
attr_reader :page_title | ||
|
||
def meta | ||
super(title: page_title) | ||
end | ||
|
||
def content | ||
[].tap do |content| | ||
content << ComponentSerializer::SectionComponentSerializer.new(components: section_primary_components, type: 'primary').to_h | ||
content << ComponentSerializer::SectionComponentSerializer.new(components: section_components, type: 'section').to_h | ||
end | ||
end | ||
|
||
def section_primary_components | ||
[ComponentSerializer::Heading1ComponentSerializer.new({ heading_content: page_title }).to_h] | ||
end | ||
|
||
def section_components | ||
[ComponentSerializer::ListComponentSerializer.new(display: 'generic', display_data: [display_data(component: 'list', variant: 'block')], components: list_components).to_h] | ||
end | ||
|
||
def list_components | ||
raise StandardError, 'You must implement #list_components' | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
...ializers/page_serializer/proposed_negative_statutory_instruments_index_page_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module PageSerializer | ||
class ProposedNegativeStatutoryInstrumentsIndexPageSerializer < ListPageSerializer | ||
# Initialise a Proposed Negative Statutory Instruments index page serializer. | ||
# | ||
# @param [Array<Grom::Node>] proposed_negative_statutory_instruments an array of Grom::Node objects of type ProposedNegativeStatutoryInstrumentPaper. | ||
# @param [String] request_id AppInsights request id | ||
# @param [Array<Hash>] data_alternates array containing the href and type of the alternative data urls | ||
# @param [String] request_original_url original url of the request | ||
def initialize(proposed_negative_statutory_instruments:, request_id: nil, data_alternates: nil, request_original_url: nil) | ||
@proposed_negative_statutory_instruments = proposed_negative_statutory_instruments | ||
@data_alternates = data_alternates | ||
@title = 'proposed-negative-statutory-instruments.index.title' | ||
|
||
super(page_title: @title, request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) | ||
end | ||
|
||
private | ||
|
||
def list_components | ||
@proposed_negative_statutory_instruments.map do |statutory_instrument| | ||
ComponentSerializer::LinkComponentSerializer.new(link: "proposed-negative-statutory-instruments/#{statutory_instrument.graph_id}", content: statutory_instrument.name).to_h | ||
end | ||
end | ||
end | ||
end |
50 changes: 50 additions & 0 deletions
50
...rializers/page_serializer/proposed_negative_statutory_instruments_show_page_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module PageSerializer | ||
class ProposedNegativeStatutoryInstrumentsShowPageSerializer < LaidThingShowPageSerializer | ||
# Initialise a Proposed Negative Statutory Instruments show page serializer. | ||
# | ||
# @param [<Grom::Node>] proposed_negative_statutory_instrument a Grom::Node object of type ProposedNegativeStatutoryInstrumentPaper. | ||
# @param [String] request_id AppInsights request id | ||
# @param [Array<Hash>] data_alternates array containing the href and type of the alternative data urls | ||
# @param [String] request_original_url original url of the request | ||
def initialize(proposed_negative_statutory_instrument:, request_id: nil, data_alternates: nil, request_original_url: nil) | ||
@proposed_negative_statutory_instrument = proposed_negative_statutory_instrument | ||
@following_statutory_instruments = @proposed_negative_statutory_instrument.statutory_instrument_papers | ||
|
||
super(laid_thing: @proposed_negative_statutory_instrument, request_id: request_id, data_alternates: data_alternates, request_original_url: request_original_url) | ||
end | ||
|
||
private | ||
|
||
def meta | ||
super(title: title) | ||
end | ||
|
||
def title | ||
@proposed_negative_statutory_instrument.name | ||
end | ||
|
||
def content | ||
[].tap do |components| | ||
components << ComponentSerializer::SectionComponentSerializer.new(components: section_primary_components, type: 'primary').to_h | ||
components << ComponentSerializer::SectionComponentSerializer.new(components: section_objects, type: 'section').to_h | ||
end | ||
end | ||
|
||
def section_primary_components | ||
[ComponentSerializer::Heading1ComponentSerializer.new({ subheading_content: 'proposed-negative-statutory-instruments.show.subheading', heading_content: title }).to_h] | ||
end | ||
|
||
def connected_statutory_instruments | ||
@following_statutory_instruments.map do |stat_instrument| | ||
ComponentSerializer::LinkComponentSerializer.new( | ||
link: "/statutory-instruments/#{stat_instrument.graph_id}", | ||
content: stat_instrument.name | ||
).to_h | ||
end | ||
end | ||
|
||
def connected_statutory_instruments_title | ||
'proposed-negative-statutory-instruments.show.preceding-title' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.