-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add update service page for both claims and placements
- Loading branch information
Showing
17 changed files
with
277 additions
and
37 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
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
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,5 @@ | ||
<section id="<%= service_update.id %>"> | ||
<%= title_element %> | ||
<p class="govuk-body govuk-!-margin-bottom-2"><%= date_pretty %></p> | ||
<div class="govuk-body"><%= content_html %></div> | ||
</section> |
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,26 @@ | ||
class ServiceUpdate::View < GovukComponent::Base | ||
attr_reader :service_update | ||
|
||
delegate :title, :content, :date, to: :service_update | ||
|
||
TITLE_CLASS = "govuk-heading-m govuk-!-margin-bottom-2" | ||
|
||
def initialize(service_update:) | ||
@service_update = service_update | ||
end | ||
|
||
def title_element | ||
tag.h2(title, class: TITLE_CLASS) | ||
end | ||
|
||
def date_pretty | ||
date.to_date.strftime("%e %B %Y") | ||
end | ||
|
||
def content_html | ||
custom_render = | ||
Redcarpet::Render::HTML.new(link_attributes: { class: "govuk-link" }) | ||
markdown = Redcarpet::Markdown.new(custom_render) | ||
markdown.render(content).html_safe | ||
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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class ServiceUpdatesController < ApplicationController | ||
include ApplicationHelper | ||
|
||
def index | ||
@service_name ||= current_service | ||
@service_updates = ServiceUpdate.where(service: @service_name) | ||
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,30 @@ | ||
class ServiceUpdate | ||
CLAIMS_SERVICE_UPDATES_YAML_FILE = | ||
Rails.root.join("db/claims_service_updates.yml").freeze | ||
PLACEMENTS_SERVICE_UPDATES_YAML_FILE = | ||
Rails.root.join("db/placements_service_updates.yml").freeze | ||
|
||
include ActiveModel::Model | ||
|
||
attr_accessor :date, :title, :content | ||
|
||
def id | ||
title.parameterize | ||
end | ||
|
||
def self.where(service:) | ||
path = file_path(service:) | ||
updates = YAML.load_file(path) || [] | ||
|
||
updates.map { |service_update| new(service_update) } | ||
end | ||
|
||
def self.file_path(service:) | ||
case service | ||
when :claims | ||
CLAIMS_SERVICE_UPDATES_YAML_FILE | ||
when :placements | ||
PLACEMENTS_SERVICE_UPDATES_YAML_FILE | ||
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,17 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds-from-desktop"> | ||
<h1 class="govuk-heading-xl"><%= t("service_updates.#{@service_name}.heading") %></h1> | ||
|
||
<h2 class="govuk-heading-m"><%= t("service_updates.contents") %></h2> | ||
<ul class="govuk-list app-list--dash govuk-!-margin-bottom-8 govuk-!-margin-left-3"> | ||
<% @service_updates.each do |service_update| %> | ||
<li><a class="govuk-link" href="#<%= service_update.id %>"><%= service_update.title %></a></li> | ||
<% end %> | ||
</ul> | ||
|
||
<% @service_updates.each do |service_update| %> | ||
<hr class="govuk-section-break govuk-section-break--l govuk-section-break--visible"> | ||
<%= render ServiceUpdate::View.new(service_update:) %> | ||
<% end %> | ||
</div> | ||
</div> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
scope module: :placements, as: :placements, constraints: { host: ENV["PLACEMENTS_HOST"] } do | ||
scope module: :placements, | ||
as: :placements, | ||
constraints: { | ||
host: ENV["PLACEMENTS_HOST"] | ||
} do | ||
root to: "pages#index" | ||
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,11 @@ | ||
# Example structure for adding service updates | ||
|
||
# - date: | ||
# type: String | ||
# format: YYYY-MM-DD | ||
# title: | ||
# type: String | ||
# format: Short text | ||
# content: | ||
# type: String | ||
# format: Multi-line text |
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,11 @@ | ||
# Example structure for adding service updates | ||
|
||
# - date: | ||
# type: String | ||
# format: YYYY-MM-DD | ||
# title: | ||
# type: String | ||
# format: Plain text | ||
# content: | ||
# type: String | ||
# format: Multi-line text |
Oops, something went wrong.